@@ -133,35 +133,47 @@ jobs:
133133 new_version=$(grep '@version "' mix.exs | grep -o '"[0-9]\+\.[0-9]\+\.[0-9]\+"' | tr -d '"')
134134 echo "new_version=$new_version" >> "$GITHUB_OUTPUT"
135135
136- - name : Commit release changes
137- id : commit-release
138- env :
139- GITHUB_TOKEN : ${{ steps.releaser.outputs.token }}
140- NEW_VERSION : ${{ steps.sampo-release.outputs.new_version }}
136+ - name : Check for release changes
137+ id : check-changes
141138 run : |
142- git add -A
143- if git diff --staged --quiet; then
139+ if [ -z "$(git status --porcelain)" ]; then
144140 echo "No changes to commit"
145141 echo "committed=false" >> "$GITHUB_OUTPUT"
146142 else
147- git commit -m "chore: Release v${NEW_VERSION} [skip ci]"
148- git push origin main
149143 echo "committed=true" >> "$GITHUB_OUTPUT"
150144 fi
151145
146+ - name : Commit release changes
147+ id : commit-release
148+ if : steps.check-changes.outputs.committed == 'true'
149+ uses : planetscale/ghcommit-action@25309d8005ac7c3bcd61d3fe19b69e0fe47dbdde # v0.2.20
150+ with :
151+ commit_message : " chore: Release v${{ steps.sampo-release.outputs.new_version }} [skip ci]"
152+ repo : ${{ github.repository }}
153+ branch : main
154+ env :
155+ GITHUB_TOKEN : ${{ steps.releaser.outputs.token }}
156+
157+ - name : Sync checkout to release commit
158+ if : steps.commit-release.outputs.commit-hash != ''
159+ env :
160+ COMMIT_HASH : ${{ steps.commit-release.outputs.commit-hash }}
161+ run : |
162+ git fetch origin main
163+ git reset --hard "$COMMIT_HASH"
152164 - name : Publish with Sampo
153- if : steps.commit-release.outputs.committed == 'true '
165+ if : steps.commit-release.outputs.commit-hash != ' '
154166 env :
155167 GITHUB_TOKEN : ${{ steps.releaser.outputs.token }}
156168 HEX_API_KEY : ${{ secrets.HEX_API_KEY }}
157169 run : sampo publish -- --yes
158170
159171 - name : Push tags
160- if : steps.commit-release.outputs.committed == 'true '
172+ if : steps.commit-release.outputs.commit-hash != ' '
161173 run : git push origin --tags
162174
163175 - name : Create GitHub Release
164- if : steps.commit-release.outputs.committed == 'true '
176+ if : steps.commit-release.outputs.commit-hash != ' '
165177 env :
166178 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
167179 NEW_VERSION : ${{ steps.sampo-release.outputs.new_version }}
0 commit comments