Release workflow (lint-staged/lint-staged)
The Release workflow from lint-staged/lint-staged, explained and optimized by Latchkey.
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.
What it does
This is the Release workflow from the lint-staged/lint-staged 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:
push:
branches:
- main
# Do not run on tags
tags-ignore:
- '*'
permissions:
contents: write
issues: read
packages: write
pull-requests: write
id-token: write
jobs:
npm:
uses: ./.github/workflows/npm.yml
Changesets:
needs: npm
runs-on: ubuntu-latest
outputs:
publish: ${{ steps.changesets.outputs.published == 'true' }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # https://github.com/actions/checkout/releases/tag/v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # https://github.com/actions/setup-node/releases/tag/v6.4.0
with:
node-version-file: .node-version
package-manager-cache: false
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # https://github.com/actions/cache/releases/tag/v5.0.5
id: cache-node_modules
with:
path: node_modules
key: node-modules-ubuntu-latest-${{ hashFiles('package-lock.json') }}
- name: Configure Git user
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git config tag.forceSignAnnotated true
- name: Changesets
id: changesets
uses: changesets/action@6a0a831ff30acef54f2c6aa1cbbc1096b066edaf # https://github.com/changesets/action/releases/tag/v1.7.0
with:
title: '🦋 Changeset release'
version: npm run version
publish: npm run tag
setupGitUser: false
createGithubReleases: true
commitMode: github-api # Sign commits and tags
commit: 'chore(changeset): release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HUSKY: '0' # disabled because pre-push hook checks for changesets which have now been removed
Publish:
name: Publish to npm
runs-on: ubuntu-latest
needs: Changesets
if: needs.Changesets.outputs.publish == 'true'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # https://github.com/actions/checkout/releases/tag/v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # https://github.com/actions/setup-node/releases/tag/v6.4.0
with:
node-version-file: .node-version
registry-url: https://registry.npmjs.org
package-manager-cache: false
- run: npm install --global npm # TODO: remove after Node.js bundles at least 11.15.0
- run: npm stage publish
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: push: branches: - main # Do not run on tags tags-ignore: - '*' permissions: contents: write issues: read packages: write pull-requests: write id-token: write concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: npm: timeout-minutes: 30 uses: ./.github/workflows/npm.yml Changesets: timeout-minutes: 30 needs: npm runs-on: latchkey-small outputs: publish: ${{ steps.changesets.outputs.published == 'true' }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # https://github.com/actions/checkout/releases/tag/v6.0.2 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # https://github.com/actions/setup-node/releases/tag/v6.4.0 with: cache: 'npm' node-version-file: .node-version package-manager-cache: false - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # https://github.com/actions/cache/releases/tag/v5.0.5 id: cache-node_modules with: path: node_modules key: node-modules-ubuntu-latest-${{ hashFiles('package-lock.json') }} - name: Configure Git user run: | git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" git config tag.forceSignAnnotated true - name: Changesets id: changesets uses: changesets/action@6a0a831ff30acef54f2c6aa1cbbc1096b066edaf # https://github.com/changesets/action/releases/tag/v1.7.0 with: title: '🦋 Changeset release' version: npm run version publish: npm run tag setupGitUser: false createGithubReleases: true commitMode: github-api # Sign commits and tags commit: 'chore(changeset): release' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} HUSKY: '0' # disabled because pre-push hook checks for changesets which have now been removed Publish: timeout-minutes: 30 name: Publish to npm runs-on: latchkey-small needs: Changesets if: needs.Changesets.outputs.publish == 'true' steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # https://github.com/actions/checkout/releases/tag/v6.0.2 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # https://github.com/actions/setup-node/releases/tag/v6.4.0 with: cache: 'npm' node-version-file: .node-version registry-url: https://registry.npmjs.org package-manager-cache: false - run: npm install --global npm # TODO: remove after Node.js bundles at least 11.15.0 - run: npm stage publish
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. - Cancel superseded runs when a branch or PR gets a newer push.
- 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 3 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.