@@ -44,43 +44,79 @@ 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+ local crate_env_var=$(echo "$crate" | tr '[:lower:]' '[:upper:]' | tr '-' '_')
56+
57+ if [ -z "$VERSION" ]; then
58+ echo "No version set (dry run?), skipping crates.io existence checks."
59+ echo "PUBLISH_${crate_env_var}=true" >> "$GITHUB_ENV"
60+ return
61+ fi
62+
63+ if curl -s "https://crates.io/api/v1/crates/$crate/$VERSION" | jq -e .version > /dev/null; then
64+ echo "PUBLISH_${crate_env_var}=false" >> "$GITHUB_ENV"
65+ echo "✅ $crate@$VERSION already exists."
66+ else
67+ echo "PUBLISH_${crate_env_var}=true" >> "$GITHUB_ENV"
68+ echo "🚀 $crate@$VERSION will be published."
69+ fi
70+ }
71+
72+ needs_publish hyperlight-common
73+ needs_publish hyperlight-guest
74+ needs_publish hyperlight-guest-bin
75+ needs_publish hyperlight-component-util
76+ needs_publish hyperlight-component-macro
77+ needs_publish hyperlight-host
78+
5079 - name : Publish hyperlight-common
5180 continue-on-error : ${{ inputs.dry_run }}
5281 run : cargo publish --manifest-path ./src/hyperlight_common/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
5382 env :
5483 CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
84+ if : env.PUBLISH_HYPERLIGHT_COMMON != 'false'
5585
5686 - name : Publish hyperlight-guest
5787 continue-on-error : ${{ inputs.dry_run }}
5888 run : cargo publish --manifest-path ./src/hyperlight_guest/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
5989 env :
6090 CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
91+ if : env.PUBLISH_HYPERLIGHT_GUEST != 'false'
6192
6293 - name : Publish hyperlight-guest-bin
6394 continue-on-error : ${{ inputs.dry_run }}
6495 run : cargo publish --manifest-path ./src/hyperlight_guest_bin/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
6596 env :
6697 CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
98+ if : env.PUBLISH_HYPERLIGHT_GUEST_BIN != 'false'
99+
67100 - name : Publish hyperlight-component-util
68101 continue-on-error : ${{ inputs.dry_run }}
69102 run : cargo publish --manifest-path ./src/hyperlight_component_util/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
70103 env :
71104 CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
105+ if : env.PUBLISH_HYPERLIGHT_COMPONENT_UTIL != 'false'
72106
73107 - name : Publish hyperlight-component-macro
74108 continue-on-error : ${{ inputs.dry_run }}
75109 run : cargo publish --manifest-path ./src/hyperlight_component_macro/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
76110 env :
77111 CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
112+ if : env.PUBLISH_HYPERLIGHT_COMPONENT_MACRO != 'false'
78113
79114 - name : Publish hyperlight-host
80115 continue-on-error : ${{ inputs.dry_run }}
81116 run : cargo publish --manifest-path ./src/hyperlight_host/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
82117 env :
83118 CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
119+ if : env.PUBLISH_HYPERLIGHT_HOST != 'false'
84120
85121
86122 # TODO: Do we want to publish hyperlight-guest-capi to crates.io given that it's not for Rust consumption?
0 commit comments