Skip to content

Prepare Release

Prepare Release #8

name: Prepare Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version number (without v prefix, e.g. 0.5.0)'
required: true
type: string
base_commit:
description: 'Base commit SHA (leave empty to use latest develop)'
required: false
type: string
default: ''
# Add permissions for GitHub operations
permissions:
contents: write
pull-requests: write
jobs:
prepare-release:
runs-on: ubuntu-latest
outputs:
version: ${{ inputs.version }} # Output the version for use in other jobs
tag_name: v${{ inputs.version }}
release_branch: release/v${{ inputs.version }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.base_commit || 'develop' }}
fetch-depth: 0 # Fetch all history for changelog generation
- name: Setup environment
run: |
set -e
# Setup Git Identity
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
# Install dependencies
sudo apt-get update && sudo apt-get install -y protobuf-compiler
cargo install cargo-edit
cargo install git-cliff
- name: Validate version format
run: |
set -e
VERSION="${{ inputs.version }}"
# Make sure version is not empty
if [ -z "$VERSION" ]; then
echo "Error: Version is required"
exit 1
fi
# Validate using semver regex pattern
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Version '$VERSION' is not valid semantic versioning format."
echo "Expected format: MAJOR.MINOR.PATCH"
echo "Examples: 1.0.0, 0.5.0"
exit 1
fi
echo "Version format is valid: $VERSION"
- name: Create release branch
run: |
set -e
# Create release branch with standardized format
RELEASE_BRANCH="release/v${{ inputs.version }}"
echo "Creating branch $RELEASE_BRANCH"
git checkout -b $RELEASE_BRANCH
echo "RELEASE_BRANCH=$RELEASE_BRANCH" >> $GITHUB_ENV
- name: Update version numbers
run: |
set -e
# Update Cargo.toml versions
find . -name "Cargo.toml" -type f -exec cargo set-version ${{ inputs.version }} --manifest-path {} \;
# Update any other version references
if [ -f "VERSION" ]; then
echo "${{ inputs.version }}" > VERSION
fi
git add -A
git commit -m "chore: bump version to ${{ inputs.version }}"
- name: Generate changelog
id: changelog
run: ./scripts/release/prepare_changelog.sh "${{ inputs.version }}"
- name: Push release branch
run: |
set -e
git push -u origin ${{ env.RELEASE_BRANCH }}
- name: Create pull request
run: |
set -e
gh pr create \
--base main \
--head ${{ env.RELEASE_BRANCH }} \
--title "Release v${{ inputs.version }}" \
--body-file .changelog_content
echo "Pull Request created. Please review the PR, make any necessary adjustments, and merge when ready."
- name: Upload changelog artifact
uses: actions/upload-artifact@v4
with:
name: changelog
path: CHANGELOG.md