Skip to content
Latchkey

Prepare Release workflow (auth0/node-jsonwebtoken)

The Prepare Release workflow from auth0/node-jsonwebtoken, explained and optimized by Latchkey.

C

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.

Grade your own workflow free or run it on Latchkey →
Source: auth0/node-jsonwebtoken.github/workflows/prepare-release.ymlLicense MITView source

What it does

This is the Prepare Release workflow from the auth0/node-jsonwebtoken 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

workflow (.yml)
name: Prepare Release

on:
  push:
    branches:
      - master

concurrency:
  group: prepare-release
  cancel-in-progress: true

permissions:
  contents: write
  pull-requests: write

jobs:
  prepare:
    runs-on: ubuntu-latest
    if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
    steps:
      - name: Checkout code
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          fetch-depth: 0
          persist-credentials: false

      - name: Setup Node.js
        uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
        with:
          node-version: '24'

      - name: Install dependencies
        run: npm install

      - name: Detect Next Version
        id: version
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          # Run semantic-release with dry-run to detect version
          set -o pipefail
          if ! OUTPUT=$(npx semantic-release --dry-run --verify-conditions false --verify-release false 2>&1); then
            echo "$OUTPUT"
            echo "::error::semantic-release failed during version detection"
            exit 1
          fi
          echo "$OUTPUT"
          NEXT_VERSION=$(echo "$OUTPUT" | awk '/The next release version is/{print $NF}')
          echo "next=$NEXT_VERSION" >> $GITHUB_OUTPUT

      - name: Update package.json
        if: steps.version.outputs.next != ''
        run: npm version "$NEXT_VERSION" --no-git-tag-version
        env:
          NEXT_VERSION: ${{ steps.version.outputs.next }}

      - name: Update CHANGELOG.md
        if: steps.version.outputs.next != ''
        run: npm run update-changelog

      - name: Create Pull Request
        if: steps.version.outputs.next != ''
        uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          commit-message: "chore(release): ${{ steps.version.outputs.next }}"
          branch: "release/v${{ steps.version.outputs.next }}"
          delete-branch: true
          title: "chore(release): ${{ steps.version.outputs.next }}"
          body: |
            This PR prepares the release of version ${{ steps.version.outputs.next }}.

            **Changes:**
            - Updated version in `package.json` to ${{ steps.version.outputs.next }}
            - Updated `CHANGELOG.md` with release notes

            **Next Steps:**
            Review and merge this PR to trigger the publish workflow.
          labels: release

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: Prepare Release
 
on:
  push:
    branches:
      - master
 
concurrency:
  group: prepare-release
  cancel-in-progress: true
 
permissions:
  contents: write
  pull-requests: write
 
jobs:
  prepare:
    timeout-minutes: 30
    runs-on: latchkey-small
    if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
    steps:
      - name: Checkout code
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          fetch-depth: 0
          persist-credentials: false
 
      - name: Setup Node.js
        uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
        with:
          cache: 'npm'
          node-version: '24'
 
      - name: Install dependencies
        run: npm install
 
      - name: Detect Next Version
        id: version
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          # Run semantic-release with dry-run to detect version
          set -o pipefail
          if ! OUTPUT=$(npx semantic-release --dry-run --verify-conditions false --verify-release false 2>&1); then
            echo "$OUTPUT"
            echo "::error::semantic-release failed during version detection"
            exit 1
          fi
          echo "$OUTPUT"
          NEXT_VERSION=$(echo "$OUTPUT" | awk '/The next release version is/{print $NF}')
          echo "next=$NEXT_VERSION" >> $GITHUB_OUTPUT
 
      - name: Update package.json
        if: steps.version.outputs.next != ''
        run: npm version "$NEXT_VERSION" --no-git-tag-version
        env:
          NEXT_VERSION: ${{ steps.version.outputs.next }}
 
      - name: Update CHANGELOG.md
        if: steps.version.outputs.next != ''
        run: npm run update-changelog
 
      - name: Create Pull Request
        if: steps.version.outputs.next != ''
        uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          commit-message: "chore(release): ${{ steps.version.outputs.next }}"
          branch: "release/v${{ steps.version.outputs.next }}"
          delete-branch: true
          title: "chore(release): ${{ steps.version.outputs.next }}"
          body: |
            This PR prepares the release of version ${{ steps.version.outputs.next }}.
 
            **Changes:**
            - Updated version in `package.json` to ${{ steps.version.outputs.next }}
            - Updated `CHANGELOG.md` with release notes
 
            **Next Steps:**
            Review and merge this PR to trigger the publish workflow.
          labels: release
 

What changed

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:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow