Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
branches: [main]
pull_request:
branches: [main]
workflow_call:

env:
CARGO_TERM_COLOR: always
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Publish

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, we can cross this bridge later: might want to consider trailing alpha, beta prerelease tags.


jobs:
ci:
name: Run CI
uses: ./.github/workflows/ci.yml

validate:
name: Validate version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check version matches tag
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
CARGO_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "cargo-hyperlight") | .version')
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
echo "Error: Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
exit 1
fi
echo "Version validated: $TAG_VERSION"

publish:
name: Publish to crates.io
needs: [ci, validate]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Publish
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }}

release:
name: Create GitHub Release
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "$GITHUB_REF_NAME" \
--title "$GITHUB_REF_NAME" \
--generate-notes
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,13 @@ cargo hyperlight build --release
Your binary will be built for the `x86_64-hyperlight-none` target by default, and placed in `target/x86_64-hyperlight-none/release/guest`.

There's no need for any extra configuration, the command will take care of everything.

## Releasing

To publish a new version:

1. Update the version in `Cargo.toml`
2. Commit the change: `git commit -S -s -am "Bump version to X.Y.Z"` and open a PR
3. Create and push a tag: `git tag -s vX.Y.Z && git push origin vX.Y.Z`

The CI will automatically run tests, publish to crates.io, and create a GitHub release.