Skip to content

Commit b78da05

Browse files
authored
Merge pull request #29 from hyperlight-dev/release-workflow-v2
ci: simplify release workflow — read version from Cargo.toml
2 parents a13793a + 71a029e commit b78da05

2 files changed

Lines changed: 51 additions & 32 deletions

File tree

.github/workflows/release.yml

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ name: Create release
22

33
on:
44
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
105

116
concurrency:
127
group: release
@@ -23,44 +18,31 @@ jobs:
2318
with:
2419
ref: main
2520

26-
- name: Validate version input
21+
- name: Read version from Cargo.toml
22+
id: version
23+
working-directory: host
24+
run: |
25+
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
26+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
27+
echo "Detected version: $VERSION"
28+
29+
- name: Validate version
2730
run: |
28-
VERSION="${{ github.event.inputs.version }}"
31+
VERSION="${{ steps.version.outputs.version }}"
2932
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
30-
echo "::error::Invalid version '$VERSION' — expected semver like 1.2.3"
33+
echo "::error::Invalid version '$VERSION' in Cargo.toml — expected semver like 1.2.3"
3134
exit 1
3235
fi
3336
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
34-
echo "::error::Tag v$VERSION already exists"
37+
echo "::error::Tag v$VERSION already exists — bump the version in Cargo.toml first"
3538
exit 1
3639
fi
3740
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-
5941
- name: Create tag and GitHub Release
6042
env:
6143
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6244
run: |
63-
VERSION="${{ github.event.inputs.version }}"
45+
VERSION="${{ steps.version.outputs.version }}"
6446
git tag "v$VERSION"
6547
git push origin "v$VERSION"
6648
gh release create "v$VERSION" \
@@ -71,5 +53,5 @@ jobs:
7153
env:
7254
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7355
run: |
74-
VERSION="${{ github.event.inputs.version }}"
56+
VERSION="${{ steps.version.outputs.version }}"
7557
gh workflow run publish-examples.yml --ref "v$VERSION"

docs/releasing.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Releasing hyperlight-unikraft
2+
3+
All examples, kernels, and GHCR images share a single version derived
4+
from `host/Cargo.toml`.
5+
6+
## Steps
7+
8+
1. **Bump the version** — open a PR that updates `version` in
9+
`host/Cargo.toml` (e.g., `"0.1.0"``"0.2.0"`). Merge it to main.
10+
11+
2. **Run the release workflow** — go to
12+
**Actions → Create release → Run workflow**. No input needed — the
13+
workflow reads the version from `Cargo.toml`.
14+
15+
3. **What happens automatically:**
16+
- A `v<version>` git tag is created on main.
17+
- A GitHub Release is created with auto-generated notes.
18+
- The publish workflow is triggered, pushing all GHCR images with
19+
both `:latest` and `:v<version>` tags.
20+
21+
## Versioning policy
22+
23+
- New examples or language support → minor bump (0.1.0 → 0.2.0).
24+
- Bug fixes or documentation → patch bump (0.1.0 → 0.1.1).
25+
- Breaking API changes → major bump (0.x → 1.0.0, once stable).
26+
27+
All images are republished on every release, even if unchanged. GHCR
28+
tags are idempotent, so this is harmless.
29+
30+
## crates.io
31+
32+
Publishing to crates.io is blocked until `hyperlight-host` with the
33+
`disk_snapshot_copy` APIs is available on crates.io (see [#27]).
34+
Once unblocked, a `cargo publish` step should be added to the release
35+
workflow.
36+
37+
[#27]: https://github.com/hyperlight-dev/hyperlight-unikraft/issues/27

0 commit comments

Comments
 (0)