Skip to content

Commit 8e458dc

Browse files
jmpalomaresAndreas Beuge
andauthored
fix: harden major-tag update (release: published) (#135)
* fix: trigger major-tag update on tag push instead of release published The release: published event is suppressed by GITHUB_TOKEN anti-recursion when a release is published by automation, which left v8 stuck on v8.3.7 after the v8.3.8 release (build-image.yaml@v8 then lacked the timeoutMinutes input, breaking kubernetes.yaml@v8.3.8 consumers). Trigger on the semver tag push instead (created only on publish, never on drafts), derive the version from the pushed ref, and add a workflow_dispatch recovery lever to realign the major tag manually. * fix: use glob tag filter and guard against tag deletions Address review feedback: - on.push.tags uses glob syntax, not regex; v[0-9]+.[0-9]+.[0-9]+ required a literal '+' and would never match v8.3.8. Use v[0-9]*.[0-9]*.[0-9]* and enforce the exact vX.Y.Z shape in the script (also skips pre-releases). - push fires on tag deletion too; add a job-level guard so it only runs on tag creation or manual dispatch. * chore: trim comments to incident-critical notes only * fix: harden release-published major-tag update Keep release: published (releases are created manually by a human, so the GITHUB_TOKEN suppression does not apply), but harden the weak parts: - take the version from github.event.release.tag_name instead of fragile git describe topology guessing - enforce strict vX.Y.Z semver and skip pre-releases - add workflow_dispatch recovery lever to realign the major tag by hand - idempotent git tag -f + force-push instead of delete-then-recreate * chore: add tag trigger to the pipeline --------- Co-authored-by: Andreas Beuge <andreasbeuge@abs-bmbp.fritz.box>
1 parent ab24c1c commit 8e458dc

1 file changed

Lines changed: 23 additions & 11 deletions

File tree

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
name: Update major tag
22
on:
3+
# `release: published` is suppressed when the release is published by the default GITHUB_TOKEN — publish releases as a human (or PAT), never via GITHUB_TOKEN, or v8 silently lags behind.
34
release:
45
types:
56
- published
7+
push:
8+
tags:
9+
- "v*.*.*"
10+
workflow_dispatch:
11+
inputs:
12+
tag:
13+
description: "Semver tag to align the major tag to (e.g. v8.3.8)"
14+
required: true
15+
16+
permissions:
17+
contents: write
618

719
jobs:
820
update-major-tag:
921
runs-on: ubuntu-latest
22+
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' || github.event.release.prerelease == false }}
1023
steps:
1124
- name: Checkout
1225
uses: actions/checkout@v6
@@ -15,22 +28,21 @@ jobs:
1528
- name: Extract major version
1629
id: version
1730
run: |
18-
# Get the latest tag created by the release job
19-
TAG_NAME="$(git describe --tags --abbrev=0)"
20-
echo "Retrieved tag: $TAG_NAME"
21-
# Extract major version (e.g., v8.2.7 -> v8)
31+
TAG_NAME="${{ github.event.inputs.tag || github.event.release.tag_name || github.ref_name }}"
32+
echo "Resolved tag: $TAG_NAME"
33+
if [[ ! "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
34+
echo "::notice::'$TAG_NAME' is not a release semver tag (vX.Y.Z); skipping major-tag update."
35+
echo "skip=true" >> "$GITHUB_OUTPUT"
36+
exit 0
37+
fi
2238
MAJOR_VERSION="$(echo "$TAG_NAME" | sed -E 's/^v([0-9]+)\..*/v\1/')"
2339
echo "major_version=$MAJOR_VERSION" >> "$GITHUB_OUTPUT"
2440
echo "full_version=$TAG_NAME" >> "$GITHUB_OUTPUT"
2541
- name: Update major version tag
42+
if: ${{ steps.version.outputs.skip != 'true' }}
2643
run: |
2744
git config user.name "parcellab-dev-bot"
2845
git config user.email "dev.bot@parcellab.com"
2946
30-
# Delete existing major version tag if it exists
31-
git tag -d "${{ steps.version.outputs.major_version }}" || true
32-
git push -d origin "${{ steps.version.outputs.major_version }}" || true
33-
34-
# Create new major version tag pointing to the same commit as the full version
35-
git tag "${{ steps.version.outputs.major_version }}"
36-
git push origin tag "${{ steps.version.outputs.major_version }}"
47+
git tag -f "${{ steps.version.outputs.major_version }}" "${{ steps.version.outputs.full_version }}"
48+
git push origin -f "refs/tags/${{ steps.version.outputs.major_version }}"

0 commit comments

Comments
 (0)