Skip to content

ci: [#1360] pin alpha base version via automated Release-As commits (… #1

ci: [#1360] pin alpha base version via automated Release-As commits (…

ci: [#1360] pin alpha base version via automated Release-As commits (… #1

Workflow file for this run

name: Pin Alpha Version
# During the pre-1.0 alpha phase, Floe pins the base version at 0.1.0 and only
# rolls the alpha counter. release-please does not do this automatically, so
# this workflow appends an empty `Release-As: 0.1.0-alpha.N+1` commit after
# every user-authored push to main, which release-please then reads as an
# override. When Floe graduates to stable, remove this workflow.
on:
push:
branches: [main]
permissions:
contents: write
jobs:
pin-alpha:
runs-on: ubuntu-latest
# Skip our own empty commits and any commit that already carries a
# Release-As footer (manual overrides, release-please release commits).
if: >-
github.actor != 'github-actions[bot]' &&
!contains(github.event.head_commit.message, 'Release-As:') &&
!startsWith(github.event.head_commit.message, 'chore(main): release')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Compute next alpha version
id: version
run: |
current=$(jq -r '."."' .github/release-please-manifest.json)
echo "current=$current" >> "$GITHUB_OUTPUT"
# Expect the form 0.1.0-alpha.N. If we're not on that line, bail loud.
if [[ ! "$current" =~ ^0\.1\.0-alpha\.([0-9]+)$ ]]; then
echo "::error::Manifest version '$current' is not on the 0.1.0-alpha.N line. Either alpha graduated (remove this workflow) or something bumped the base. Aborting."
exit 1
fi
n="${BASH_REMATCH[1]}"
next="0.1.0-alpha.$((n + 1))"
echo "next=$next" >> "$GITHUB_OUTPUT"
echo "Next alpha: $next"
- name: Append Release-As commit
env:
NEXT: ${{ steps.version.outputs.next }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Retry on race: another push may have landed between our checkout
# and push. Up to 5 tries with a rebase each time.
for attempt in 1 2 3 4 5; do
git fetch origin main
git reset --hard origin/main
# If someone else already pinned (e.g. a concurrent run beat us to
# it), the head commit will contain Release-As and we can exit.
head_msg=$(git log -1 --format=%B)
if grep -q "^Release-As:" <<<"$head_msg"; then
echo "Head already has Release-As footer, skipping."
exit 0
fi
git commit --allow-empty \
-m "chore: release as $NEXT" \
-m "Release-As: $NEXT"
if git push origin main; then
echo "Pushed pin for $NEXT (attempt $attempt)"
exit 0
fi
echo "Push failed on attempt $attempt, retrying..."
sleep 2
done
echo "::error::Failed to push Release-As commit after 5 attempts"
exit 1