Skip to content

Self / Retag

Self / Retag #3

Workflow file for this run

name: Self / Retag
on:
workflow_dispatch:
inputs:
major:
description: 'Major digit to move (e.g. 2). Writes annotated tag v<major> at origin/main.'
required: true
type: string
permissions:
contents: read
concurrency:
group: qntx-workflows-self-retag-${{ github.repository }}-${{ github.ref }}
cancel-in-progress: false
jobs:
retag:
runs-on: ubuntu-latest
timeout-minutes: 10
environment: retag
permissions:
contents: write
steps:
- uses: $/actions/hardened-checkout
with:
fetch-depth: 0
persist-credentials: true
- name: Configure git identity
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Move major tag
shell: bash
env:
MAJOR: ${{ inputs.major }}
run: |
set -euo pipefail
if ! [[ "$MAJOR" =~ ^[0-9]+$ ]]; then
echo "::error::major must match ^[0-9]+$ (got ${MAJOR})"
exit 1
fi
# Dispatch ref is not origin/main. Do not peel HEAD.
git fetch origin main --tags --force
if ! git rev-parse --verify origin/main >/dev/null; then
echo "::error::origin/main is missing after fetch"
exit 1
fi
main_sha="$(git rev-parse origin/main)"
git tag -f -a "v${MAJOR}" -m "track origin/main" "$main_sha"
git push -f origin "v${MAJOR}"
peeled="$(git rev-parse "v${MAJOR}^{commit}")"
{
echo "origin/main=${main_sha}"
echo "v${MAJOR}^{commit}=${peeled}"
} | tee -a "$GITHUB_STEP_SUMMARY"