1+ # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+ name : Publish npm packages
4+
5+ on :
6+ workflow_dispatch :
7+ inputs :
8+ version :
9+ description : ' Version to publish (e.g., 0.2.0)'
10+ required : true
11+ type : string
12+ dry-run :
13+ description : ' Dry run (skip actual publish)'
14+ required : false
15+ type : boolean
16+ default : false
17+ # IMPORTANT: Trusted publishing (OIDC) is configured on npmjs.com with
18+ # workflow filename 'CreateRelease.yml'. npm checks the *calling* workflow
19+ # for workflow_call, not the reusable workflow that runs npm publish.
20+ # Calling this workflow from a different parent workflow will fail OIDC auth.
21+ # See: https://docs.npmjs.com/trusted-publishers#troubleshooting
22+ workflow_call :
23+ inputs :
24+ version :
25+ description : ' Version to publish'
26+ required : true
27+ type : string
28+ dry-run :
29+ description : ' Dry run (skip actual publish)'
30+ required : false
31+ type : boolean
32+ default : true
33+
34+ permissions :
35+ contents : read
36+ id-token : write
37+
38+ jobs :
39+ publish-hyperlight-packages :
40+ runs-on : ubuntu-latest
41+
42+ steps :
43+ - uses : actions/checkout@v6
44+ with :
45+ fetch-depth : 0
46+ fetch-tags : true
47+
48+ # Ensures just is installed using setup wokflow to ensure just version consistency
49+ - name : Hyperlight setup
50+ uses : hyperlight-dev/ci-setup-workflow@v1.9.0
51+ with :
52+ rust-toolchain : " 1.90"
53+ just-version : " 1.51"
54+
55+ - name : Install cargo-overlay-registry
56+ run : cargo install cargo-overlay-registry
57+
58+ - name : Determine which crates need publishing
59+ env :
60+ VERSION : ${{ inputs.version }}
61+ shell : bash
62+ run : |
63+ needs_publish() {
64+ local crate=$1
65+ local crate_env_var=$(echo "$crate" | tr '[:lower:]' '[:upper:]' | tr '-' '_')
66+
67+ if [ -z "$VERSION" ] || [ "$VERSION" == "v0.0.0" ] || [ "$VERSION" == "0.0.0" ]; then
68+ echo "No version set (dry run?), skipping crates.io existence checks."
69+ echo "PUBLISH_${crate_env_var}=true" >> "$GITHUB_ENV"
70+ return
71+ fi
72+
73+ if curl -s "https://crates.io/api/v1/crates/$crate/$VERSION" | jq -e .version > /dev/null; then
74+ echo "PUBLISH_${crate_env_var}=false" >> "$GITHUB_ENV"
75+ echo "✅ $crate@$VERSION already exists."
76+ else
77+ echo "PUBLISH_${crate_env_var}=true" >> "$GITHUB_ENV"
78+ echo "🚀 $crate@$VERSION will be published."
79+ fi
80+ }
81+
82+ needs_publish hyperlight-js-runtime
83+ needs_publish hyperlight-js
84+
85+ - name : Dry run publishing
86+ shell : bash
87+ run : |
88+ cargo-overlay-registry \
89+ -r local \
90+ -r local=./target/package/tmp-registry/ \
91+ -r crates.io \
92+ -- \
93+ cargo publish --workspace --dry-run \
94+ -p hyperlight-js \
95+ -p hyperlight-js-runtime
96+
97+ - name : Authenticate with crates.io
98+ uses : rust-lang/crates-io-auth-action@v1
99+ id : crates-io-auth
100+
101+ - name : Publish hyperlight-js-runtime
102+ run : cargo publish -p hyperlight-js-runtime
103+ env :
104+ CARGO_REGISTRY_TOKEN : ${{ steps.crates-io-auth.outputs.token }}
105+ if : ${{ env.PUBLISH_HYPERLIGHT_JS_RUNTIME != 'false' && !inputs['dry-run'] }}
106+
107+ - name : Publish hyperlight-js
108+ run : cargo publish -p hyperlight-js
109+ env :
110+ CARGO_REGISTRY_TOKEN : ${{ steps.crates-io-auth.outputs.token }}
111+ if : ${{ env.PUBLISH_HYPERLIGHT_JS != 'false' && !inputs['dry-run'] }}
0 commit comments