Skip to content

version management

version management #96

Workflow file for this run

name: version management
on:
workflow_dispatch:
inputs:
action:
type: choice
description: What do you want to do?
required: true
options:
- bump-version # 1.2.3 -> 1.2.4
- start-prerelease # 1.2.3 -> 1.3.0-beta.1
- bump-prerelease # beta.5 -> beta.6
- transition-prerelease # beta.5 -> rc.1
- finalize # 1.3.0-rc.2 -> 1.3.0
level:
type: choice
description: Version bump level (required for bump-version / start-prerelease)
required: false
options: [patch, minor, major]
stage:
type: choice
description: Prerelease stage (required for start-prerelease / transition-prerelease)
required: false
options: [alpha, beta, rc]
permissions:
contents: write
pull-requests: write
jobs:
bump-version:
runs-on: ubuntu-latest
steps:
- name: Validate inputs
run: |
ACTION="${{ github.event.inputs.action }}"
LEVEL="${{ github.event.inputs.level }}"
STAGE="${{ github.event.inputs.stage }}"
case "$ACTION" in
bump-version)
[ -n "$LEVEL" ] || { echo "level is required"; exit 1; }
;;
start-prerelease)
[ -n "$LEVEL" ] && [ -n "$STAGE" ] || {
echo "level and stage are required"
exit 1
}
;;
bump-prerelease)
;;
transition-prerelease)
[ -n "$STAGE" ] || { echo "stage is required"; exit 1; }
;;
finalize)
;;
*)
echo "Invalid action"
exit 1
;;
esac
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get current version
id: current_version
uses: mozilla-ai/cargo-goose/actions/current-version@v1
with:
force-single-version: true
- name: Compute cargo-goose args
id: goose_args
run: |
ACTION="${{ github.event.inputs.action }}"
LEVEL="${{ github.event.inputs.level }}"
STAGE="${{ github.event.inputs.stage }}"
case "$ACTION" in
bump-version)
ARGS="bump version $LEVEL"
;;
start-prerelease)
ARGS="bump version $LEVEL $STAGE"
;;
bump-prerelease)
ARGS="bump prerelease"
;;
transition-prerelease)
ARGS="bump prerelease $STAGE"
;;
finalize)
ARGS="bump release"
;;
*)
echo "Invalid action"
exit 1
;;
esac
echo "args=$ARGS" >> "$GITHUB_OUTPUT"
- name: Bump version
uses: mozilla-ai/cargo-goose/actions/cargo-goose@v1
with:
args: ${{ steps.goose_args.outputs.args }}
- name: Get new version
id: new_version
uses: mozilla-ai/cargo-goose/actions/current-version@v1
with:
force-single-version: true
- name: Abort if version did not change
run: |
if [ "${{ steps.current_version.outputs.version }}" = \
"${{ steps.new_version.outputs.version }}" ]; then
echo "Version did not change; aborting"
exit 1
fi
- name: Update Cargo.lock
run: cargo generate-lockfile
- name: Generate labels
id: labels
run: |
ACTION="${{ github.event.inputs.action }}"
LEVEL="${{ github.event.inputs.level }}"
IS_PRE="${{ steps.new_version.outputs.is_prerelease }}"
PRE="${{ steps.new_version.outputs.pre }}"
LABELS="version-bump\nauto-generated\n$ACTION"
if [ "$IS_PRE" = "true" ]; then
LABELS="$LABELS\nprerelease\n$PRE"
else
[ -n "$LEVEL" ] && LABELS="$LABELS\n$LEVEL"
fi
echo "labels<<EOF" >> "$GITHUB_OUTPUT"
echo -e "$LABELS" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Create Pull Request
id: create_pr
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "version: bump version 🚀 ${{ steps.new_version.outputs.version }}"
title: "version: Version Bump 🚀 ${{ steps.new_version.outputs.version }}"
body: |
Version bumped from ${{ steps.current_version.outputs.version }}
to ${{ steps.new_version.outputs.version }}.
### 🔄 Changes
- 📝 Updated version in Cargo.toml
- 🔒 Updated Cargo.lock
✨ This PR was automatically generated by the Version Management workflow ✨
![version bump](https://media0.giphy.com/media/v1.Y2lkPTc5MGI3NjExNjJmOXBxbGh2Z3BiYXM1NnJhMHdtbmNoaTFxN2xjOGZjZnd1ZGhuMiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/3oEjI53nBYOOEQgDcY/giphy.gif)
branch: version/bump-${{ github.run_id }}
base: main
delete-branch: true
add-paths: |
Cargo.lock
**/Cargo.toml
labels: ${{ steps.labels.outputs.labels }}