|
39 | 39 | echo "Release v${{ steps.get_version.outputs.version }} does not exist yet" |
40 | 40 | fi |
41 | 41 |
|
| 42 | + - name: Update README version |
| 43 | + if: steps.check_release.outputs.exists == 'false' |
| 44 | + env: |
| 45 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + VERSION: ${{ steps.get_version.outputs.version }} |
| 47 | + run: | |
| 48 | + README_FILE="README.md" |
| 49 | + TMP_FILE=$(mktemp) |
| 50 | +
|
| 51 | + # Update the version badge with the new version and logo |
| 52 | + sed -E 's#\[!\[Version\]\(https://img\.shields\.io/badge/Version-[0-9]+\.[0-9]+\.[0-9]+-orange\.svg\?logo=github\)\]\(https://github\.com/EngineScript/enginescript-site-optimizer/releases/download/v[0-9]+\.[0-9]+\.[0-9]+/enginescript-site-optimizer-[0-9]+\.[0-9]+\.[0-9]+\.zip\)#[](https://github.com/EngineScript/enginescript-site-optimizer/releases/download/v'"$VERSION"'/enginescript-site-optimizer-'"$VERSION"'.zip)#g' "$README_FILE" > "$TMP_FILE" |
| 53 | +
|
| 54 | + # Replace file if changes were made |
| 55 | + if ! cmp -s "$README_FILE" "$TMP_FILE"; then |
| 56 | + cp "$TMP_FILE" "$README_FILE" |
| 57 | + echo "Updated README.md with version $VERSION" |
| 58 | +
|
| 59 | + # Configure git |
| 60 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 61 | + git config --local user.name "github-actions[bot]" |
| 62 | +
|
| 63 | + # Commit and push the changes |
| 64 | + git add "$README_FILE" |
| 65 | + git commit -m "docs: update README.md version to $VERSION [skip ci]" |
| 66 | + git push https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git |
| 67 | +
|
| 68 | + echo "::notice::README.md updated with latest version $VERSION" |
| 69 | + else |
| 70 | + echo "::notice::README.md already has the correct version" |
| 71 | + fi |
| 72 | +
|
| 73 | + # Clean up temporary file |
| 74 | + rm "$TMP_FILE" |
| 75 | +
|
42 | 76 | - name: Create zip file |
43 | 77 | if: steps.check_release.outputs.exists == 'false' |
44 | 78 | run: | |
@@ -81,37 +115,3 @@ jobs: |
81 | 115 | draft: false |
82 | 116 | prerelease: false |
83 | 117 | generate_release_notes: false |
84 | | - |
85 | | - - name: Update README version |
86 | | - if: steps.check_release.outputs.exists == 'false' |
87 | | - env: |
88 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
89 | | - VERSION: ${{ steps.get_version.outputs.version }} |
90 | | - run: | |
91 | | - README_FILE="README.md" |
92 | | - TMP_FILE=$(mktemp) |
93 | | - |
94 | | - # Update the version badge with the new version and logo |
95 | | - sed -E 's/\[\!Version\]\(https:\/\/img\.shields\.io\/badge\/Version-[0-9]+\.[0-9]+\.[0-9]+-orange\.svg\?logo=github\)\]\(https:\/\/github\.com\/EngineScript\/enginescript-site-exporter\/releases\/latest\/download\/enginescript-site-exporter-[0-9]+\.[0-9]+\.[0-9]+\.zip\)/\[\!Version\]\(https:\/\/img\.shields\.io\/badge\/Version-'"$VERSION"'-orange\.svg\?logo=github\)\]\(https:\/\/github\.com\/EngineScript\/enginescript-site-exporter\/releases\/latest\/download\/enginescript-site-exporter-'"$VERSION"'\.zip\)/g' "$README_FILE" > "$TMP_FILE" |
96 | | - |
97 | | - # Replace file if changes were made |
98 | | - if ! cmp -s "$README_FILE" "$TMP_FILE"; then |
99 | | - cp "$TMP_FILE" "$README_FILE" |
100 | | - echo "Updated README.md with version $VERSION" |
101 | | - |
102 | | - # Configure git |
103 | | - git config --local user.email "github-actions[bot]@users.noreply.github.com" |
104 | | - git config --local user.name "github-actions[bot]" |
105 | | - |
106 | | - # Commit and push the changes |
107 | | - git add "$README_FILE" |
108 | | - git commit -m "docs: update README.md version to $VERSION [skip ci]" |
109 | | - git push https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git |
110 | | - |
111 | | - echo "::notice::README.md updated with latest version $VERSION" |
112 | | - else |
113 | | - echo "::notice::README.md already has the correct version" |
114 | | - fi |
115 | | - |
116 | | - # Clean up temporary file |
117 | | - rm "$TMP_FILE" |
0 commit comments