npm publish workflow (cytoscape/cytoscape.js)
The npm publish workflow from cytoscape/cytoscape.js, explained and optimized by Latchkey.
CI health: A - excellent
Point runs-on at Latchkey and get caching, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the npm publish workflow from the cytoscape/cytoscape.js 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: npm publish
permissions:
contents: read # Required for OIDC
id-token: write # Required for OIDC
on:
workflow_call:
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 5
environment: prod
steps:
- uses: actions/checkout@v6
with:
ref: master
- uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
package-manager-cache: false # never use caching in release builds
registry-url: 'https://registry.npmjs.org'
- name: Publish Package To npmjs
run: npm 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: npm publish permissions: contents: read # Required for OIDC id-token: write # Required for OIDC on: workflow_call: workflow_dispatch: jobs: publish: runs-on: latchkey-small timeout-minutes: 5 environment: prod steps: - uses: actions/checkout@v6 with: ref: master - uses: actions/setup-node@v6 with: cache: 'npm' node-version-file: .nvmrc package-manager-cache: false # never use caching in release builds registry-url: 'https://registry.npmjs.org' - name: Publish Package To npmjs run: npm 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. - Cache dependency installs on the setup step so they are served from cache.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.