Skip to content
Latchkey

draft-release.yml workflow (olton/metroui)

The draft-release.yml workflow from olton/metroui, explained and optimized by Latchkey.

F

CI health: F - at risk

Point runs-on at Latchkey and get caching, 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: olton/metroui.github/workflows/draft-release.ymlLicense MITView source

What it does

This is the draft-release.yml workflow from the olton/metroui 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: draft-release.yml
on:
  push:
    branches:
      - master
jobs:
  releaseDraft:
    name: Release draft
    if: github.event_name != 'pull_request'
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      # Check out the current repository
      - name: Fetch Sources
        uses: actions/checkout@v4
        with:
          ref: master

      - uses: actions/setup-node@v4
        with:
          node-version: 22

      - name: Install dependencies
        run: npm install

      - name: Build
        run: npm run build

      - name: Get Version
        id: get-version
        uses: beaconbrigade/package-json-version@v0.3.2
        with:
          path: .

      - name: Read CHANGELOG.md
        id: changelog
        uses: jaywcjlove/github-action-read-file@main
        with:
          path: CHANGELOG.md

      # Remove old release drafts by using the curl request for the available releases with a draft flag
      - name: Remove Old Release Drafts
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          gh api repos/{owner}/{repo}/releases \
            --jq '.[] | select(.draft == true) | .id' \
            | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}

      # Create a new release draft which is not publicly visible and requires manual acceptance
      - name: Create Release Draft
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          gh release create "v${{ steps.get-version.outputs.version }}" \
            --draft \
            --title "v${{ steps.get-version.outputs.version }}" \
            --notes "$(cat << 'EOM'
          ${{ steps.changelog.outputs.content }}
          EOM
          )"

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: draft-release.yml
on:
  push:
    branches:
      - master
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  releaseDraft:
    timeout-minutes: 30
    name: Release draft
    if: github.event_name != 'pull_request'
    runs-on: latchkey-small
    permissions:
      contents: write
    steps:
      # Check out the current repository
      - name: Fetch Sources
        uses: actions/checkout@v4
        with:
          ref: master
 
      - uses: actions/setup-node@v4
        with:
          cache: 'npm'
          node-version: 22
 
      - name: Install dependencies
        run: npm install
 
      - name: Build
        run: npm run build
 
      - name: Get Version
        id: get-version
        uses: beaconbrigade/package-json-version@v0.3.2
        with:
          path: .
 
      - name: Read CHANGELOG.md
        id: changelog
        uses: jaywcjlove/github-action-read-file@main
        with:
          path: CHANGELOG.md
 
      # Remove old release drafts by using the curl request for the available releases with a draft flag
      - name: Remove Old Release Drafts
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          gh api repos/{owner}/{repo}/releases \
            --jq '.[] | select(.draft == true) | .id' \
            | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
 
      # Create a new release draft which is not publicly visible and requires manual acceptance
      - name: Create Release Draft
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          gh release create "v${{ steps.get-version.outputs.version }}" \
            --draft \
            --title "v${{ steps.get-version.outputs.version }}" \
            --notes "$(cat << 'EOM'
          ${{ steps.changelog.outputs.content }}
          EOM
          )"

What changed

2 third-party actions are referenced by a movable tag. Pin them 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