@@ -44,43 +44,79 @@ jobs:
44
44
else
45
45
VERSION="${{ github.ref }}"
46
46
VERSION="${VERSION#refs/heads/release/v}"
47
+ echo "VERSION=$VERSION" >> $GITHUB_ENV
47
48
fi
48
49
./dev/verify-version.sh "$VERSION" hyperlight-common hyperlight-guest hyperlight-guest-bin hyperlight-host hyperlight-component-util hyperlight-component-macro
49
50
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
+
50
79
- name : Publish hyperlight-common
51
80
continue-on-error : ${{ inputs.dry_run }}
52
81
run : cargo publish --manifest-path ./src/hyperlight_common/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
53
82
env :
54
83
CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
84
+ if : env.PUBLISH_HYPERLIGHT_COMMON != 'false'
55
85
56
86
- name : Publish hyperlight-guest
57
87
continue-on-error : ${{ inputs.dry_run }}
58
88
run : cargo publish --manifest-path ./src/hyperlight_guest/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
59
89
env :
60
90
CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
91
+ if : env.PUBLISH_HYPERLIGHT_GUEST != 'false'
61
92
62
93
- name : Publish hyperlight-guest-bin
63
94
continue-on-error : ${{ inputs.dry_run }}
64
95
run : cargo publish --manifest-path ./src/hyperlight_guest_bin/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
65
96
env :
66
97
CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
98
+ if : env.PUBLISH_HYPERLIGHT_GUEST_BIN != 'false'
99
+
67
100
- name : Publish hyperlight-component-util
68
101
continue-on-error : ${{ inputs.dry_run }}
69
102
run : cargo publish --manifest-path ./src/hyperlight_component_util/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
70
103
env :
71
104
CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
105
+ if : env.PUBLISH_HYPERLIGHT_COMPONENT_UTIL != 'false'
72
106
73
107
- name : Publish hyperlight-component-macro
74
108
continue-on-error : ${{ inputs.dry_run }}
75
109
run : cargo publish --manifest-path ./src/hyperlight_component_macro/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
76
110
env :
77
111
CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
112
+ if : env.PUBLISH_HYPERLIGHT_COMPONENT_MACRO != 'false'
78
113
79
114
- name : Publish hyperlight-host
80
115
continue-on-error : ${{ inputs.dry_run }}
81
116
run : cargo publish --manifest-path ./src/hyperlight_host/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
82
117
env :
83
118
CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_PUBLISH_TOKEN }}
119
+ if : env.PUBLISH_HYPERLIGHT_HOST != 'false'
84
120
85
121
86
122
# TODO: Do we want to publish hyperlight-guest-capi to crates.io given that it's not for Rust consumption?
0 commit comments