Skip to content

Prepare Release

Prepare Release #10

name: Prepare Release
concurrency:
group: prepare-release-${{ github.ref }}
cancel-in-progress: false
on:
workflow_dispatch:
inputs:
bump:
description: "Semantic version bump"
type: choice
options:
- patch
- minor
- major
default: patch
release:
description: "Manual release version (e.g. 1.2.3). Overrides bump."
type: string
required: false
default: ""
permissions:
contents: write
pull-requests: write
jobs:
prepare-release:
name: Prepare Release
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
steps:
- name: Checkout (Full History)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-edit
run: cargo install cargo-edit --locked
- name: Set Workspace Version (manual or bump)
shell: bash
run: |
set -euo pipefail
MANUAL_RELEASE="${{ inputs.release }}"
if [[ -n "${MANUAL_RELEASE}" ]]; then
# Validate SemVer (strict X.Y.Z numeric to align with repo conventions).
if [[ ! "${MANUAL_RELEASE}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Provided release '${MANUAL_RELEASE}' is not a valid SemVer (expected X.Y.Z)." >&2
exit 1
fi
echo "Setting workspace version to ${MANUAL_RELEASE} (manual)."
cargo set-version --workspace "${MANUAL_RELEASE}"
else
echo "Bumping workspace version by '${{ inputs.bump }}'."
cargo set-version --workspace --bump "${{ inputs.bump }}"
fi
- name: Read New Version
id: ver
shell: bash
run: |
set -euo pipefail
NEXT_VERSION=$(grep -m1 '^version = "' etl/Cargo.toml | sed -E 's/version = "([0-9]+\.[0-9]+\.[0-9]+)"/\1/')
if [[ -z "${NEXT_VERSION}" ]]; then
echo "Failed to parse bumped version from etl/Cargo.toml" >&2
exit 1
fi
echo "next=${NEXT_VERSION}" >> "$GITHUB_OUTPUT"
echo "Next version: ${NEXT_VERSION}"
- name: Install git-cliff
run: cargo install git-cliff --locked
- name: Generate CHANGELOG.md
env:
NEXT_VERSION: ${{ steps.ver.outputs.next }}
run: |
# Generate changelog with the new tag, containing only unreleased changes (difference from last tag)
# and prepend it to the existing changelog.
git cliff --config cliff.toml --tag "v${NEXT_VERSION}" --unreleased --prepend CHANGELOG.md
- name: Create Release Pull Request
uses: peter-evans/create-pull-request@v6
with:
commit-message: "chore(release): v${{ steps.ver.outputs.next }}"
title: "chore(release): v${{ steps.ver.outputs.next }}"
body: |
This PR prepares release v${{ steps.ver.outputs.next }}.
- Bumps workspace versions.
- Updates CHANGELOG.md with unreleased changes.
Merging this PR into `main` will trigger the release workflow which tags the commit, publishes Docker images, and creates the GitHub Release.
branch: release/v${{ steps.ver.outputs.next }}
base: main
labels: |
release
automated
delete-branch: true