diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5c0524c8..c51b3c07 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -271,3 +271,36 @@ jobs: parse_mode: "Markdown", disable_web_page_preview: true }')" + + sync-version-file: + needs: [release] + if: ${{ needs.release.result == 'success' }} + runs-on: ubuntu-latest + steps: + - name: Checkout default branch + uses: actions/checkout@v6 + with: + ref: ${{ github.event.repository.default_branch }} + + - name: Sync VERSION file to released tag + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + VERSION=${{ github.event.inputs.tag }} + VERSION=${VERSION#v} + else + VERSION=${GITHUB_REF#refs/tags/v} + fi + + CURRENT_VERSION=$(tr -d '\r\n' < backend/cmd/server/VERSION || true) + if [ "$CURRENT_VERSION" = "$VERSION" ]; then + echo "VERSION file already matches $VERSION" + exit 0 + fi + + echo "$VERSION" > backend/cmd/server/VERSION + + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add backend/cmd/server/VERSION + git commit -m "chore: sync VERSION to ${VERSION} [skip ci]" + git push origin HEAD:${{ github.event.repository.default_branch }}