1414jobs :
1515 build :
1616 runs-on : ubuntu-latest
17+ permissions :
18+ contents : write
1719 steps :
1820 - name : Checkout
1921 uses : actions/checkout@v6
20- with :
21- ref : " master"
2222 - name : Set up Node.js
2323 uses : actions/setup-node@v6
2424 with :
@@ -74,16 +74,16 @@ jobs:
7474 name : Generate release tag
7575 run : |
7676 cd backend
77- SUBSTORE_RELEASE=` node --eval="process.stdout.write(require('./package.json').version)"`
78- echo "release_tag=$SUBSTORE_RELEASE" >> $ GITHUB_OUTPUT
77+ SUBSTORE_RELEASE="$( node --eval="process.stdout.write(require('./package.json').version)")"
78+ echo "release_tag=${ SUBSTORE_RELEASE} " >> "${ GITHUB_OUTPUT}"
7979 - name : Prepare release
8080 run : |
8181 cd backend
8282 pnpm i -D conventional-changelog-cli
8383 pnpm run changelog
8484 - name : Release
85- uses : softprops/action-gh-release@v1
86- if : ${{ success() }}
85+ uses : softprops/action-gh-release@v3
86+ if : ${{ success() && github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }}
8787 env :
8888 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
8989 with :
@@ -99,16 +99,36 @@ jobs:
9999 ./backend/dist/proxy-utils.esm.mjs
100100 ./backend/dist/sub-store.bundle.js
101101 - name : Git push assets to "release" branch
102+ if : ${{ success() && github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }}
103+ env :
104+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
102105 run : |
103- cd backend/dist || exit 1
104- git init
106+ set -euo pipefail
107+
108+ auth_header="AUTHORIZATION: bearer ${GITHUB_TOKEN}"
109+ repo_url="https://github.com/${GITHUB_REPOSITORY}.git"
110+ release_dir="${RUNNER_TEMP}/release-dist"
111+
112+ rm -rf "${release_dir}"
113+ if git -c http.https://github.com/.extraheader="${auth_header}" ls-remote --exit-code --heads "${repo_url}" release > /dev/null; then
114+ git -c http.https://github.com/.extraheader="${auth_header}" clone --depth 1 --branch release "${repo_url}" "${release_dir}"
115+ else
116+ git init -b release "${release_dir}"
117+ git -C "${release_dir}" remote add origin "${repo_url}"
118+ fi
119+
120+ rsync -a --delete --exclude='.git' backend/dist/ "${release_dir}/"
121+
122+ cd "${release_dir}"
105123 git config --local user.name "github-actions[bot]"
106124 git config --local user.email "github-actions[bot]@users.noreply.github.com"
107- git checkout -b release
108- git add .
125+ git add -A
126+ if git diff --cached --quiet; then
127+ echo "No release asset changes to push."
128+ exit 0
129+ fi
109130 git commit -m "release: ${{ steps.tag.outputs.release_tag }}"
110- git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
111- git push -f -u origin release
131+ git -c http.https://github.com/.extraheader="${auth_header}" push origin release
112132 # - name: Sync to GitLab
113133 # env:
114134 # GITLAB_PIPELINE_TOKEN: ${{ secrets.GITLAB_PIPELINE_TOKEN }}
0 commit comments