diff --git a/.github/workflows/cargo-publish.yml b/.github/workflows/cargo-publish.yml new file mode 100644 index 0000000..e4c6fbf --- /dev/null +++ b/.github/workflows/cargo-publish.yml @@ -0,0 +1,68 @@ +name: Publish to crates.io + +on: + release: + types: [published] + workflow_dispatch: + inputs: + dry_run: + description: "Run without actually publishing" + type: boolean + default: true + +permissions: + contents: read + id-token: write + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: dtolnay/rust-toolchain@stable + + - name: Determine if dry run + id: mode + run: | + if [ "${{ github.event_name }}" = "release" ]; then + echo "dry_run=false" >> "$GITHUB_OUTPUT" + else + echo "dry_run=${{ inputs.dry_run }}" >> "$GITHUB_OUTPUT" + fi + + - name: Verify version matches tag + if: ${{ steps.mode.outputs.dry_run == 'false' }} + run: | + TAG="${GITHUB_REF#refs/tags/v}" + CARGO_VER=$(grep '^version' host/Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/') + if [ "$TAG" != "$CARGO_VER" ]; then + echo "::error::Tag v$TAG does not match Cargo.toml version $CARGO_VER" + exit 1 + fi + + - name: Check crate not already published + run: | + CARGO_VER=$(grep '^version' host/Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/') + if curl -sf "https://crates.io/api/v1/crates/hyperlight-unikraft/$CARGO_VER" -H "User-Agent: hyperlight-unikraft" | jq -e .version > /dev/null 2>&1; then + echo "::warning::hyperlight-unikraft@$CARGO_VER already published" + echo "ALREADY_PUBLISHED=true" >> "$GITHUB_ENV" + fi + + - name: Dry run (no auth needed) + if: ${{ steps.mode.outputs.dry_run == 'true' && env.ALREADY_PUBLISHED != 'true' }} + run: cargo publish --manifest-path host/Cargo.toml --dry-run + + - name: Authenticate with crates.io + if: ${{ steps.mode.outputs.dry_run == 'false' && env.ALREADY_PUBLISHED != 'true' }} + uses: rust-lang/crates-io-auth-action@v1 + id: crates-io-auth + + - name: Publish hyperlight-unikraft + if: ${{ steps.mode.outputs.dry_run == 'false' && env.ALREADY_PUBLISHED != 'true' }} + run: cargo publish --manifest-path host/Cargo.toml + env: + CARGO_REGISTRY_TOKEN: ${{ steps.crates-io-auth.outputs.token }} diff --git a/README.md b/README.md index 824459b..ebe6a95 100644 --- a/README.md +++ b/README.md @@ -117,15 +117,14 @@ pillow/lxml/cryptography/dateutil/dotenv preloaded) behind a simple `setup` / `run` workflow: ```bash +# Install pyhl from crates.io +cargo install hyperlight-unikraft --bin pyhl + # One-time: build the driver image (kernel + CPIO) cd examples/python-agent-driver just rootfs && just build cd ../.. -# Install pyhl -cargo install --git https://github.com/hyperlight-dev/hyperlight-unikraft \ - hyperlight-unikraft-host --bin pyhl - # Point pyhl at the image you just built — creates ./.pyhl/ in cwd pyhl setup --from examples/python-agent-driver diff --git a/demos/pptx-gen/Cargo.toml b/demos/pptx-gen/Cargo.toml index 6699deb..cc5308f 100644 --- a/demos/pptx-gen/Cargo.toml +++ b/demos/pptx-gen/Cargo.toml @@ -6,7 +6,7 @@ description = "PowerPoint generator using Hyperlight-Unikraft sandboxed Python e [dependencies] # Hyperlight-Unikraft library -hyperlight-unikraft = { path = "../../host", package = "hyperlight-unikraft-host" } +hyperlight-unikraft = { path = "../../host" } # OpenAI API client async-openai = "0.25" diff --git a/host/Cargo.lock b/host/Cargo.lock index 747974c..d86735d 100644 --- a/host/Cargo.lock +++ b/host/Cargo.lock @@ -1203,8 +1203,8 @@ dependencies = [ ] [[package]] -name = "hyperlight-unikraft-host" -version = "0.10.0" +name = "hyperlight-unikraft" +version = "0.11.0" dependencies = [ "anyhow", "base64", diff --git a/host/Cargo.toml b/host/Cargo.toml index a1e57ba..8c04c31 100644 --- a/host/Cargo.toml +++ b/host/Cargo.toml @@ -1,9 +1,14 @@ [package] -name = "hyperlight-unikraft-host" -version = "0.10.0" +name = "hyperlight-unikraft" +version = "0.11.0" edition = "2021" description = "Embedded Hyperlight host for running Unikraft unikernels" license = "MIT OR Apache-2.0" +repository = "https://github.com/hyperlight-dev/hyperlight-unikraft" +homepage = "https://github.com/hyperlight-dev/hyperlight-unikraft" +keywords = ["hyperlight", "unikraft", "unikernel", "microvm", "sandbox"] +categories = ["virtualization"] +readme = "../README.md" [lib] name = "hyperlight_unikraft"