Skip to content
Latchkey

Create Draft Release workflow (tiangolo/sqlmodel)

The Create Draft Release workflow from tiangolo/sqlmodel, explained and optimized by Latchkey.

C

CI health: C - fair

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

Grade your own workflow free or run it on Latchkey →
Source: tiangolo/sqlmodel.github/workflows/create-draft-release.ymlLicense MITView source

What it does

This is the Create Draft Release workflow from the tiangolo/sqlmodel 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: Create Draft Release

on:
  pull_request:
    types:
      - closed

permissions: {}

jobs:
  create-draft-release:
    if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')
    runs-on: ubuntu-latest
    timeout-minutes: 5
    permissions:
      contents: write
    env:
      PREPARE_RELEASE_VERSION_FILE: sqlmodel/__init__.py
      PREPARE_RELEASE_RELEASE_NOTES_FILE: docs/release-notes.md
    steps:
      - name: Dump GitHub context
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: echo "$GITHUB_CONTEXT"
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          ref: ${{ github.event.repository.default_branch }}
          persist-credentials: true
      - name: Set up Python
        uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
        with:
          python-version-file: ".python-version"
      - name: Install uv
        uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
        with:
          # Before upgrading uv version, make sure astral-sh/setup-uv knows its checksum.
          # See: https://github.com/astral-sh/setup-uv/issues/851#issuecomment-4282017837
          version: "0.11.18"
      - name: Extract release details
        id: release-details
        run: |
          set -euo pipefail
          version="$(uv run python scripts/prepare_release.py current-version)"
          uv run python scripts/prepare_release.py release-notes > draft-release-notes.md
          echo "version=$version" >> "$GITHUB_OUTPUT"
      - name: Create draft release
        env:
          GH_TOKEN: ${{ github.token }}
          VERSION: ${{ steps.release-details.outputs.version }}
        run: |
          set -euo pipefail
          gh release create "$VERSION" \
            --draft \
            --title "$VERSION" \
            --notes-file draft-release-notes.md \
            --target "$(git rev-parse HEAD)"

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 Draft Release
 
on:
  pull_request:
    types:
      - closed
 
permissions: {}
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  create-draft-release:
    if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')
    runs-on: latchkey-small
    timeout-minutes: 5
    permissions:
      contents: write
    env:
      PREPARE_RELEASE_VERSION_FILE: sqlmodel/__init__.py
      PREPARE_RELEASE_RELEASE_NOTES_FILE: docs/release-notes.md
    steps:
      - name: Dump GitHub context
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: echo "$GITHUB_CONTEXT"
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          ref: ${{ github.event.repository.default_branch }}
          persist-credentials: true
      - name: Set up Python
        uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
        with:
          cache: 'pip'
          python-version-file: ".python-version"
      - name: Install uv
        uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
        with:
          # Before upgrading uv version, make sure astral-sh/setup-uv knows its checksum.
          # See: https://github.com/astral-sh/setup-uv/issues/851#issuecomment-4282017837
          version: "0.11.18"
      - name: Extract release details
        id: release-details
        run: |
          set -euo pipefail
          version="$(uv run python scripts/prepare_release.py current-version)"
          uv run python scripts/prepare_release.py release-notes > draft-release-notes.md
          echo "version=$version" >> "$GITHUB_OUTPUT"
      - name: Create draft release
        env:
          GH_TOKEN: ${{ github.token }}
          VERSION: ${{ steps.release-details.outputs.version }}
        run: |
          set -euo pipefail
          gh release create "$VERSION" \
            --draft \
            --title "$VERSION" \
            --notes-file draft-release-notes.md \
            --target "$(git rev-parse HEAD)"
 

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