mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-06 08:06:50 +00:00
fix(release): require the tagged commit to carry the release VERSION
The sync-version-file job committed the VERSION bump to main only after publishing, so every tag pointed at a commit whose VERSION was the previous release (v0.2.19 through v0.2.26). Published artifacts were unaffected because prepare rewrites VERSION from the tag, but source builds of a tag (go build, GitHub source archives, Docker builds without .git) reported the old version. prepare now fails before building or publishing when VERSION at the tag does not match the tag version. A manual run with allow_version_mismatch=true downgrades this to a warning for re-releasing older tags. The post-release sync job is removed: the VERSION bump is committed before tagging instead.
This commit is contained in:
1 parent
ce3a27912e
commit
ec0e489ab7
4 files changed
+39
-34
No files matched your search
@@ -20,6 +20,11 @@ on:
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
allow_version_mismatch:
|
||||
description: 'Re-release an older tag whose committed VERSION predates the tag (builds with the tag version)'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
concurrency:
|
||||
group: release-${{ github.repository }}
|
||||
@@ -64,10 +69,14 @@ jobs:
|
||||
id: plan
|
||||
env:
|
||||
REQUESTED_REF: ${{ inputs.tag || github.ref_name }}
|
||||
ALLOW_VERSION_MISMATCH: ${{ github.event_name == 'workflow_dispatch' && inputs.allow_version_mismatch == true }}
|
||||
run: |
|
||||
args=(--ref "$REQUESTED_REF")
|
||||
if [[ "$SIMPLE_RELEASE" == true ]]; then args+=(--simple); fi
|
||||
if [[ "$DRY_RUN" == true ]]; then args+=(--dry-run); fi
|
||||
# The tagged commit must already carry the release VERSION. Only an explicit
|
||||
# manual re-release of an older tag may bypass this.
|
||||
if [[ "$ALLOW_VERSION_MISMATCH" == true ]]; then args+=(--allow-version-mismatch); fi
|
||||
python "$RUNNER_TEMP/release-tools/release_matrix.py" plan "${args[@]}"
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
@@ -374,35 +383,3 @@ jobs:
|
||||
parse_mode: "Markdown",
|
||||
disable_web_page_preview: true
|
||||
}')"
|
||||
|
||||
sync-version-file:
|
||||
needs: [prepare, release]
|
||||
if: ${{ needs.release.result == 'success' && needs.prepare.outputs.dry_run != 'true' }}
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
env:
|
||||
RELEASE_VERSION: ${{ needs.prepare.outputs.version }}
|
||||
steps:
|
||||
- name: Checkout default branch
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ github.event.repository.default_branch }}
|
||||
|
||||
- name: Sync VERSION file to released tag
|
||||
run: |
|
||||
VERSION="$RELEASE_VERSION"
|
||||
|
||||
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 }}
|
||||
Reference in new issue
Block a user