Skip to content

Promote Version Tag #16

Promote Version Tag

Promote Version Tag #16

Workflow file for this run

name: Promote Version Tag
on:
workflow_dispatch:
inputs:
major_tag:
description: "Major version tag to update (e.g. v0, v1)"
required: true
type: choice
options:
- v0
- v1
release_tag:
description: "Full semver tag to point to (e.g. v0.1.3)"
required: true
type: string
jobs:
promote:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate semver format
run: |
SEMVER_REGEX="^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$"
if [[ "${{ inputs.release_tag }}" =~ $SEMVER_REGEX ]]; then
echo "Valid semver: ${{ inputs.release_tag }}"
else
echo "::error::Invalid semver format: ${{ inputs.release_tag }} (expected vX.Y.Z)"
exit 1
fi
- name: Verify release tag exists
run: |
if ! git rev-parse "refs/tags/${{ inputs.release_tag }}" >/dev/null 2>&1; then
echo "::error::Tag '${{ inputs.release_tag }}' does not exist"
exit 1
fi
- name: Verify major version matches
run: |
TAG_MAJOR=$(echo "${{ inputs.release_tag }}" | grep -oP '^v\K[0-9]+')
EXPECTED_MAJOR=$(echo "${{ inputs.major_tag }}" | grep -oP '^v\K[0-9]+')
if [ "$TAG_MAJOR" != "$EXPECTED_MAJOR" ]; then
echo "::error::Tag ${{ inputs.release_tag }} (major=$TAG_MAJOR) does not match ${{ inputs.major_tag }} (major=$EXPECTED_MAJOR)"
exit 1
fi
- name: Move ${{ inputs.major_tag }} tag to ${{ inputs.release_tag }}
run: |
git tag -f ${{ inputs.major_tag }} ${{ inputs.release_tag }}
git push origin ${{ inputs.major_tag }} --force
echo "### Promoted \`${{ inputs.major_tag }}\` -> \`${{ inputs.release_tag }}\`" >> "$GITHUB_STEP_SUMMARY"