From 869aa23fe9c3d52137dfed3dfbd7064c768c8540 Mon Sep 17 00:00:00 2001 From: rafaeljohn9 Date: Tue, 1 Jul 2025 13:42:00 +0300 Subject: [PATCH 01/10] feat: enable dynamic update of version in README Signed-off-by: rafaeljohn9 --- .github/workflows/update-readme-version.yml | 50 +++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/update-readme-version.yml diff --git a/.github/workflows/update-readme-version.yml b/.github/workflows/update-readme-version.yml new file mode 100644 index 0000000..08cb946 --- /dev/null +++ b/.github/workflows/update-readme-version.yml @@ -0,0 +1,50 @@ +# .github/workflows/update-readme-version.yml +name: Update README Version + +on: + push: + tags: + - 'v*' # Triggers on any tag starting with 'v' + +permissions: + contents: write # Required for pushing changes + +jobs: + update-readme: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: main # Checkout main branch instead of the tag + fetch-depth: 0 # Fetch all history for all tags and branches + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Get the version from tag + id: get_version + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + + - name: Update README.md + run: | + # Replace the version in the specific line + sed -i "s/To install the templates for this specific version (\`v[0-9]\+\.[0-9]\+\.[0-9]\+\`)/To install the templates for this specific version (\`${{ steps.get_version.outputs.VERSION }}\`)/g" README.md + sed -i "s|https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]\+\.[0-9]\+\.[0-9]\+|https://github.com/RafaelJohn9/gh-templates/releases/tag/${{ steps.get_version.outputs.VERSION }}|g" README.md + + - name: Check if README was modified + id: check_changes + run: | + if git diff --quiet README.md; then + echo "changed=false" >> $GITHUB_OUTPUT + else + echo "changed=true" >> $GITHUB_OUTPUT + fi + + - name: Commit and push changes + if: steps.check_changes.outputs.changed == 'true' + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add README.md + git commit -m "Update README version to ${{ steps.get_version.outputs.VERSION }}" + git push origin main From a36662c416d8a3af82b8868db920c8d35e67a910 Mon Sep 17 00:00:00 2001 From: rafaeljohn9 Date: Tue, 1 Jul 2025 13:50:30 +0300 Subject: [PATCH 02/10] fix: added a sed command on account of a missing line Signed-off-by: rafaeljohn9 --- .github/workflows/update-readme-version.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/update-readme-version.yml b/.github/workflows/update-readme-version.yml index 08cb946..1e786d7 100644 --- a/.github/workflows/update-readme-version.yml +++ b/.github/workflows/update-readme-version.yml @@ -30,6 +30,7 @@ jobs: # Replace the version in the specific line sed -i "s/To install the templates for this specific version (\`v[0-9]\+\.[0-9]\+\.[0-9]\+\`)/To install the templates for this specific version (\`${{ steps.get_version.outputs.VERSION }}\`)/g" README.md sed -i "s|https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]\+\.[0-9]\+\.[0-9]\+|https://github.com/RafaelJohn9/gh-templates/releases/tag/${{ steps.get_version.outputs.VERSION }}|g" README.md + sed -i "s/\(\[v\)[0-9]\+\.[0-9]\+\.[0-9]\+\( release page](https:\/\/github.com\/RafaelJohn9\/gh-templates\/releases\/tag\/\)v[0-9]\+\.[0-9]\+\.[0-9]\+\()/\1${{ steps.get_version.outputs.VERSION }}\2${{ steps.get_version.outputs.VERSION }}\3/g" README.md - name: Check if README was modified id: check_changes From 3c382e873b53b1c483319f4c31fd166dc7d6aadc Mon Sep 17 00:00:00 2001 From: rafaeljohn9 Date: Tue, 1 Jul 2025 13:53:23 +0300 Subject: [PATCH 03/10] fix: both link part and displayed message part will be displayed Signed-off-by: rafaeljohn9 --- .github/workflows/update-readme-version.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/update-readme-version.yml b/.github/workflows/update-readme-version.yml index 1e786d7..1b88c4e 100644 --- a/.github/workflows/update-readme-version.yml +++ b/.github/workflows/update-readme-version.yml @@ -28,9 +28,8 @@ jobs: - name: Update README.md run: | # Replace the version in the specific line - sed -i "s/To install the templates for this specific version (\`v[0-9]\+\.[0-9]\+\.[0-9]\+\`)/To install the templates for this specific version (\`${{ steps.get_version.outputs.VERSION }}\`)/g" README.md + sed -i "s/To install the templates for this specific version (\`v[0-9]\+\.[0-9]\+\.[0-9]\+\`), download the appropriate binary for your platform from the \[v[0-9]\+\.[0-9]\+\.[0-9]\+ release page\](https:\/\/github.com\/RafaelJohn9\/gh-templates\/releases\/tag\/v[0-9]\+\.[0-9]\+\.[0-9]\+\)./To install the templates for this specific version (\`v${{ steps.get_version.outputs.VERSION }}\`), download the appropriate binary for your platform from the \[v${{ steps.get_version.outputs.VERSION }} release page\](https:\/\/github.com\/RafaelJohn9\/gh-templates\/releases\/tag\/v${{ steps.get_version.outputs.VERSION }})./g" README.md sed -i "s|https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]\+\.[0-9]\+\.[0-9]\+|https://github.com/RafaelJohn9/gh-templates/releases/tag/${{ steps.get_version.outputs.VERSION }}|g" README.md - sed -i "s/\(\[v\)[0-9]\+\.[0-9]\+\.[0-9]\+\( release page](https:\/\/github.com\/RafaelJohn9\/gh-templates\/releases\/tag\/\)v[0-9]\+\.[0-9]\+\.[0-9]\+\()/\1${{ steps.get_version.outputs.VERSION }}\2${{ steps.get_version.outputs.VERSION }}\3/g" README.md - name: Check if README was modified id: check_changes From 3df872e9d954351b4080e080278f72714e17edee Mon Sep 17 00:00:00 2001 From: rafaeljohn9 Date: Tue, 1 Jul 2025 13:57:16 +0300 Subject: [PATCH 04/10] fix: Escape the forward slashes and parentheses properly in the sed pattern Signed-off-by: rafaeljohn9 --- .github/workflows/update-readme-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-readme-version.yml b/.github/workflows/update-readme-version.yml index 1b88c4e..1fa1d25 100644 --- a/.github/workflows/update-readme-version.yml +++ b/.github/workflows/update-readme-version.yml @@ -28,7 +28,7 @@ jobs: - name: Update README.md run: | # Replace the version in the specific line - sed -i "s/To install the templates for this specific version (\`v[0-9]\+\.[0-9]\+\.[0-9]\+\`), download the appropriate binary for your platform from the \[v[0-9]\+\.[0-9]\+\.[0-9]\+ release page\](https:\/\/github.com\/RafaelJohn9\/gh-templates\/releases\/tag\/v[0-9]\+\.[0-9]\+\.[0-9]\+\)./To install the templates for this specific version (\`v${{ steps.get_version.outputs.VERSION }}\`), download the appropriate binary for your platform from the \[v${{ steps.get_version.outputs.VERSION }} release page\](https:\/\/github.com\/RafaelJohn9\/gh-templates\/releases\/tag\/v${{ steps.get_version.outputs.VERSION }})./g" README.md + sed -i "s|To install the templates for this specific version (\`v[0-9]\+\.[0-9]\+\.[0-9]\+\`), download the appropriate binary for your platform from the \[v[0-9]\+\.[0-9]\+\.[0-9]\+ release page\](https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]\+\.[0-9]\+\.[0-9]\+).|To install the templates for this specific version (\`v${{ steps.get_version.outputs.VERSION }}\`), download the appropriate binary for your platform from the \[v${{ steps.get_version.outputs.VERSION }} release page\](https://github.com/RafaelJohn9/gh-templates/releases/tag/v${{ steps.get_version.outputs.VERSION }}).|g" README.md sed -i "s|https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]\+\.[0-9]\+\.[0-9]\+|https://github.com/RafaelJohn9/gh-templates/releases/tag/${{ steps.get_version.outputs.VERSION }}|g" README.md - name: Check if README was modified From 62dee53f4c3baf917547916f340a544ac75ebbe0 Mon Sep 17 00:00:00 2001 From: rafaeljohn9 Date: Tue, 1 Jul 2025 14:07:26 +0300 Subject: [PATCH 05/10] fix: update sed commands Signed-off-by: rafaeljohn9 --- .github/workflows/update-readme-version.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-readme-version.yml b/.github/workflows/update-readme-version.yml index 1fa1d25..7da3cbd 100644 --- a/.github/workflows/update-readme-version.yml +++ b/.github/workflows/update-readme-version.yml @@ -27,9 +27,21 @@ jobs: - name: Update README.md run: | - # Replace the version in the specific line - sed -i "s|To install the templates for this specific version (\`v[0-9]\+\.[0-9]\+\.[0-9]\+\`), download the appropriate binary for your platform from the \[v[0-9]\+\.[0-9]\+\.[0-9]\+ release page\](https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]\+\.[0-9]\+\.[0-9]\+).|To install the templates for this specific version (\`v${{ steps.get_version.outputs.VERSION }}\`), download the appropriate binary for your platform from the \[v${{ steps.get_version.outputs.VERSION }} release page\](https://github.com/RafaelJohn9/gh-templates/releases/tag/v${{ steps.get_version.outputs.VERSION }}).|g" README.md - sed -i "s|https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]\+\.[0-9]\+\.[0-9]\+|https://github.com/RafaelJohn9/gh-templates/releases/tag/${{ steps.get_version.outputs.VERSION }}|g" README.md + VERSION=${{ steps.get_version.outputs.VERSION }} + + # Escape dots for regex + ESCAPED_VERSION=$(echo "$VERSION" | sed 's/\./\\./g') + + # Update "To install the templates..." sentence with new version + sed -E -i "s|To install the templates for this specific version \(`v[0-9]+\.[0-9]+\.[0-9]+`\), download the appropriate binary for your platform from the \[v[0-9]+\.[0-9]+\.[0-9]+ release page\]\(https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]+\.[0-9]+\.[0-9]+\)|To install the templates for this specific version (\`v$VERSION\`), download the appropriate binary for your platform from the \[v$VERSION release page\](https://github.com/RafaelJohn9/gh-templates/releases/tag/v$VERSION)|" README.md + + # Update all GitHub release **tag** links + sed -E -i "s|https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]+\.[0-9]+\.[0-9]+|https://github.com/RafaelJohn9/gh-templates/releases/tag/v$VERSION|g" README.md + + # Update all GitHub release **download** links + sed -E -i "s|https://github.com/RafaelJohn9/gh-templates/releases/download/v[0-9]+\.[0-9]+\.[0-9]+|https://github.com/RafaelJohn9/gh-templates/releases/download/v$VERSION|g" README.md + + - name: Check if README was modified id: check_changes From 24c3aae9fc9af2236768bdc4d9b7ca4c0cdfe352 Mon Sep 17 00:00:00 2001 From: rafaeljohn9 Date: Tue, 1 Jul 2025 14:13:30 +0300 Subject: [PATCH 06/10] fix: removed redundant v while giving versions Signed-off-by: rafaeljohn9 --- .github/workflows/update-readme-version.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-readme-version.yml b/.github/workflows/update-readme-version.yml index 7da3cbd..595dcfc 100644 --- a/.github/workflows/update-readme-version.yml +++ b/.github/workflows/update-readme-version.yml @@ -33,13 +33,13 @@ jobs: ESCAPED_VERSION=$(echo "$VERSION" | sed 's/\./\\./g') # Update "To install the templates..." sentence with new version - sed -E -i "s|To install the templates for this specific version \(`v[0-9]+\.[0-9]+\.[0-9]+`\), download the appropriate binary for your platform from the \[v[0-9]+\.[0-9]+\.[0-9]+ release page\]\(https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]+\.[0-9]+\.[0-9]+\)|To install the templates for this specific version (\`v$VERSION\`), download the appropriate binary for your platform from the \[v$VERSION release page\](https://github.com/RafaelJohn9/gh-templates/releases/tag/v$VERSION)|" README.md + sed -E -i "s|To install the templates for this specific version \(`v[0-9]+\.[0-9]+\.[0-9]+`\), download the appropriate binary for your platform from the \[v[0-9]+\.[0-9]+\.[0-9]+ release page\]\(https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]+\.[0-9]+\.[0-9]+\)|To install the templates for this specific version (\`$VERSION\`), download the appropriate binary for your platform from the \[$VERSION release page\](https://github.com/RafaelJohn9/gh-templates/releases/tag/$VERSION)|" README.md # Update all GitHub release **tag** links - sed -E -i "s|https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]+\.[0-9]+\.[0-9]+|https://github.com/RafaelJohn9/gh-templates/releases/tag/v$VERSION|g" README.md + sed -E -i "s|https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]+\.[0-9]+\.[0-9]+|https://github.com/RafaelJohn9/gh-templates/releases/tag/$VERSION|g" README.md # Update all GitHub release **download** links - sed -E -i "s|https://github.com/RafaelJohn9/gh-templates/releases/download/v[0-9]+\.[0-9]+\.[0-9]+|https://github.com/RafaelJohn9/gh-templates/releases/download/v$VERSION|g" README.md + sed -E -i "s|https://github.com/RafaelJohn9/gh-templates/releases/download/v[0-9]+\.[0-9]+\.[0-9]+|https://github.com/RafaelJohn9/gh-templates/releases/download/$VERSION|g" README.md From ff6b9d16df903f6b09fc361def6d8b071035ca41 Mon Sep 17 00:00:00 2001 From: rafaeljohn9 Date: Tue, 1 Jul 2025 14:18:53 +0300 Subject: [PATCH 07/10] fix: replace the version in both markdown and plain-text Signed-off-by: rafaeljohn9 --- .github/workflows/update-readme-version.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-readme-version.yml b/.github/workflows/update-readme-version.yml index 595dcfc..586b9fe 100644 --- a/.github/workflows/update-readme-version.yml +++ b/.github/workflows/update-readme-version.yml @@ -32,8 +32,10 @@ jobs: # Escape dots for regex ESCAPED_VERSION=$(echo "$VERSION" | sed 's/\./\\./g') - # Update "To install the templates..." sentence with new version + # Replace the version in both Markdown and plain-text sed -E -i "s|To install the templates for this specific version \(`v[0-9]+\.[0-9]+\.[0-9]+`\), download the appropriate binary for your platform from the \[v[0-9]+\.[0-9]+\.[0-9]+ release page\]\(https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]+\.[0-9]+\.[0-9]+\)|To install the templates for this specific version (\`$VERSION\`), download the appropriate binary for your platform from the \[$VERSION release page\](https://github.com/RafaelJohn9/gh-templates/releases/tag/$VERSION)|" README.md + sed -E -i "s|To install the templates for this specific version \(v[0-9]+\.[0-9]+\.[0-9]+\), download the appropriate binary for your platform from the v[0-9]+\.[0-9]+\.[0-9]+ release page\.|To install the templates for this specific version ($VERSION), download the appropriate binary for your platform from the $VERSION release page.|" README.md + # Update all GitHub release **tag** links sed -E -i "s|https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]+\.[0-9]+\.[0-9]+|https://github.com/RafaelJohn9/gh-templates/releases/tag/$VERSION|g" README.md From 0891bb17ed2306060f494fdb0efa754dc089ba2d Mon Sep 17 00:00:00 2001 From: rafaeljohn9 Date: Tue, 1 Jul 2025 14:24:00 +0300 Subject: [PATCH 08/10] fix: handle the sed cmd correctly to correctly update the versions Signed-off-by: rafaeljohn9 --- .github/workflows/update-readme-version.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/update-readme-version.yml b/.github/workflows/update-readme-version.yml index 586b9fe..dcb1152 100644 --- a/.github/workflows/update-readme-version.yml +++ b/.github/workflows/update-readme-version.yml @@ -33,9 +33,7 @@ jobs: ESCAPED_VERSION=$(echo "$VERSION" | sed 's/\./\\./g') # Replace the version in both Markdown and plain-text - sed -E -i "s|To install the templates for this specific version \(`v[0-9]+\.[0-9]+\.[0-9]+`\), download the appropriate binary for your platform from the \[v[0-9]+\.[0-9]+\.[0-9]+ release page\]\(https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]+\.[0-9]+\.[0-9]+\)|To install the templates for this specific version (\`$VERSION\`), download the appropriate binary for your platform from the \[$VERSION release page\](https://github.com/RafaelJohn9/gh-templates/releases/tag/$VERSION)|" README.md - sed -E -i "s|To install the templates for this specific version \(v[0-9]+\.[0-9]+\.[0-9]+\), download the appropriate binary for your platform from the v[0-9]+\.[0-9]+\.[0-9]+ release page\.|To install the templates for this specific version ($VERSION), download the appropriate binary for your platform from the $VERSION release page.|" README.md - + sed -E -i "s|To install the templates for this specific version (\`v[0-9]+\.[0-9]+\.[0-9]+\`), download the appropriate binary for your platform from the \[v[0-9]+\.[0-9]+\.[0-9]+ release page\]\(https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]+\.[0-9]+\.[0-9]+\).|To install the templates for this specific version (\`$VERSION\`), download the appropriate binary for your platform from the \[$VERSION release page\](https://github.com/RafaelJohn9/gh-templates/releases/tag/$VERSION).|g" README.md # Update all GitHub release **tag** links sed -E -i "s|https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]+\.[0-9]+\.[0-9]+|https://github.com/RafaelJohn9/gh-templates/releases/tag/$VERSION|g" README.md From 350a7f8906cd6a046321b6f72a092d98150d72e1 Mon Sep 17 00:00:00 2001 From: rafaeljohn9 Date: Tue, 1 Jul 2025 14:30:46 +0300 Subject: [PATCH 09/10] fix: sed command to correctly update markdown text part Signed-off-by: rafaeljohn9 --- .github/workflows/update-readme-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-readme-version.yml b/.github/workflows/update-readme-version.yml index dcb1152..069ef85 100644 --- a/.github/workflows/update-readme-version.yml +++ b/.github/workflows/update-readme-version.yml @@ -33,7 +33,7 @@ jobs: ESCAPED_VERSION=$(echo "$VERSION" | sed 's/\./\\./g') # Replace the version in both Markdown and plain-text - sed -E -i "s|To install the templates for this specific version (\`v[0-9]+\.[0-9]+\.[0-9]+\`), download the appropriate binary for your platform from the \[v[0-9]+\.[0-9]+\.[0-9]+ release page\]\(https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]+\.[0-9]+\.[0-9]+\).|To install the templates for this specific version (\`$VERSION\`), download the appropriate binary for your platform from the \[$VERSION release page\](https://github.com/RafaelJohn9/gh-templates/releases/tag/$VERSION).|g" README.md + sed -E -i "s|To install the templates for this specific version \(`v[0-9]+\.[0-9]+\.[0-9]+`\), download the appropriate binary for your platform from the \[v[0-9]+\.[0-9]+\.[0-9]+ release page\]\(https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]+\.[0-9]+\.[0-9]+\)|To install the templates for this specific version (\`$VERSION\`), download the appropriate binary for your platform from the \[$VERSION release page\](https://github.com/RafaelJohn9/gh-templates/releases/tag/$VERSION)|g" README.md # Update all GitHub release **tag** links sed -E -i "s|https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]+\.[0-9]+\.[0-9]+|https://github.com/RafaelJohn9/gh-templates/releases/tag/$VERSION|g" README.md From ed6bf68c2ed92e59a97411a55e0b28aab973d6e3 Mon Sep 17 00:00:00 2001 From: rafaeljohn9 Date: Tue, 1 Jul 2025 14:36:25 +0300 Subject: [PATCH 10/10] fix: updated sed command Signed-off-by: rafaeljohn9 --- .github/workflows/update-readme-version.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update-readme-version.yml b/.github/workflows/update-readme-version.yml index 069ef85..7d95ab0 100644 --- a/.github/workflows/update-readme-version.yml +++ b/.github/workflows/update-readme-version.yml @@ -29,11 +29,9 @@ jobs: run: | VERSION=${{ steps.get_version.outputs.VERSION }} - # Escape dots for regex - ESCAPED_VERSION=$(echo "$VERSION" | sed 's/\./\\./g') - # Replace the version in both Markdown and plain-text - sed -E -i "s|To install the templates for this specific version \(`v[0-9]+\.[0-9]+\.[0-9]+`\), download the appropriate binary for your platform from the \[v[0-9]+\.[0-9]+\.[0-9]+ release page\]\(https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]+\.[0-9]+\.[0-9]+\)|To install the templates for this specific version (\`$VERSION\`), download the appropriate binary for your platform from the \[$VERSION release page\](https://github.com/RafaelJohn9/gh-templates/releases/tag/$VERSION)|g" README.md + sed -i "s|To install the templates for this specific version (\`v[0-9]\+\.[0-9]\+\.[0-9]\+\`), download the appropriate binary for your platform from the \[v[0-9]\+\.[0-9]\+\.[0-9]\+ release page\](https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]\+\.[0-9]\+\.[0-9]\+).|To install the templates for this specific version (\`$VERSION\`), download the appropriate binary for your platform from the \[$VERSION release page\](https://github.com/RafaelJohn9/gh-templates/releases/tag/$VERSION).|g" README.md + # Update all GitHub release **tag** links sed -E -i "s|https://github.com/RafaelJohn9/gh-templates/releases/tag/v[0-9]+\.[0-9]+\.[0-9]+|https://github.com/RafaelJohn9/gh-templates/releases/tag/$VERSION|g" README.md