ref:66017f96d16167506bf72b5fd4cc238aca556e5f

Fix CI release: branch detection and anvil CLI install (#7)

## Summary Fixes the release step which was skipping on main with "not on main (on HEAD)". ## Root causes 1. **Branch detection**: `git rev-parse --abbrev-ref HEAD` returns `"HEAD"` in CI because the runner checks out a detached HEAD at a specific commit SHA. Fixed by comparing `HEAD` SHA against `origin/main` SHA. 2. **anvil CLI not available**: Docker container doesn't have the anvil binary. Fixed by downloading it from `anvil.fangorn.io/cli/download`. 3. **Idempotency check**: `git tag -l` replaced with `git rev-parse` which is more reliable. ## Test plan - [x] 560 tests pass - [ ] Merge to main and verify release step creates tag + Anvil release
SHA: 66017f96d16167506bf72b5fd4cc238aca556e5f
Author: Anvil <noreply@anvil.fangorn.io>
Date: 2026-04-09 21:05
Parents: 32f9f47
1 files changed +13 -9
Type
.anvil.yml +13 −9
@@ -70,23 +70,31 @@
- name: release
run: |
set -e
apt-get update && apt-get install -y --no-install-recommends git jq
apt-get update && apt-get install -y --no-install-recommends git jq curl
git config --global --add safe.directory /workspace
export MIX_HOME=/workspace/.mix
# Only release from main branch
# CI checks out a detached HEAD so git branch name is always "HEAD".
# Compare the checked-out SHA against origin/main instead.
git fetch origin main 2>/dev/null || true
HEAD_SHA=$(git rev-parse HEAD)
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$BRANCH" != "main" ]; then
echo "Skipping release: not on main (on $BRANCH)"
MAIN_SHA=$(git rev-parse origin/main 2>/dev/null || echo "")
if [ "$HEAD_SHA" != "$MAIN_SHA" ]; then
echo "Skipping release: HEAD ($HEAD_SHA) != origin/main ($MAIN_SHA)"
exit 0
fi
# Install anvil CLI
curl -sL "https://anvil.fangorn.io/cli/download?os=$(uname -s)&arch=$(uname -m)" -o /usr/local/bin/anvil
chmod +x /usr/local/bin/anvil
# Compute CalVer version
VERSION=$(bash ci/release.sh)
echo "Releasing version: $VERSION"
# Idempotency: skip if this version tag already exists
if git rev-parse "$VERSION" >/dev/null 2>&1; then
if git tag -l "$VERSION" | grep -q .; then
echo "Tag $VERSION already exists, skipping release"
exit 0
fi
@@ -98,10 +106,6 @@
# Generate changelog from commits since last tag
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || git rev-list --max-parents=0 HEAD)
CHANGELOG=$(git log --oneline "$LAST_TAG"..HEAD)
# Generate hex package
mix hex.build
HEX_TAR=$(ls ex_git_objectstore-*.tar 2>/dev/null | head -1 || true)
# Generate docs
mix docs