@@ -44,43 +44,73 @@ jobs:
4444 else
4545 VERSION="${{ github.ref }}"
4646 VERSION="${VERSION#refs/heads/release/v}"
47+ echo "VERSION=$VERSION" >> $GITHUB_ENV
4748 fi
4849 ./dev/verify-version.sh "$VERSION" hyperlight-common hyperlight-guest hyperlight-guest-bin hyperlight-host hyperlight-component-util hyperlight-component-macro
4950
51+ - name : Determine which crates need publishing
52+ run : |
53+ needs_publish() {
54+ local crate=$1
55+ if curl -s "https://crates.io/api/v1/crates/$crate/$VERSION" | jq -e .version > /dev/null; then
56+ echo "PUBLISH_${crate^^}=false" >> "$GITHUB_ENV"
57+ echo "✅ $crate@$VERSION already exists."
58+ else
59+ echo "PUBLISH_${crate^^}=true" >> "$GITHUB_ENV"
60+ echo "🚀 $crate@$VERSION will be published."
61+ fi
62+ }
63+
64+ # NOTE, must use underscores here, not dashes.
65+
66+ needs_publish hyperlight_common
67+ needs_publish hyperlight_guest
68+ needs_publish hyperlight_guest_bin
69+ needs_publish hyperlight_component_util
70+ needs_publish hyperlight_component_macro
71+ needs_publish hyperlight_host
72+
5073 - name : Publish hyperlight-common
5174 continue-on-error : ${{ inputs.dry_run }}
5275 run : cargo publish --manifest-path ./src/hyperlight_common/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
5376 env :
5477 CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
78+ if : env.PUBLISH_HYPERLIGHT_COMMON != 'false'
5579
5680 - name : Publish hyperlight-guest
5781 continue-on-error : ${{ inputs.dry_run }}
5882 run : cargo publish --manifest-path ./src/hyperlight_guest/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
5983 env :
6084 CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
85+ if : env.PUBLISH_HYPERLIGHT_GUEST != 'false'
6186
6287 - name : Publish hyperlight-guest-bin
6388 continue-on-error : ${{ inputs.dry_run }}
6489 run : cargo publish --manifest-path ./src/hyperlight_guest_bin/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
6590 env :
6691 CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
92+ if : env.PUBLISH_HYPERLIGHT_GUEST_BIN != 'false'
93+
6794 - name : Publish hyperlight-component-util
6895 continue-on-error : ${{ inputs.dry_run }}
6996 run : cargo publish --manifest-path ./src/hyperlight_component_util/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
7097 env :
7198 CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
99+ if : env.PUBLISH_HYPERLIGHT_COMPONENT_UTIL != 'false'
72100
73101 - name : Publish hyperlight-component-macro
74102 continue-on-error : ${{ inputs.dry_run }}
75103 run : cargo publish --manifest-path ./src/hyperlight_component_macro/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
76104 env :
77105 CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
106+ if : env.PUBLISH_HYPERLIGHT_COMPONENT_MACRO != 'false'
78107
79108 - name : Publish hyperlight-host
80109 continue-on-error : ${{ inputs.dry_run }}
81110 run : cargo publish --manifest-path ./src/hyperlight_host/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
82111 env :
83112 CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
113+ if : env.PUBLISH_HYPERLIGHT_HOST != 'false'
84114
85115
86116 # TODO: Do we want to publish hyperlight-guest-capi to crates.io given that it's not for Rust consumption?
0 commit comments