Skip to content

Release Tag

Release Tag #40

Workflow file for this run

name: Release Tag
on:
workflow_dispatch:
inputs:
release_type:
description: "Semantic version bump to apply before tagging"
required: true
type: choice
default: patch
options:
- patch
- minor
- major
release_notes:
description: "Release notes for the GitHub release"
required: false
default: ""
jobs:
bump:
runs-on: ubuntu-latest
if: github.actor == 'siliconlad'
permissions: write-all
steps:
- uses: actions/checkout@v4
with:
ref: "main"
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: latest
- name: Configure git
run: |
git config user.name "siliconlad"
git config user.email "siliconlad@protonmail.com"
shell: bash
- name: New Branch
run: |
git checkout -b bot/version-bump
shell: bash
- name: Prepare version
id: version
shell: bash
run: |
set -euo pipefail
uv version --bump ${{ inputs.release_type }}
echo "version=$(uv version --short)" >> "$GITHUB_OUTPUT"
echo "tag=v$(uv version --short)" >> "$GITHUB_OUTPUT"
- name: Commit and push version bump
shell: bash
env:
VERSION: ${{ steps.version.outputs.version }}
TAG: ${{ steps.version.outputs.tag }}
run: |
set -euo pipefail
if git diff --quiet; then
echo "No changes detected after version update."
exit 1
fi
git commit -am "chore: release $VERSION"
git push -f -u origin bot/version-bump
- name: Create PR
env:
VERSION: ${{ steps.version.outputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create --title "Version Bump" --body "Bump version to $VERSION" --base main --label version
shell: bash
- name: Merge PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pr_number=$(gh pr list --state open --limit 1 --label version --json number --jq '.[0].number')
gh pr merge $pr_number --merge --delete-branch --admin
shell: bash
release:
runs-on: ubuntu-latest
if: github.actor == 'siliconlad'
needs: [bump]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: "main" # Checkout main branch with updated commit
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: latest
- name: Get version
id: version
shell: bash
run: |
set -euo pipefail
echo "version=$(uv version --short)" >> "$GITHUB_OUTPUT"
echo "tag=v$(uv version --short)" >> "$GITHUB_OUTPUT"
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
target_commitish: main
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.tag }}
body: ${{ inputs.release_notes }}
generate_release_notes: true
make_latest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
runs-on: ubuntu-latest
if: github.actor == 'siliconlad'
needs: [release]
environment: pypi
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: "main" # Checkout main branch with updated commit
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: Get version
id: version
shell: bash
run: |
set -euo pipefail
echo "version=$(uv version --short)" >> "$GITHUB_OUTPUT"
echo "tag=v$(uv version --short)" >> "$GITHUB_OUTPUT"
- name: Build package
run: uv build --no-sources
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*
tag_name: ${{ steps.version.outputs.tag }}
- name: Publish to PyPI
run: uv publish