Skip to content
Latchkey

Release workflow (iterative/cml)

The Release workflow from iterative/cml, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get 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: iterative/cml.github/workflows/release.ymlLicense Apache-2.0View source

What it does

This is the Release workflow from the iterative/cml repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Release
on:
  workflow_dispatch:
    inputs:
      bump:
        type: choice
        required: true
        description: Bump version number
        options: [major, minor, patch]
        default: patch
  pull_request:
    types: [closed]
jobs:
  bump:
    if: github.event_name == 'workflow_dispatch'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - run: |
          git config --global user.name Olivaw[bot]
          git config --global user.email 64868532+iterative-olivaw@users.noreply.github.com
          git checkout -b bump/$(npm version ${{ github.event.inputs.bump }})
          git push --set-upstream origin HEAD
          gh pr create --title "Bump version to $(git describe --tags)" --body "Approve me 🤖"
          gh pr merge --auto --squash
        env:
          GITHUB_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
  release:
    if: github.event.pull_request.merged && startsWith(github.head_ref, 'bump/')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - run: >
          gh release create --target ${{
          github.event.pull_request.merge_commit_sha }} {--title=CML\
          ,}"$(basename "$GITHUB_HEAD_REF")" --generate-notes --draft
        env:
          GITHUB_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
  package:
    needs: release
    secrets: inherit
    uses: ./.github/workflows/test-deploy.yml
    with:
      release: true

The same workflow, on Latchkey

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

name: Release
on:
  workflow_dispatch:
    inputs:
      bump:
        type: choice
        required: true
        description: Bump version number
        options: [major, minor, patch]
        default: patch
  pull_request:
    types: [closed]
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  bump:
    timeout-minutes: 30
    if: github.event_name == 'workflow_dispatch'
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v3
      - run: |
          git config --global user.name Olivaw[bot]
          git config --global user.email 64868532+iterative-olivaw@users.noreply.github.com
          git checkout -b bump/$(npm version ${{ github.event.inputs.bump }})
          git push --set-upstream origin HEAD
          gh pr create --title "Bump version to $(git describe --tags)" --body "Approve me 🤖"
          gh pr merge --auto --squash
        env:
          GITHUB_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
  release:
    timeout-minutes: 30
    if: github.event.pull_request.merged && startsWith(github.head_ref, 'bump/')
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v3
      - run: >
          gh release create --target ${{
          github.event.pull_request.merge_commit_sha }} {--title=CML\
          ,}"$(basename "$GITHUB_HEAD_REF")" --generate-notes --draft
        env:
          GITHUB_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
  package:
    timeout-minutes: 30
    needs: release
    secrets: inherit
    uses: ./.github/workflows/test-deploy.yml
    with:
      release: true
 

What changed

This workflow runs 3 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