Skip to content

Crates Version Bump #15

Crates Version Bump

Crates Version Bump #15

name: Crates Version Bump
on:
workflow_dispatch:
inputs:
pre-id:
description: 'Prerelease identifier for prerelease versions'
required: false
default: 'alpha'
type: choice
options:
- beta
- rc
force:
description: 'Force version bump even if no changes detected'
required: false
default: false
type: boolean
jobs:
bump-version:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
fetch-depth: 0
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo-workspaces
uses: actions/cache@v3
id: cache-cargo-workspaces
with:
path: ~/.cargo/bin/cargo-workspaces
key: cargo-workspaces-${{ runner.os }}-v1
restore-keys: |
cargo-workspaces-${{ runner.os }}-
- name: Install cargo-workspaces
if: steps.cache-cargo-workspaces.outputs.cache-hit != 'true'
run: cargo install cargo-workspaces
- name: Setup Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Run version bump
run: |
BRANCH="${GITHUB_REF_NAME}"
PRE_ID="${{ inputs.pre-id }}"
FORCE="${{ inputs.force }}"
echo "Running on branch: $BRANCH"
echo "Prerelease identifier: $PRE_ID"
echo "Force flag: $FORCE"
echo "Will bump version for ALL crates"
FORCE_FLAG=""
if [ "$FORCE" = "true" ]; then
FORCE_FLAG="--force '*'"
fi
case "$BRANCH" in
main)
cargo workspaces version --allow-branch "$BRANCH" --no-global-tag --yes $FORCE_FLAG
;;
development)
cargo workspaces version --allow-branch "$BRANCH" --no-global-tag prerelease --pre-id "$PRE_ID" --yes $FORCE_FLAG
;;
*)
echo "❌ This workflow can only be run on 'main' or 'development'."
exit 1
;;
esac