Prepare Release workflow (hikari-py/hikari)
The Prepare Release workflow from hikari-py/hikari, 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.
What it does
This is the Prepare Release workflow from the hikari-py/hikari 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: Prepare Release
on:
workflow_dispatch:
inputs:
version:
description: "The version to prepare the release for"
required: true
jobs:
prepare-release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Generate token
id: generate_token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
# We need to use a bot token to be able to trigger workflows that listen to pull_request calls
token: ${{ steps.generate_token.outputs.token }}
- name: Setup git config
run: |
git config --global user.name "hikari-bot"
git config --global user.email "90276125+hikari-bot[bot]@users.noreply.github.com"
- name: Setup uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
python-version: 3.14
activate-environment: true
- name: Run prepare script
env:
VERSION: ${{ inputs.version }}
run: bash scripts/ci/prepare-release.sh
- name: Create pull request
env:
VERSION: ${{ inputs.version }}
AUTHOR: ${{ github.event.sender.login }}
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
title="Prepare for release of ${VERSION}"
body="Release preparation triggered by @${AUTHOR}.
Once the pull request is merged, you can trigger a PyPI release by creating a GitHub release for \`${VERSION}\` in the repository."
gh pr create \
--title "${title}" \
--body "${body}" \
--assignee "${AUTHOR}"
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Prepare Release on: workflow_dispatch: inputs: version: description: "The version to prepare the release for" required: true jobs: prepare-release: timeout-minutes: 30 runs-on: latchkey-small if: github.ref == 'refs/heads/master' steps: - name: Generate token id: generate_token uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1 with: app-id: ${{ secrets.APP_ID }} private-key: ${{ secrets.PRIVATE_KEY }} - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: # We need to use a bot token to be able to trigger workflows that listen to pull_request calls token: ${{ steps.generate_token.outputs.token }} - name: Setup git config run: | git config --global user.name "hikari-bot" git config --global user.email "90276125+hikari-bot[bot]@users.noreply.github.com" - name: Setup uv uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 with: python-version: 3.14 activate-environment: true - name: Run prepare script env: VERSION: ${{ inputs.version }} run: bash scripts/ci/prepare-release.sh - name: Create pull request env: VERSION: ${{ inputs.version }} AUTHOR: ${{ github.event.sender.login }} GH_TOKEN: ${{ steps.generate_token.outputs.token }} run: | title="Prepare for release of ${VERSION}" body="Release preparation triggered by @${AUTHOR}. Once the pull request is merged, you can trigger a PyPI release by creating a GitHub release for \`${VERSION}\` in the repository." gh pr create \ --title "${title}" \ --body "${body}" \ --assignee "${AUTHOR}"
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.