Skip to content
Latchkey

Publish workflow (evanw/esbuild)

The Publish workflow from evanw/esbuild, explained and optimized by Latchkey.

D

CI health: D - needs work

Point runs-on at Latchkey and get caching, run de-duplication, 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: evanw/esbuild.github/workflows/publish.ymlLicense MITView source

What it does

This is the Publish workflow from the evanw/esbuild 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: Publish

permissions:
  id-token: write
  contents: write

on:
  push:
    branches:
      - main
    paths:
      - version.txt

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Read version info
        run: |
          echo "GO_VERSION=$(cat go.version)" >> $GITHUB_ENV
          echo "ESBUILD_VERSION=$(cat version.txt)" >> $GITHUB_ENV

      # This is here to fail quickly if the release already exists
      - name: Try to create the "v${{ env.ESBUILD_VERSION }}" tag
        run: |
          git fetch --tags
          git tag "v$ESBUILD_VERSION"

      - name: Extract the release notes
        run: |
          CHANGELOG=$(awk -v "ver=$ESBUILD_VERSION" '/^## / { if (p) { exit }; if ($2 == ver) { p=1; next} } p' CHANGELOG.md)
          echo "CHANGELOG<<EOF" >> $GITHUB_ENV
          echo "$CHANGELOG" >> $GITHUB_ENV
          echo "EOF" >> $GITHUB_ENV

      # Make sure we'll be able to generate release notes later on below
      - name: Release notes must not be empty
        run: |
          test -n "$CHANGELOG"

      - name: Set up Go ${{ env.GO_VERSION }}
        uses: actions/setup-go@v3
        with:
          go-version: ${{ env.GO_VERSION }}

      - name: Setup Node.js environment
        uses: actions/setup-node@v3
        with:
          node-version: 24

      # This updates the version in all "package.json" files
      - name: Build for all platforms
        run: |
          make platform-all

      # All "package.json" files should have been updated already by running "make platform-all" and committing the results
      - name: Reject uncommitted/untracked changes
        run: |
          git status --porcelain
          test -z "$(git status --porcelain)"

      # Trusted publishing requires this specific version of npm
      - name: Install npm
        run: |
          npm install -g npm@11.5.1

      - name: Publish packages
        run: |
          make publish-all

      - name: Push the tag to GitHub
        run: |
          git push origin tag "v$ESBUILD_VERSION"

      # Only do this after publishing was successful
      - name: Create a GitHub Release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: v${{ env.ESBUILD_VERSION }}
          release_name: v${{ env.ESBUILD_VERSION }}
          body: ${{ env.CHANGELOG }}
          draft: false
          prerelease: false

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: Publish
 
permissions:
  id-token: write
  contents: write
 
on:
  push:
    branches:
      - main
    paths:
      - version.txt
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  publish:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
 
      - name: Read version info
        run: |
          echo "GO_VERSION=$(cat go.version)" >> $GITHUB_ENV
          echo "ESBUILD_VERSION=$(cat version.txt)" >> $GITHUB_ENV
 
      # This is here to fail quickly if the release already exists
      - name: Try to create the "v${{ env.ESBUILD_VERSION }}" tag
        run: |
          git fetch --tags
          git tag "v$ESBUILD_VERSION"
 
      - name: Extract the release notes
        run: |
          CHANGELOG=$(awk -v "ver=$ESBUILD_VERSION" '/^## / { if (p) { exit }; if ($2 == ver) { p=1; next} } p' CHANGELOG.md)
          echo "CHANGELOG<<EOF" >> $GITHUB_ENV
          echo "$CHANGELOG" >> $GITHUB_ENV
          echo "EOF" >> $GITHUB_ENV
 
      # Make sure we'll be able to generate release notes later on below
      - name: Release notes must not be empty
        run: |
          test -n "$CHANGELOG"
 
      - name: Set up Go ${{ env.GO_VERSION }}
        uses: actions/setup-go@v3
        with:
          go-version: ${{ env.GO_VERSION }}
 
      - name: Setup Node.js environment
        uses: actions/setup-node@v3
        with:
          cache: 'npm'
          node-version: 24
 
      # This updates the version in all "package.json" files
      - name: Build for all platforms
        run: |
          make platform-all
 
      # All "package.json" files should have been updated already by running "make platform-all" and committing the results
      - name: Reject uncommitted/untracked changes
        run: |
          git status --porcelain
          test -z "$(git status --porcelain)"
 
      # Trusted publishing requires this specific version of npm
      - name: Install npm
        run: |
          npm install -g npm@11.5.1
 
      - name: Publish packages
        run: |
          make publish-all
 
      - name: Push the tag to GitHub
        run: |
          git push origin tag "v$ESBUILD_VERSION"
 
      # Only do this after publishing was successful
      - name: Create a GitHub Release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: v${{ env.ESBUILD_VERSION }}
          release_name: v${{ env.ESBUILD_VERSION }}
          body: ${{ env.CHANGELOG }}
          draft: false
          prerelease: false
 

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