Skip to content
Latchkey

Publish workflow (github/relative-time-element)

The Publish workflow from github/relative-time-element, 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: github/relative-time-element.github/workflows/publish.ymlLicense MITView source

What it does

This is the Publish workflow from the github/relative-time-element 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

on:
  release:
    types: [created]

jobs:
  publish-npm:
    name: Publish to npm
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          registry-url: https://registry.npmjs.org/
          cache: npm
      - run: npm install -g npm@latest
      - run: npm ci
      - run: npx playwright install --with-deps chromium
      - run: npm test
      - run: npm version ${TAG_NAME} --git-tag-version=false
        env:
          TAG_NAME: ${{ github.event.release.tag_name }}
      - run: npm --ignore-scripts publish --provenance --access public
  publish-github:
    name: Publish to GitHub Packages
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
      id-token: write
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          registry-url: https://npm.pkg.github.com
          cache: npm
          scope: '@github'
      - run: npm ci
      - run: npx playwright install --with-deps chromium
      - run: npm test
      - run: npm version ${TAG_NAME} --git-tag-version=false
        env:
          TAG_NAME: ${{ github.event.release.tag_name }}
      - run: npm --ignore-scripts publish --provenance --access public
        env:
          NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The same workflow, on Latchkey

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

name: Publish
 
on:
  release:
    types: [created]
 
jobs:
  publish-npm:
    timeout-minutes: 30
    name: Publish to npm
    runs-on: latchkey-small
    permissions:
      contents: read
      id-token: write
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          registry-url: https://registry.npmjs.org/
          cache: npm
      - run: npm install -g npm@latest
      - run: npm ci
      - run: npx playwright install --with-deps chromium
      - run: npm test
      - run: npm version ${TAG_NAME} --git-tag-version=false
        env:
          TAG_NAME: ${{ github.event.release.tag_name }}
      - run: npm --ignore-scripts publish --provenance --access public
  publish-github:
    timeout-minutes: 30
    name: Publish to GitHub Packages
    runs-on: latchkey-small
    permissions:
      contents: read
      packages: write
      id-token: write
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          registry-url: https://npm.pkg.github.com
          cache: npm
          scope: '@github'
      - run: npm ci
      - run: npx playwright install --with-deps chromium
      - run: npm test
      - run: npm version ${TAG_NAME} --git-tag-version=false
        env:
          TAG_NAME: ${{ github.event.release.tag_name }}
      - run: npm --ignore-scripts publish --provenance --access public
        env:
          NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 

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