Skip to content
Latchkey

Publish Dist workflow (plotly/plotly.js)

The Publish Dist workflow from plotly/plotly.js, 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: plotly/plotly.js.github/workflows/publish-dist.ymlLicense MITView source

What it does

This is the Publish Dist workflow from the plotly/plotly.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

workflow (.yml)
name: Publish Dist

on:
  push:
    branches: [master]
  pull_request:
    types:
      - opened
      - reopened
      - synchronize
  workflow_dispatch:

concurrency:
  group: publish-dist-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  publish-dist:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
        with:
          fetch-depth: 0
          fetch-tags: true

      - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
        with:
          node-version: '22.14.0'
          cache: 'npm'

      - name: Set up build environment
        run: .github/scripts/env_build.sh

      - name: Set draft version in package.json
        run: |
          node --eval "var fs = require('fs'); var inOut = './package.json'; var data = JSON.parse(fs.readFileSync(inOut)); var a = process.argv; data.version = a[a.length - 1].replace('v', ''); fs.writeFileSync(inOut, JSON.stringify(data, null, 2) + '\n');" $(git describe)
          # View package.json diff from last release (should show that the version has been changed to the draft version)
          git --no-pager diff --color-words tags/$(git describe --tags --abbrev=0) package.json || true

      - name: Build dist/
        run: npm run build

      - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
        name: Upload archive of plotly.js build artifacts (contents of dist/)
        with:
          name: dist
          retention-days: 7
          path: dist/

      - name: Test plot-schema.json diff
        run: diff --unified --color dist/plot-schema.json test/plot-schema.json

The same workflow, on Latchkey

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

name: Publish Dist
 
on:
  push:
    branches: [master]
  pull_request:
    types:
      - opened
      - reopened
      - synchronize
  workflow_dispatch:
 
concurrency:
  group: publish-dist-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true
 
jobs:
  publish-dist:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
        with:
          fetch-depth: 0
          fetch-tags: true
 
      - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
        with:
          node-version: '22.14.0'
          cache: 'npm'
 
      - name: Set up build environment
        run: .github/scripts/env_build.sh
 
      - name: Set draft version in package.json
        run: |
          node --eval "var fs = require('fs'); var inOut = './package.json'; var data = JSON.parse(fs.readFileSync(inOut)); var a = process.argv; data.version = a[a.length - 1].replace('v', ''); fs.writeFileSync(inOut, JSON.stringify(data, null, 2) + '\n');" $(git describe)
          # View package.json diff from last release (should show that the version has been changed to the draft version)
          git --no-pager diff --color-words tags/$(git describe --tags --abbrev=0) package.json || true
 
      - name: Build dist/
        run: npm run build
 
      - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
        name: Upload archive of plotly.js build artifacts (contents of dist/)
        with:
          name: dist
          retention-days: 7
          path: dist/
 
      - name: Test plot-schema.json diff
        run: diff --unified --color dist/plot-schema.json test/plot-schema.json
 

What changed

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