Release workflow (alpinejs/alpine)
The Release workflow from alpinejs/alpine, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get caching, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Release workflow from the alpinejs/alpine repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g. 3.15.12 or v3.15.12)'
required: true
type: string
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
release:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm install -g npm@latest
# ── Normalize version ──────────────────────────────────────────
- name: Normalize version
id: version
run: |
RAW="${{ github.event.inputs.version }}"
VERSION="${RAW#v}"
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid version format: $VERSION (expected X.Y.Z)"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
# ── Verify tag doesn't already exist ───────────────────────────
- name: Verify tag doesn't exist
run: |
if git ls-remote --tags origin | grep -q "refs/tags/${{ steps.version.outputs.tag }}$"; then
echo "::error::Tag ${{ steps.version.outputs.tag }} already exists"
exit 1
fi
# ── Install dependencies ───────────────────────────────────────
- run: npm ci
# ── Bump versions ──────────────────────────────────────────────
- name: Bump versions in all packages
run: node scripts/prep-release.js ${{ steps.version.outputs.version }}
# ── Commit and push version bumps ──────────────────────────────
- name: Commit version bumps
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "Bump version to ${{ steps.version.outputs.version }}"
git push
# ── Build ──────────────────────────────────────────────────────
- run: npm run build
# ── Create GitHub release ──────────────────────────────────────
- name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ steps.version.outputs.tag }}" \
--target main \
--title "${{ steps.version.outputs.tag }}" \
--generate-notes
# ── Publish all packages to npm ────────────────────────────────
- name: Publish all packages to npm
run: |
FAILED=""
for pkg in alpinejs csp intersect collapse persist resize anchor morph focus sort mask ui docs; do
echo "Publishing $pkg..."
cd packages/$pkg
if ! npm publish --access public --provenance 2>&1; then
echo "::warning::Failed to publish $pkg"
FAILED="$FAILED $pkg"
fi
cd ../..
done
if [ -n "$FAILED" ]; then
echo "::error::Failed to publish:$FAILED"
exit 1
fi
The same workflow, on Latchkey
Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.
name: Release on: workflow_dispatch: inputs: version: description: 'Version to release (e.g. 3.15.12 or v3.15.12)' required: true type: string env: FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true jobs: release: timeout-minutes: 30 runs-on: latchkey-small environment: release permissions: id-token: write contents: write steps: - uses: actions/checkout@v4 with: token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/setup-node@v4 with: cache: 'npm' node-version: '20' - run: npm install -g npm@latest # ── Normalize version ────────────────────────────────────────── - name: Normalize version id: version run: | RAW="${{ github.event.inputs.version }}" VERSION="${RAW#v}" if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "::error::Invalid version format: $VERSION (expected X.Y.Z)" exit 1 fi echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "tag=v$VERSION" >> "$GITHUB_OUTPUT" # ── Verify tag doesn't already exist ─────────────────────────── - name: Verify tag doesn't exist run: | if git ls-remote --tags origin | grep -q "refs/tags/${{ steps.version.outputs.tag }}$"; then echo "::error::Tag ${{ steps.version.outputs.tag }} already exists" exit 1 fi # ── Install dependencies ─────────────────────────────────────── - run: npm ci # ── Bump versions ────────────────────────────────────────────── - name: Bump versions in all packages run: node scripts/prep-release.js ${{ steps.version.outputs.version }} # ── Commit and push version bumps ────────────────────────────── - name: Commit version bumps run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add -A git commit -m "Bump version to ${{ steps.version.outputs.version }}" git push # ── Build ────────────────────────────────────────────────────── - run: npm run build # ── Create GitHub release ────────────────────────────────────── - name: Create GitHub release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh release create "${{ steps.version.outputs.tag }}" \ --target main \ --title "${{ steps.version.outputs.tag }}" \ --generate-notes # ── Publish all packages to npm ──────────────────────────────── - name: Publish all packages to npm run: | FAILED="" for pkg in alpinejs csp intersect collapse persist resize anchor morph focus sort mask ui docs; do echo "Publishing $pkg..." cd packages/$pkg if ! npm publish --access public --provenance 2>&1; then echo "::warning::Failed to publish $pkg" FAILED="$FAILED $pkg" fi cd ../.. done if [ -n "$FAILED" ]; then echo "::error::Failed to publish:$FAILED" exit 1 fi
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.