Skip to content

Commit 29c62dc

Browse files
authored
Merge pull request #8 from hyperlight-dev/jprendes/fix-publishing
Fix publishing workflow
2 parents 89f5fb5 + 520ab36 commit 29c62dc

File tree

9 files changed

+89
-43
lines changed

9 files changed

+89
-43
lines changed

.github/workflows/CargoPublish.yml

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
22

3-
name: Publish crates to intenral cargo registry
3+
name: Publish crates to crates.io
44

55
on:
66
workflow_dispatch:
7+
inputs:
8+
dry_run:
9+
description: "Run the release without actually releasing bits"
10+
type: boolean
11+
default: true
712
workflow_call:
13+
inputs:
14+
dry_run:
15+
description: "Run the release without actually releasing bits"
16+
type: boolean
17+
default: true
818

919
permissions:
1020
contents: read
@@ -14,8 +24,7 @@ jobs:
1424
publish-hyperlight-packages:
1525
runs-on: [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd"]
1626

17-
# We should only publish from main if minver contains `-preview`
18-
if: ${{ contains(github.ref, 'refs/heads/release/') }} || ${{ github.ref=='refs/heads/main' }}
27+
if: ${{ startsWith(github.ref, 'refs/heads/release/v') || inputs.dry_run }}
1928

2029
steps:
2130
- uses: actions/checkout@v4
@@ -27,47 +36,39 @@ jobs:
2736
with:
2837
rust-toolchain: "1.81.0"
2938

30-
- name: Set up cargo workspaces version
39+
- name: Check crate versions
40+
shell: bash
3141
run: |
32-
cargo install cargo-workspaces
33-
cargo install minver_rs
34-
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
35-
git config --global user.Name "${{ github.actor }}"
36-
37-
- name: Set crate versions
38-
run: |
39-
git fetch --tags || true
40-
version=$(MINVER_TAG_PREFIX=v MINVER_AUTO_INCREMENT_LEVEL=Minor MINVER_PRERELEASE_IDENTIFIER=preview minver)
41-
echo "Setting version to $version"
42-
cargo ws version --force=hyperlight_* --no-git-commit --yes custom $version
43-
echo "HYPERLIGHT_VERSION=$version" >> "$GITHUB_ENV"
44-
45-
- name: Determine if we should publish crates
46-
run: |
47-
echo "github.ref=${{ github.ref }}"
48-
echo "HYPERLIGHT_VERSION=$HYPERLIGHT_VERSION"
49-
if [[ ${{ github.ref }} =~ 'refs/heads/release/' || ( ${{ github.ref }} == 'refs/heads/main' && $HYPERLIGHT_VERSION =~ '-preview' ) ]]
50-
then
51-
echo "Setting SHOULD_PUBLISH in GITHUB_ENV"
52-
echo "SHOULD_PUBLISH=true" >> "$GITHUB_ENV"
42+
if ${{ inputs.dry_run }}; then
43+
VERSION=""
44+
else
45+
VERSION="${{ github.ref }}"
46+
VERSION="${VERSION#refs/heads/release/v}"
5347
fi
54-
# `allow-dirty` is needed in the publish below because we are using the `--no-git-commit`
55-
# option above to cover the case where no changes are made by cargo ws version because the version
56-
# is already correct
57-
- name: Publish hyperlight-flatbuffers
58-
if: ${{ env.SHOULD_PUBLISH == 'true' }}
59-
run: cargo publish --manifest-path ./src/hyperlight_common/Cargo.toml --registry hyperlight_packages --allow-dirty
48+
./dev/verify-version.sh "$VERSION" hyperlight-common hyperlight-guest hyperlight-host
49+
50+
- name: Publish hyperlight-common
51+
continue-on-error: ${{ inputs.dry_run }}
52+
run: cargo publish --manifest-path ./src/hyperlight_common/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
53+
env:
54+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }}
6055

6156
- name: Publish hyperlight-guest
62-
if: ${{ env.SHOULD_PUBLISH == 'true' }}
63-
run: cargo publish --manifest-path ./src/hyperlight_guest/Cargo.toml --registry hyperlight_packages --allow-dirty
57+
continue-on-error: ${{ inputs.dry_run }}
58+
run: cargo publish --manifest-path ./src/hyperlight_guest/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
59+
env:
60+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }}
6461

6562
- name: Publish hyperlight-host
66-
if: ${{ env.SHOULD_PUBLISH == 'true' }}
67-
run: cargo publish --manifest-path ./src/hyperlight_host/Cargo.toml --registry hyperlight_packages --allow-dirty
63+
continue-on-error: ${{ inputs.dry_run }}
64+
run: cargo publish --manifest-path ./src/hyperlight_host/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
65+
env:
66+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }}
6867

69-
# `--no-verify` is needed because build.rs writes to "include/hyperlight_guest.h", but since we exclude that directory in Cargo.toml, it should be fine.
70-
# Cargo does not want you to modify files outside of OUT_DIR
71-
- name: Publish hyperlight-guest-capi
72-
if: ${{ env.SHOULD_PUBLISH == 'true' }}
73-
run: cd ./src/hyperlight_guest_capi && cargo publish --registry hyperlight_packages --no-verify --allow-dirty # cd is required because of https://github.com/rust-lang/cargo/issues/10302
68+
# TODO: Do we want to publish hyperlight-guest-capi to crates.io given that it's not for Rust consumption?
69+
# - name: Publish hyperlight-guest-capi
70+
# # `--no-verify` is needed because build.rs writes to "include/hyperlight_guest.h", but since we exclude that directory in Cargo.toml, it should be fine.
71+
# # Cargo does not want you to modify files outside of OUT_DIR
72+
# run: cd ./src/hyperlight_guest_capi && cargo publish --no-verify ${{ inputs.dry_run && '--dry-run' || '' }} # cd is required because of https://github.com/rust-lang/cargo/issues/10302
73+
# env:
74+
# CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }}

.github/workflows/CreateRelease.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ jobs:
7474
cargo-publish:
7575
needs: [publish]
7676
uses: ./.github/workflows/CargoPublish.yml
77+
with:
78+
dry_run: false
7779
secrets: inherit
7880
permissions:
7981
id-token: write

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ exclude = [
2727
version = "0.9.0"
2828
edition = "2021"
2929
rust-version = "1.79.0"
30+
license = "Apache-2.0"
31+
homepage = "https://github.com/hyperlight-dev/hyperlight"
32+
repository = "https://github.com/hyperlight-dev/hyperlight"
33+
readme = "README.md"
3034

3135
[workspace.dependencies]
3236
mshv-bindings = { version = "=0.2.1" }
@@ -35,7 +39,7 @@ mshv-ioctls = { version = "=0.2.1" }
3539
hyperlight-common = { path = "src/hyperlight_common", version = "0.9.0", default-features = false }
3640
hyperlight-host = { path = "src/hyperlight_host", version = "0.9.0", default-features = false }
3741
hyperlight-guest = { path = "src/hyperlight_guest", version = "0.9.0", default-features = false }
38-
hyperlight-testing = { path = "src/hyperlight_testing", version = "0.9.0", default-features = false }
42+
hyperlight-testing = { path = "src/hyperlight_testing", default-features = false }
3943

4044
[workspace.lints.rust]
4145
unsafe_op_in_unsafe_fn = "deny"

dev/verify-version.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -Eeuo pipefail
3+
cargo install -q jaq
4+
5+
EXPECTED="$1"
6+
EXPECTED="${EXPECTED#refs/heads/release/}"
7+
EXPECTED="${EXPECTED#v}"
8+
shift
9+
10+
for CRATE in "$@"; do
11+
VERSION=$(cargo metadata --format-version=1 2>/dev/null | jaq --raw-output '.packages[] | select(.name == "'$CRATE'").version')
12+
if [ "$VERSION" == "$EXPECTED" ] || [ "" == "$EXPECTED" ]; then
13+
echo -e " \u001b[1;32m✓\u001b[0m Crate \u001b[1m$CRATE\u001b[0m version is \u001b[1m$VERSION\u001b[0m"
14+
else
15+
echo -e " \u001b[1;31m✗\u001b[0m Crate \u001b[1m$CRATE\u001b[0m version is \u001b[1m$VERSION\u001b[0m, expected \u001b[1m$EXPECTED\u001b[0m"
16+
exit 1
17+
fi
18+
done

docs/how-to-make-releases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Releasing a new Hyperlight version to Cargo
22

3-
This document details the process of releasing a new version of Hyperlight to the [Azure-internal Cargo feeds](https://dev.azure.com/AzureContainerUpstream/hyperlight/_artifacts/feed/hyperlight_packages). It's intended to be used as a checklist for the developer doing the release. The checklist is represented in the below sections.
3+
This document details the process of releasing a new version of Hyperlight to [crates.io](https://crates.io). It's intended to be used as a checklist for the developer doing the release. The checklist is represented in the below sections.
44

55
## Update Cargo.toml Versions
66

src/hyperlight_common/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ name = "hyperlight-common"
33
version.workspace = true
44
edition.workspace = true
55
rust-version.workspace = true
6+
license.workspace = true
7+
homepage.workspace = true
8+
repository.workspace = true
9+
readme.workspace = true
10+
description = """
11+
Hyperlight's components common to host and guest.
12+
"""
613

714
[lints]
815
workspace = true

src/hyperlight_guest/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ links = "c"
44
version.workspace = true
55
edition.workspace = true
66
rust-version.workspace = true
7+
license.workspace = true
8+
homepage.workspace = true
9+
repository.workspace = true
10+
readme.workspace = true
11+
description = """
12+
Library to build guest applications for hyperlight.
13+
"""
714

815
[features]
916
default = ["libc", "printf", "alloca"]

src/hyperlight_host/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ name = "hyperlight-host"
33
version.workspace = true
44
edition.workspace = true
55
rust-version.workspace = true
6+
license.workspace = true
7+
homepage.workspace = true
8+
repository.workspace = true
9+
readme.workspace = true
10+
description = """
11+
A lightweight Virtual Machine Manager that can be hosted in an application to safely
12+
run untrusted or code within a VM partition with very low latency and overhead.
13+
"""
614

715
[lib]
816
# https://docs.rust-embedded.org/book/interoperability/rust-with-c.html

src/hyperlight_testing/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[package]
22
name = "hyperlight-testing"
3-
version.workspace = true
43
edition = "2021"
54

65
[dependencies]

0 commit comments

Comments
 (0)