Skip to content

Commit b05247b

Browse files
authored
Merge pull request #8 from jsturtevant/publish-step
Add publish step
2 parents dd69686 + 87a48aa commit b05247b

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
branches: [main]
1010
pull_request:
1111
branches: [main]
12+
workflow_call:
1213

1314
env:
1415
CARGO_TERM_COLOR: always

.github/workflows/publish.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
8+
jobs:
9+
ci:
10+
name: Run CI
11+
uses: ./.github/workflows/ci.yml
12+
13+
validate:
14+
name: Validate version
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Check version matches tag
19+
run: |
20+
TAG_VERSION="${GITHUB_REF_NAME#v}"
21+
CARGO_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "cargo-hyperlight") | .version')
22+
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
23+
echo "Error: Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
24+
exit 1
25+
fi
26+
echo "Version validated: $TAG_VERSION"
27+
28+
publish:
29+
name: Publish to crates.io
30+
needs: [ci, validate]
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: actions-rust-lang/setup-rust-toolchain@v1
35+
- name: Publish
36+
run: cargo publish
37+
env:
38+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }}
39+
40+
release:
41+
name: Create GitHub Release
42+
needs: publish
43+
runs-on: ubuntu-latest
44+
permissions:
45+
contents: write
46+
steps:
47+
- uses: actions/checkout@v4
48+
- name: Create GitHub Release
49+
env:
50+
GH_TOKEN: ${{ github.token }}
51+
run: |
52+
gh release create "$GITHUB_REF_NAME" \
53+
--title "$GITHUB_REF_NAME" \
54+
--generate-notes

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,13 @@ cargo hyperlight build --release
8686
Your binary will be built for the `x86_64-hyperlight-none` target by default, and placed in `target/x86_64-hyperlight-none/release/guest`.
8787

8888
There's no need for any extra configuration, the command will take care of everything.
89+
90+
## Releasing
91+
92+
To publish a new version:
93+
94+
1. Update the version in `Cargo.toml`
95+
2. Commit the change: `git commit -S -s -am "Bump version to X.Y.Z"` and open a PR
96+
3. Create and push a tag: `git tag -s vX.Y.Z && git push origin vX.Y.Z`
97+
98+
The CI will automatically run tests, publish to crates.io, and create a GitHub release.

0 commit comments

Comments
 (0)