@@ -13,6 +13,9 @@ permissions:
1313jobs :
1414 check-and-release :
1515 runs-on : ubuntu-latest
16+ env :
17+ PLUGIN_FILE : enginescript-site-optimizer.php
18+ PLUGIN_SLUG : enginescript-site-optimizer
1619 steps :
1720 - name : Checkout code
1821 uses : actions/checkout@v6
@@ -22,14 +25,14 @@ jobs:
2225 - name : Get latest version
2326 id : get_version
2427 run : |
25- VERSION=$(grep -oP "Version: \K[0-9]+\.[0-9]+\.[0-9]+" enginescript-site-optimizer.php )
28+ VERSION=$(grep -oP "Version: \K[0-9]+\.[0-9]+\.[0-9]+" "$PLUGIN_FILE" )
2629 echo "version=$VERSION" >> $GITHUB_OUTPUT
2730 echo "Found version: $VERSION"
2831
2932 - name : Check if release exists
3033 id : check_release
3134 run : |
32- RELEASE_EXISTS=$(curl -s -o /dev/null -w "%{http_code}" https://api.github.com/repos/${{ github.repository }} /releases/tags/v${{ steps.get_version.outputs.version }})
35+ RELEASE_EXISTS=$(curl -s -o /dev/null -w "%{http_code}" " https://api.github.com/repos/${GITHUB_REPOSITORY} /releases/tags/v${{ steps.get_version.outputs.version }}" )
3336 if [[ "$RELEASE_EXISTS" == "200" ]]; then
3437 echo "exists=true" >> $GITHUB_OUTPUT
3538 echo "Release v${{ steps.get_version.outputs.version }} already exists"
4851 TMP_FILE=$(mktemp)
4952
5053 # Update the version badge with the new version and logo
51- 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"
54+ sed -E " s#\[!\[Version\]\(https://img\.shields\.io/badge/Version-[0-9]+\.[0-9]+\.[0-9]+-orange\.svg\?logo=github\)\]\(https://github\.com/[^[:space:])]+/ releases/(latest/ download|download /v[0-9]+\.[0-9]+\.[0-9]+)/[^[:space:])]+- [0-9]+\.[0-9]+\.[0-9]+\.zip\)#[](https://github.com/${GITHUB_REPOSITORY}/ releases/latest/ download/${PLUGIN_SLUG}-${ VERSION} .zip)#g" "$README_FILE" > "$TMP_FILE"
5255
5356 # Replace file if changes were made
5457 if ! cmp -s "$README_FILE" "$TMP_FILE"; then
6265 # Commit and push the changes
6366 git add "$README_FILE"
6467 git commit -m "docs: update README.md version to $VERSION [skip ci]"
65- git push https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }} .git
68+ git push " https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} .git"
6669
6770 echo "::notice::README.md updated with latest version $VERSION"
6871 else
7578 - name : Create zip file
7679 if : steps.check_release.outputs.exists == 'false'
7780 run : |
78- PLUGIN_SLUG="enginescript-site-optimizer"
7981 rm -rf "$PLUGIN_SLUG"
8082 mkdir -p "$PLUGIN_SLUG"
81- cp enginescript-site-optimizer.php "$PLUGIN_SLUG/"
83+ cp "$PLUGIN_FILE" "$PLUGIN_SLUG/"
8284 cp -r includes "$PLUGIN_SLUG/"
8385 cp readme.txt "$PLUGIN_SLUG/"
8486 cp README.md "$PLUGIN_SLUG/"
@@ -113,7 +115,7 @@ jobs:
113115 3. Activate the plugin
114116
115117 [Full Documentation](https://github.com/${{ github.repository }})
116- files : enginescript-site-optimizer -${{ steps.get_version.outputs.version }}.zip
118+ files : ${{ env.PLUGIN_SLUG }} -${{ steps.get_version.outputs.version }}.zip
117119 draft : false
118120 prerelease : false
119121 generate_release_notes : false
0 commit comments