Skip to content
Latchkey

Create Github release workflow (fal-ai/fal)

The Create Github release workflow from fal-ai/fal, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get caching, 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: fal-ai/fal.github/workflows/create-release.yamlLicense Apache-2.0View source

What it does

This is the Create Github release workflow from the fal-ai/fal 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: Create Github release

on:
  workflow_dispatch:
    inputs:
      project_name:
        description: Project name
        required: true
        type: choice
        options:
          - fal
          - fal_client
          - isolate_proto
      bump_version:
        description: Version
        required: false
        default: patch
        type: choice
        options:
          - patch
          - minor
          - major

jobs:
  create_release:
    runs-on: ubuntu-latest
    environment:
      name: create-github-release
    steps:
      - name: Mint GitHub App token
        id: app_token
        uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2.2.2
        with:
          app-id: ${{ secrets.REGEN_APP_ID }}
          private-key: ${{ secrets.REGEN_APP_PRIVATE_KEY }}
          owner: fal-ai
          repositories: fal

      - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
        with:
          fetch-depth: 0
          token: ${{ steps.app_token.outputs.token }}

      - uses: actions/setup-python@e9aba2c848f5ebd159c070c61ea2c4e2b122355e # v2.3.4
        with:
          python-version: "3.9"

      - name: Create Github release
        env:
          PROJECT_NAME: ${{ github.event.inputs.project_name }}
          BUMP_VERSION: ${{ github.event.inputs.bump_version }}
          GH_TOKEN: ${{ steps.app_token.outputs.token }}
        run: |
          set -xeo pipefail
          last_tag=$(git describe --tags --abbrev=0 --match "${PROJECT_NAME}_v*")
          regex="^${PROJECT_NAME}_v([0-9]*).([0-9]*).([0-9]*)$"
          [[ $last_tag =~ $regex ]] || $(echo "failed to parse last tag '$last_tag'" && exit 1)
          major=${BASH_REMATCH[1]}
          minor=${BASH_REMATCH[2]}
          patch=${BASH_REMATCH[3]}
          if [ $BUMP_VERSION == "major" ]; then version="$((major + 1)).0.0"; fi
          if [ $BUMP_VERSION == "minor" ]; then version="$major.$((minor + 1)).0"; fi
          if [ $BUMP_VERSION == "patch" ]; then version="$major.$minor.$((patch + 1))"; fi
          git log $last_tag...HEAD --pretty=format:'*  %s' --reverse -- projects/$PROJECT_NAME/ > /tmp/notes.txt
          gh release create ${PROJECT_NAME}_v$version --title ${PROJECT_NAME}_v$version --notes-file /tmp/notes.txt

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: Create Github release
 
on:
  workflow_dispatch:
    inputs:
      project_name:
        description: Project name
        required: true
        type: choice
        options:
          - fal
          - fal_client
          - isolate_proto
      bump_version:
        description: Version
        required: false
        default: patch
        type: choice
        options:
          - patch
          - minor
          - major
 
jobs:
  create_release:
    timeout-minutes: 30
    runs-on: latchkey-small
    environment:
      name: create-github-release
    steps:
      - name: Mint GitHub App token
        id: app_token
        uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2.2.2
        with:
          app-id: ${{ secrets.REGEN_APP_ID }}
          private-key: ${{ secrets.REGEN_APP_PRIVATE_KEY }}
          owner: fal-ai
          repositories: fal
 
      - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
        with:
          fetch-depth: 0
          token: ${{ steps.app_token.outputs.token }}
 
      - uses: actions/setup-python@e9aba2c848f5ebd159c070c61ea2c4e2b122355e # v2.3.4
        with:
          cache: 'pip'
          python-version: "3.9"
 
      - name: Create Github release
        env:
          PROJECT_NAME: ${{ github.event.inputs.project_name }}
          BUMP_VERSION: ${{ github.event.inputs.bump_version }}
          GH_TOKEN: ${{ steps.app_token.outputs.token }}
        run: |
          set -xeo pipefail
          last_tag=$(git describe --tags --abbrev=0 --match "${PROJECT_NAME}_v*")
          regex="^${PROJECT_NAME}_v([0-9]*).([0-9]*).([0-9]*)$"
          [[ $last_tag =~ $regex ]] || $(echo "failed to parse last tag '$last_tag'" && exit 1)
          major=${BASH_REMATCH[1]}
          minor=${BASH_REMATCH[2]}
          patch=${BASH_REMATCH[3]}
          if [ $BUMP_VERSION == "major" ]; then version="$((major + 1)).0.0"; fi
          if [ $BUMP_VERSION == "minor" ]; then version="$major.$((minor + 1)).0"; fi
          if [ $BUMP_VERSION == "patch" ]; then version="$major.$minor.$((patch + 1))"; fi
          git log $last_tag...HEAD --pretty=format:'*  %s' --reverse -- projects/$PROJECT_NAME/ > /tmp/notes.txt
          gh release create ${PROJECT_NAME}_v$version --title ${PROJECT_NAME}_v$version --notes-file /tmp/notes.txt
 

What changed

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