Skip to content

Commit d487304

Browse files
committed
chore: release v0.2.0 and add bump-release workflow
- Bump version to 0.2.0 - Add workflow_dispatch workflow that bumps Cargo.toml, commits, tags, and pushes (triggering the existing release workflow)
1 parent 51c434c commit d487304

3 files changed

Lines changed: 152 additions & 67 deletions

File tree

.github/workflows/bump-release.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Bump & Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump:
7+
description: "Version bump type"
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
15+
permissions:
16+
contents: write
17+
18+
jobs:
19+
bump-and-tag:
20+
runs-on: ubuntu-22.04
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Compute new version
27+
id: version
28+
run: |
29+
CURRENT=$(grep -m1 '^version' Cargo.toml | sed 's/.*"\(.*\)"/\1/')
30+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
31+
case "${{ inputs.bump }}" in
32+
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
33+
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
34+
patch) PATCH=$((PATCH + 1)) ;;
35+
esac
36+
NEW="${MAJOR}.${MINOR}.${PATCH}"
37+
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
38+
echo "new=$NEW" >> "$GITHUB_OUTPUT"
39+
echo "Bumping $CURRENT -> $NEW"
40+
41+
- name: Bump Cargo.toml
42+
run: sed -i "0,/^version = \".*\"/s//version = \"${{ steps.version.outputs.new }}\"/" Cargo.toml
43+
44+
- name: Update Cargo.lock
45+
run: cargo generate-lockfile
46+
47+
- name: Commit, tag, and push
48+
run: |
49+
git config user.name "github-actions[bot]"
50+
git config user.email "github-actions[bot]@users.noreply.github.com"
51+
git add Cargo.toml Cargo.lock
52+
git commit -m "chore: release v${{ steps.version.outputs.new }}"
53+
git tag "v${{ steps.version.outputs.new }}"
54+
git push origin main --tags

0 commit comments

Comments
 (0)