Skip to content

Commit 2d52690

Browse files
committed
ci: add release workflow with version bump and GH Release
Signed-off-by: danbugs <danilochiarlone@gmail.com>
1 parent a67b556 commit 2d52690

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Create release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version (e.g., 0.2.0) — without the v prefix'
8+
required: true
9+
type: string
10+
11+
concurrency:
12+
group: release
13+
cancel-in-progress: false
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
packages: write
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
ref: main
25+
26+
- name: Validate version input
27+
run: |
28+
VERSION="${{ github.event.inputs.version }}"
29+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
30+
echo "::error::Invalid version '$VERSION' — expected semver like 1.2.3"
31+
exit 1
32+
fi
33+
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
34+
echo "::error::Tag v$VERSION already exists"
35+
exit 1
36+
fi
37+
38+
- uses: Swatinem/rust-cache@v2
39+
with:
40+
workspaces: host -> target
41+
42+
- name: Bump Cargo.toml version
43+
working-directory: host
44+
run: |
45+
VERSION="${{ github.event.inputs.version }}"
46+
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
47+
cargo generate-lockfile
48+
grep "^version" Cargo.toml
49+
50+
- name: Commit version bump
51+
run: |
52+
VERSION="${{ github.event.inputs.version }}"
53+
git config user.name "github-actions[bot]"
54+
git config user.email "github-actions[bot]@users.noreply.github.com"
55+
git add host/Cargo.toml host/Cargo.lock
56+
git commit -m "release: v$VERSION"
57+
git push origin main
58+
59+
- name: Create tag and GitHub Release
60+
env:
61+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
run: |
63+
VERSION="${{ github.event.inputs.version }}"
64+
git tag "v$VERSION"
65+
git push origin "v$VERSION"
66+
gh release create "v$VERSION" \
67+
--title "v$VERSION" \
68+
--generate-notes
69+
70+
- name: Trigger GHCR image publish
71+
env:
72+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
run: |
74+
VERSION="${{ github.event.inputs.version }}"
75+
gh workflow run publish-examples.yml --ref "v$VERSION"

0 commit comments

Comments
 (0)