Skip to content
Latchkey

Release workflow (clappr/clappr)

The Release workflow from clappr/clappr, explained and optimized by Latchkey.

A

CI health: A - excellent

Point runs-on at Latchkey and get 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: clappr/clappr.github/workflows/release.ymlLicense BSD-3-ClauseView source

What it does

This is the Release workflow from the clappr/clappr repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Release

on:
  workflow_run:
    workflows: ['CI']
    branches: [main]
    types:
      - completed

jobs:
  release:
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    permissions:
      contents: write
      id-token: write

    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Configure git
        run: |
          git config user.name github-actions[bot]
          git config user.email 41898282+github-actions[bot]@users.noreply.github.com

      - name: Use Node.js
        uses: actions/setup-node@v6
        with:
          node-version: '18.x'
          registry-url: https://registry.npmjs.org
          cache: 'yarn'

      - name: Install dependencies
        run: yarn --frozen-lockfile

      - name: Check for changes
        id: check_changes
        run: |
          git fetch --tags
          set +e
          OUTPUT=$(lerna changed 2>&1)
          EXIT_CODE=$?
          set -e

          if echo "$OUTPUT" | grep -q "No changed packages found"; then
            echo "has_changes=false" >> $GITHUB_OUTPUT
            echo "No packages to publish"
          elif [ $EXIT_CODE -eq 0 ] && [ -n "$OUTPUT" ]; then
            echo "has_changes=true" >> $GITHUB_OUTPUT
            echo "Found packages to publish:"
            echo "$OUTPUT"
          elif [ $EXIT_CODE -eq 0 ] && [ -z "$OUTPUT" ]; then
            echo "has_changes=false" >> $GITHUB_OUTPUT
            echo "No packages to publish (empty output)"
          else
            echo "Error running lerna changed (exit code: $EXIT_CODE):"
            echo "$OUTPUT"
            exit 1
          fi

      - name: Release packages
        id: release
        if: steps.check_changes.outputs.has_changes == 'true'
        run: yarn release
        continue-on-error: true

      - name: Publish from git tags
        if: steps.check_changes.outputs.has_changes == 'true' && steps.release.outcome == 'failure'
        run: lerna publish from-git --yes

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Release
 
on:
  workflow_run:
    workflows: ['CI']
    branches: [main]
    types:
      - completed
 
jobs:
  release:
    timeout-minutes: 30
    runs-on: latchkey-small
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    permissions:
      contents: write
      id-token: write
 
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          token: ${{ secrets.GITHUB_TOKEN }}
 
      - name: Configure git
        run: |
          git config user.name github-actions[bot]
          git config user.email 41898282+github-actions[bot]@users.noreply.github.com
 
      - name: Use Node.js
        uses: actions/setup-node@v6
        with:
          node-version: '18.x'
          registry-url: https://registry.npmjs.org
          cache: 'yarn'
 
      - name: Install dependencies
        run: yarn --frozen-lockfile
 
      - name: Check for changes
        id: check_changes
        run: |
          git fetch --tags
          set +e
          OUTPUT=$(lerna changed 2>&1)
          EXIT_CODE=$?
          set -e
 
          if echo "$OUTPUT" | grep -q "No changed packages found"; then
            echo "has_changes=false" >> $GITHUB_OUTPUT
            echo "No packages to publish"
          elif [ $EXIT_CODE -eq 0 ] && [ -n "$OUTPUT" ]; then
            echo "has_changes=true" >> $GITHUB_OUTPUT
            echo "Found packages to publish:"
            echo "$OUTPUT"
          elif [ $EXIT_CODE -eq 0 ] && [ -z "$OUTPUT" ]; then
            echo "has_changes=false" >> $GITHUB_OUTPUT
            echo "No packages to publish (empty output)"
          else
            echo "Error running lerna changed (exit code: $EXIT_CODE):"
            echo "$OUTPUT"
            exit 1
          fi
 
      - name: Release packages
        id: release
        if: steps.check_changes.outputs.has_changes == 'true'
        run: yarn release
        continue-on-error: true
 
      - name: Publish from git tags
        if: steps.check_changes.outputs.has_changes == 'true' && steps.release.outcome == 'failure'
        run: lerna publish from-git --yes
 

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