Bump Release Version workflow (kiali/kiali)
The Bump Release Version workflow from kiali/kiali, 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 Bump Release Version workflow from the kiali/kiali 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: Bump Release Version
on:
workflow_dispatch:
inputs:
tag_branches:
description: Branches to bump version (Separate branches by commas)
required: true
default: v2.4,v2.11,v2.17,v2.22
type: string
workflow_call:
inputs:
tag_branches:
description: Branches to bump version (Separate branches by commas)
required: true
default: v2.4,v2.11,v2.17,v2.22
type: string
jobs:
initialize:
permissions:
contents: read
name: Initialize
runs-on: ubuntu-latest
outputs:
branches: ${{ env.branches }}
steps:
- name: Prepare script to var
id: script_convert
run: |
cat <<-EOF > conversor.py
import sys, json
branch_arg = sys.argv[1]
branches = branch_arg.split(',')
print(json.dumps(branches))
EOF
- name: Set Branch
id: branches
env:
TAG_BRANCHES: ${{ github.event.inputs.tag_branches }}
run: |
BRANCHES=$(python conversor.py $TAG_BRANCHES)
echo "branches=$BRANCHES" >> $GITHUB_ENV
bump_version:
permissions:
contents: write
needs: [initialize]
runs-on: ubuntu-latest
strategy:
# Allow other branches to continue even if one of the branches failed
fail-fast: false
matrix:
branch: ${{fromJson(needs.initialize.outputs.branches)}}
steps:
- name: Checkout branch
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{matrix.branch}}
token: ${{ secrets.KIALI_BOT_TOKEN }}
# We need to fetch the full history to determine the latest tag
fetch-depth: 0
- name: Prepare scripts
run: |
cat <<-EOF > bump.py
import sys
release_type = sys.argv[1]
version = sys.argv[2]
parts = version.split('.')
major = int(parts[0][1:])
minor = int(parts[1])
patch = int(parts[2])
if release_type == 'major':
major = major + 1
minor = 0
patch = 0
elif release_type == 'minor':
minor = minor + 1
patch = 0
elif release_type == 'patch':
patch = patch + 1
print('.'.join(['v' + str(major), str(minor), str(patch)]))
EOF
- name: Configure git
run: |
git config user.email 'kiali-dev@googlegroups.com'
git config user.name 'kiali-bot'
- name: Bump to next version
env:
BRANCH: ${{matrix.branch}}
run: |
RAW_VERSION=$(sed -rn 's/^VERSION \?= (.*)/\1/p' Makefile)
LATEST_TAG=$(git describe --tags --abbrev=0)
# Check if the latest tag is the current release version tag
if [[ "$LATEST_TAG" == "$RAW_VERSION" ]]; then
RELEASE_VERSION=$(python bump.py patch $RAW_VERSION)
# Update the version in Kiali repository
sed -i -r "s/^VERSION \?= (.*)/VERSION \?= $RELEASE_VERSION/" Makefile
sed -i -r 's/"version": (.*)/"version": "'${RELEASE_VERSION:1}'",/' frontend/package.json
# Commit the changes
git add Makefile frontend/package.json
git commit -m "Bump to version $RELEASE_VERSION"
git push origin $(git rev-parse HEAD):refs/heads/$BRANCH
# Create the ossm version tag
git push origin $(git rev-parse HEAD):refs/tags/$RELEASE_VERSION-ossm
else
echo "Error: Latest tag $LATEST_TAG does not match expected $RAW_VERSION tag"
exit 1
fi
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Bump Release Version on: workflow_dispatch: inputs: tag_branches: description: Branches to bump version (Separate branches by commas) required: true default: v2.4,v2.11,v2.17,v2.22 type: string workflow_call: inputs: tag_branches: description: Branches to bump version (Separate branches by commas) required: true default: v2.4,v2.11,v2.17,v2.22 type: string jobs: initialize: timeout-minutes: 30 permissions: contents: read name: Initialize runs-on: latchkey-small outputs: branches: ${{ env.branches }} steps: - name: Prepare script to var id: script_convert run: | cat <<-EOF > conversor.py import sys, json branch_arg = sys.argv[1] branches = branch_arg.split(',') print(json.dumps(branches)) EOF - name: Set Branch id: branches env: TAG_BRANCHES: ${{ github.event.inputs.tag_branches }} run: | BRANCHES=$(python conversor.py $TAG_BRANCHES) echo "branches=$BRANCHES" >> $GITHUB_ENV bump_version: timeout-minutes: 30 permissions: contents: write needs: [initialize] runs-on: latchkey-small strategy: # Allow other branches to continue even if one of the branches failed fail-fast: false matrix: branch: ${{fromJson(needs.initialize.outputs.branches)}} steps: - name: Checkout branch uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: ref: ${{matrix.branch}} token: ${{ secrets.KIALI_BOT_TOKEN }} # We need to fetch the full history to determine the latest tag fetch-depth: 0 - name: Prepare scripts run: | cat <<-EOF > bump.py import sys release_type = sys.argv[1] version = sys.argv[2] parts = version.split('.') major = int(parts[0][1:]) minor = int(parts[1]) patch = int(parts[2]) if release_type == 'major': major = major + 1 minor = 0 patch = 0 elif release_type == 'minor': minor = minor + 1 patch = 0 elif release_type == 'patch': patch = patch + 1 print('.'.join(['v' + str(major), str(minor), str(patch)])) EOF - name: Configure git run: | git config user.email 'kiali-dev@googlegroups.com' git config user.name 'kiali-bot' - name: Bump to next version env: BRANCH: ${{matrix.branch}} run: | RAW_VERSION=$(sed -rn 's/^VERSION \?= (.*)/\1/p' Makefile) LATEST_TAG=$(git describe --tags --abbrev=0) # Check if the latest tag is the current release version tag if [[ "$LATEST_TAG" == "$RAW_VERSION" ]]; then RELEASE_VERSION=$(python bump.py patch $RAW_VERSION) # Update the version in Kiali repository sed -i -r "s/^VERSION \?= (.*)/VERSION \?= $RELEASE_VERSION/" Makefile sed -i -r 's/"version": (.*)/"version": "'${RELEASE_VERSION:1}'",/' frontend/package.json # Commit the changes git add Makefile frontend/package.json git commit -m "Bump to version $RELEASE_VERSION" git push origin $(git rev-parse HEAD):refs/heads/$BRANCH # Create the ossm version tag git push origin $(git rev-parse HEAD):refs/tags/$RELEASE_VERSION-ossm else echo "Error: Latest tag $LATEST_TAG does not match expected $RAW_VERSION tag" exit 1 fi
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 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.