Skip to content
Latchkey

Release package workflow (thlorenz/doctoc)

The Release package workflow from thlorenz/doctoc, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: thlorenz/doctoc.github/workflows/release.ymlLicense MITView source

What it does

This is the Release package workflow from the thlorenz/doctoc 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)
# config borrowed from: https://docs.npmjs.com/trusted-publishers#github-actions-configuration
name: Release package

on:
  push:
    tags:
      - "v*.*.*"

permissions:
  id-token: write # Required for OIDC
  contents: write
  issues: write # Required for raising issues

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Use Node.js 24.x
        uses: actions/setup-node@v6
        with:
          node-version: 24.x
          cache: "npm"

      # This explicitly sets the version of the npm package to match that of the tag.
      - run: npm version ${{ github.ref_name }} --no-git-tag-version

      - run: npm install

      - run: npm test

      # note if locally preparing packages you will need to explicitly set the version in package.json,
      # see for discussion https://github.com/thlorenz/doctoc/pull/289#discussion_r2649551681 for more details.
      - run: npm pack

      - name: NPM Publish
        id: publish
        run: npm publish
        continue-on-error: true

      - name: Create issue on npm publish failure
        if: ${{ steps.publish.outcome == 'failure' }}
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          gh issue create \
            --title "NPM Publish step failed for release ${GITHUB_REF_NAME}" \
            --body "The NPM publish step failed for release: ${GITHUB_REF_NAME}. The npm package will need to be manually uploaded to NPM." \
            --assignee AndrewSouthpaw

      - name: Release
        uses: softprops/action-gh-release@v2
        with:
          generate_release_notes: true
          files: |
            ./doctoc-*.tgz

The same workflow, on Latchkey

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

# config borrowed from: https://docs.npmjs.com/trusted-publishers#github-actions-configuration
name: Release package
 
on:
  push:
    tags:
      - "v*.*.*"
 
permissions:
  id-token: write # Required for OIDC
  contents: write
  issues: write # Required for raising issues
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - name: Checkout
        uses: actions/checkout@v6
 
      - name: Use Node.js 24.x
        uses: actions/setup-node@v6
        with:
          node-version: 24.x
          cache: "npm"
 
      # This explicitly sets the version of the npm package to match that of the tag.
      - run: npm version ${{ github.ref_name }} --no-git-tag-version
 
      - run: npm install
 
      - run: npm test
 
      # note if locally preparing packages you will need to explicitly set the version in package.json,
      # see for discussion https://github.com/thlorenz/doctoc/pull/289#discussion_r2649551681 for more details.
      - run: npm pack
 
      - name: NPM Publish
        id: publish
        run: npm publish
        continue-on-error: true
 
      - name: Create issue on npm publish failure
        if: ${{ steps.publish.outcome == 'failure' }}
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          gh issue create \
            --title "NPM Publish step failed for release ${GITHUB_REF_NAME}" \
            --body "The NPM publish step failed for release: ${GITHUB_REF_NAME}. The npm package will need to be manually uploaded to NPM." \
            --assignee AndrewSouthpaw
 
      - name: Release
        uses: softprops/action-gh-release@v2
        with:
          generate_release_notes: true
          files: |
            ./doctoc-*.tgz
 

What changed

1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

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