Skip to content

docs(holdout): document the shipped system honestly; remove vestigial split (#259) #228

docs(holdout): document the shipped system honestly; remove vestigial split (#259)

docs(holdout): document the shipped system honestly; remove vestigial split (#259) #228

Workflow file for this run

name: Auto Semver Tag
on:
pull_request:
types: [closed]
branches: [main]
concurrency:
group: auto-tag
cancel-in-progress: false
jobs:
auto-tag:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
checks: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Parse semver labels
id: check
env:
LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }}
run: |
SEMVER_LABELS=$(echo "$LABELS" | jq -r '.[] | select(startswith("semver:"))' | grep -v '^semver:skip$' || true)
SKIP=$(echo "$LABELS" | jq -r '.[] | select(. == "semver:skip")' || true)
if [ -n "$SKIP" ]; then
echo "semver:skip label found — skipping release"
echo "skipped=true" >> "$GITHUB_OUTPUT"
exit 0
fi
COUNT=$(echo "$SEMVER_LABELS" | grep -c . || true)
if [ "$COUNT" -eq 0 ]; then
echo "No semver label found — skipping release"
echo "skipped=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ "$COUNT" -gt 1 ]; then
echo "::error::Multiple semver labels found: $(echo $SEMVER_LABELS | tr '\n' ', '). Use exactly one."
exit 1
fi
BUMP="${SEMVER_LABELS#semver:}"
echo "bump=$BUMP" >> "$GITHUB_OUTPUT"
echo "skipped=false" >> "$GITHUB_OUTPUT"
echo "Bump type: $BUMP"
- name: Verify CI checks passed
if: steps.check.outputs.skipped != 'true'
env:
GH_TOKEN: ${{ github.token }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
echo "Verifying CI status for PR head commit: $HEAD_SHA"
RUNS=$(gh api "repos/${{ github.repository }}/commits/${HEAD_SHA}/check-runs" \
--paginate --jq '.check_runs[] | select(.name != "auto-tag") | {name: .name, status: .status, conclusion: .conclusion}')
if [ -z "$RUNS" ]; then
echo "::error::No CI check runs found for commit $HEAD_SHA — refusing to tag"
exit 1
fi
echo "Check runs:"
echo "$RUNS" | jq -s '.'
INCOMPLETE=$(echo "$RUNS" | jq -s '[.[] | select(.status != "completed")] | length')
if [ "$INCOMPLETE" -gt 0 ]; then
echo "::error::${INCOMPLETE} check(s) still running — refusing to tag"
echo "$RUNS" | jq -s '[.[] | select(.status != "completed")]'
exit 1
fi
FAILED=$(echo "$RUNS" | jq -s '[.[] | select(.conclusion != "success" and .conclusion != "skipped" and .conclusion != "neutral")] | length')
if [ "$FAILED" -gt 0 ]; then
echo "::error::${FAILED} check(s) did not pass — refusing to tag"
echo "$RUNS" | jq -s '[.[] | select(.conclusion != "success" and .conclusion != "skipped" and .conclusion != "neutral")]'
exit 1
fi
echo "All CI checks passed ✓"
- name: Compute next version
if: steps.check.outputs.skipped != 'true'
id: bump
env:
BUMP: ${{ steps.check.outputs.bump }}
run: |
LATEST=$(git tag --list 'v*.*.*' --sort=-v:refname | head -n 1)
if [ -z "$LATEST" ]; then
LATEST="v0.0.0"
echo "No existing tags found — starting from v0.0.0"
fi
echo "Latest tag: $LATEST"
VERSION="${LATEST#v}"
MAJOR="${VERSION%%.*}"
REST="${VERSION#*.}"
MINOR="${REST%%.*}"
PATCH="${REST#*.}"
case "$BUMP" in
major)
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
minor)
MINOR=$((MINOR + 1))
PATCH=0
;;
patch)
PATCH=$((PATCH + 1))
;;
*)
echo "::error::Unknown bump type: $BUMP"
exit 1
;;
esac
NEW_TAG="v${MAJOR}.${MINOR}.${PATCH}"
echo "tag=$NEW_TAG" >> "$GITHUB_OUTPUT"
echo "New tag: $NEW_TAG"
- name: Create and push tag
if: steps.check.outputs.skipped != 'true'
env:
NEW_TAG: ${{ steps.bump.outputs.tag }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
MSG=$(printf 'Release %s (PR #%s: %s)' "$NEW_TAG" "$PR_NUMBER" "$PR_TITLE")
git tag -a "$NEW_TAG" -m "$MSG"
git push origin "$NEW_TAG"
- name: Create GitHub Release
if: steps.check.outputs.skipped != 'true'
env:
NEW_TAG: ${{ steps.bump.outputs.tag }}
GH_TOKEN: ${{ github.token }}
run: |
VERSION="${NEW_TAG#v}"
gh release create "$NEW_TAG" --generate-notes --title "v$VERSION"