66 tag :
77 description : ' Tag to publish to NPM'
88 required : true
9- default : ' 0 .1.0-alpha.9'
9+ default : ' v0 .1.0-alpha.9'
1010
1111jobs :
1212 release :
1313 runs-on : ubuntu-latest
14+ env :
15+ GH_TOKEN : ${{ github.token }}
1416
1517 steps :
16- - name : Download build artifacts
17- uses : actions/download-artifact@v4
18- with :
19- name : ${{ github.event.inputs.tag }}-tlsn-wasm-pkg
20- path : tlsn-wasm-pkg
21-
22- - name : NPM Publish for tlsn-wasm
23- env :
24- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
25- run : |
26- cd tlsn-wasm-pkg
27- npm publish
18+ - name : Find and download tlsn-wasm build from the tagged ci workflow
19+ id : find_run
20+ run : |
21+ # Find the workflow run ID for the tag
22+ RUN_ID=$(gh api \
23+ -H "Accept: application/vnd.github+json" \
24+ "/repos/tlsnotary/tlsn/actions/workflows/ci.yml/runs?per_page=100" \
25+ --jq '.workflow_runs[] | select(.head_branch == "${{ github.event.inputs.tag }}") | .id')
26+
27+ if [ -z "$RUN_ID" ]; then
28+ echo "No run found for tag ${{ github.event.inputs.tag }}"
29+ exit 1
30+ fi
31+
32+ echo "Found run: $RUN_ID"
33+ echo "run_id=$RUN_ID" >> "$GITHUB_OUTPUT"
34+
35+ # Find the download URL for the build artifact
36+ DOWNLOAD_URL=$(gh api \
37+ -H "Accept: application/vnd.github+json" \
38+ /repos/tlsnotary/tlsn/actions/runs/${RUN_ID}/artifacts \
39+ --jq '.artifacts[] | select(.name == "${{ github.event.inputs.tag }}-tlsn-wasm-pkg") | .archive_download_url')
40+
41+ if [ -z "$DOWNLOAD_URL" ]; then
42+ echo "No download url for build artifact ${{ github.event.inputs.tag }}-tlsn-wasm-pkg in run $RUN_ID"
43+ exit 1
44+ fi
45+
46+ # Download and unzip the build artifact
47+ mkdir tlsn-wasm-pkg
48+ curl -L -H "Authorization: Bearer ${GH_TOKEN}" \
49+ -H "Accept: application/vnd.github+json" \
50+ -o tlsn-wasm-pkg.zip \
51+ ${DOWNLOAD_URL}
52+ unzip -q tlsn-wasm-pkg.zip -d tlsn-wasm-pkg
53+
54+
55+ - name : NPM Publish for tlsn-wasm
56+ env :
57+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
58+ run : |
59+ cd tlsn-wasm-pkg
60+ echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > .npmrc
61+ npm publish
62+ rm .npmrc
0 commit comments