Skip to content
Latchkey

Package Deployment workflow (select2/select2)

The Package Deployment workflow from select2/select2, 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: select2/select2.github/workflows/package-deploy.ymlLicense MITView source

What it does

This is the Package Deployment workflow from the select2/select2 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: Package Deployment
on:
  push:
    branches:
      - develop
      - master
  release: ~
jobs:
  deploy_github:
    name: GitHub Package Registry
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - name: Use Node.js 24
        uses: actions/setup-node@v6
        with:
          node-version: 24
          registry-url: https://npm.pkg.github.com/
          scope: '@select2'
      - name: Rename package to include private scope
        run: "sed -i -e 's#\"name\": \"select2\"#\"name\": \"@select2/select2\"#' package.json"
      - name: npm install
        run: npm install
      - name: Run linting, tests, minify
        run: grunt
      - name: Deploy (release)
        if: github.event_name == 'release'
        run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
      - name: Deploy (release candidate)
        if: github.event_name == 'push'
        run: 'sed -i -E "s/\"version\": \"(.+)\",/\"version\": \"\1-commit-$GITHUB_SHA\",/" package.json && npm publish --tag next'
        env:
          NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
          GITHUB_SHA: ${{github.sha}}
  deploy_npm:
    name: NPM
    if: github.event_name == 'release'
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write
    steps:
      - uses: actions/checkout@v7
      - name: Use Node.js 24
        uses: actions/setup-node@v6
        with:
          node-version: 24
          registry-url: 'https://registry.npmjs.org'
      - name: npm install
        run: npm install
      - name: Run linting, tests, minify
        run: grunt
      - name: Deploy (release)
        run: npm publish --provenance --access public

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: Package Deployment
on:
  push:
    branches:
      - develop
      - master
  release: ~
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  deploy_github:
    timeout-minutes: 30
    name: GitHub Package Registry
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v7
      - name: Use Node.js 24
        uses: actions/setup-node@v6
        with:
          cache: 'npm'
          node-version: 24
          registry-url: https://npm.pkg.github.com/
          scope: '@select2'
      - name: Rename package to include private scope
        run: "sed -i -e 's#\"name\": \"select2\"#\"name\": \"@select2/select2\"#' package.json"
      - name: npm install
        run: npm install
      - name: Run linting, tests, minify
        run: grunt
      - name: Deploy (release)
        if: github.event_name == 'release'
        run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
      - name: Deploy (release candidate)
        if: github.event_name == 'push'
        run: 'sed -i -E "s/\"version\": \"(.+)\",/\"version\": \"\1-commit-$GITHUB_SHA\",/" package.json && npm publish --tag next'
        env:
          NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
          GITHUB_SHA: ${{github.sha}}
  deploy_npm:
    timeout-minutes: 30
    name: NPM
    if: github.event_name == 'release'
    runs-on: latchkey-small
    permissions:
      contents: read
      id-token: write
    steps:
      - uses: actions/checkout@v7
      - name: Use Node.js 24
        uses: actions/setup-node@v6
        with:
          cache: 'npm'
          node-version: 24
          registry-url: 'https://registry.npmjs.org'
      - name: npm install
        run: npm install
      - name: Run linting, tests, minify
        run: grunt
      - name: Deploy (release)
        run: npm publish --provenance --access public
 

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 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow