Release workflow (TanStack/query)
The Release workflow from TanStack/query, 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 Release workflow from the TanStack/query 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: Release
on:
push:
branches: [main, 'v[0-9]', '*-pre', '*-maint']
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
permissions:
contents: read
jobs:
release:
name: Release
if: github.repository_owner == 'TanStack'
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: true # changesets/action pushes version/release changes
- name: Setup Tools
uses: TanStack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3
- name: Run Build
run: pnpm run build:all
- name: Determine dist-tag
id: dist-tag
run: |
BRANCH="${GITHUB_REF_NAME}"
if [[ "$BRANCH" == *-pre ]]; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
elif [[ "$BRANCH" == *-maint ]]; then
echo "tag=maint" >> "$GITHUB_OUTPUT"
elif [[ "$BRANCH" =~ ^v[0-9]+$ ]]; then
echo "tag=$BRANCH" >> "$GITHUB_OUTPUT"
else
echo "latest=true" >> "$GITHUB_OUTPUT"
fi
- name: Create Release Pull Request or Publish
id: changesets
uses: changesets/action@63a615b9cd06ba9a3e6d13796c7fbcb080a60a0b # v1.8.0
with:
version: pnpm run changeset:version
publish: pnpm run changeset:publish ${{ steps.dist-tag.outputs.tag && format('--tag {0}', steps.dist-tag.outputs.tag) }}
title: 'ci: Version Packages'
commit: 'ci: changeset release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
if: steps.changesets.outputs.published == 'true'
run: node scripts/create-github-release.mjs ${PRERELEASE_FLAG} ${LATEST_FLAG}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PRERELEASE_FLAG: ${{ steps.dist-tag.outputs.prerelease == 'true' && '--prerelease' }}
LATEST_FLAG: ${{ steps.dist-tag.outputs.latest == 'true' && '--latest' }}
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Release on: push: branches: [main, 'v[0-9]', '*-pre', '*-maint'] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: false env: NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} permissions: contents: read jobs: release: timeout-minutes: 30 name: Release if: github.repository_owner == 'TanStack' runs-on: latchkey-small permissions: contents: write id-token: write pull-requests: write steps: - name: Checkout uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: fetch-depth: 0 persist-credentials: true # changesets/action pushes version/release changes - name: Setup Tools uses: TanStack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3 - name: Run Build run: pnpm run build:all - name: Determine dist-tag id: dist-tag run: | BRANCH="${GITHUB_REF_NAME}" if [[ "$BRANCH" == *-pre ]]; then echo "prerelease=true" >> "$GITHUB_OUTPUT" elif [[ "$BRANCH" == *-maint ]]; then echo "tag=maint" >> "$GITHUB_OUTPUT" elif [[ "$BRANCH" =~ ^v[0-9]+$ ]]; then echo "tag=$BRANCH" >> "$GITHUB_OUTPUT" else echo "latest=true" >> "$GITHUB_OUTPUT" fi - name: Create Release Pull Request or Publish id: changesets uses: changesets/action@63a615b9cd06ba9a3e6d13796c7fbcb080a60a0b # v1.8.0 with: version: pnpm run changeset:version publish: pnpm run changeset:publish ${{ steps.dist-tag.outputs.tag && format('--tag {0}', steps.dist-tag.outputs.tag) }} title: 'ci: Version Packages' commit: 'ci: changeset release' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create GitHub Release if: steps.changesets.outputs.published == 'true' run: node scripts/create-github-release.mjs ${PRERELEASE_FLAG} ${LATEST_FLAG} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PRERELEASE_FLAG: ${{ steps.dist-tag.outputs.prerelease == 'true' && '--prerelease' }} LATEST_FLAG: ${{ steps.dist-tag.outputs.latest == 'true' && '--latest' }}
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.