Skip to content

Commit 4c9562a

Browse files
authored
Merge pull request Wei-Shaw#1148 from weak-fox/ci/sync-version-file-after-release
ci: sync VERSION file back to default branch after release
2 parents 71942fd + 3070635 commit 4c9562a

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,36 @@ jobs:
271271
parse_mode: "Markdown",
272272
disable_web_page_preview: true
273273
}')"
274+
275+
sync-version-file:
276+
needs: [release]
277+
if: ${{ needs.release.result == 'success' }}
278+
runs-on: ubuntu-latest
279+
steps:
280+
- name: Checkout default branch
281+
uses: actions/checkout@v6
282+
with:
283+
ref: ${{ github.event.repository.default_branch }}
284+
285+
- name: Sync VERSION file to released tag
286+
run: |
287+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
288+
VERSION=${{ github.event.inputs.tag }}
289+
VERSION=${VERSION#v}
290+
else
291+
VERSION=${GITHUB_REF#refs/tags/v}
292+
fi
293+
294+
CURRENT_VERSION=$(tr -d '\r\n' < backend/cmd/server/VERSION || true)
295+
if [ "$CURRENT_VERSION" = "$VERSION" ]; then
296+
echo "VERSION file already matches $VERSION"
297+
exit 0
298+
fi
299+
300+
echo "$VERSION" > backend/cmd/server/VERSION
301+
302+
git config user.name "github-actions[bot]"
303+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
304+
git add backend/cmd/server/VERSION
305+
git commit -m "chore: sync VERSION to ${VERSION} [skip ci]"
306+
git push origin HEAD:${{ github.event.repository.default_branch }}

0 commit comments

Comments
 (0)