mirror of
https://github.com/tlsnotary/tlsn.git
synced 2026-01-10 07:07:57 -05:00
63 lines
2.0 KiB
YAML
63 lines
2.0 KiB
YAML
name: Publish tlsn-wasm to NPM
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: 'Tag to publish to NPM'
|
|
required: true
|
|
default: 'v0.1.0-alpha.13-pre'
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
|
|
steps:
|
|
- name: Find and download tlsn-wasm build from the tagged ci workflow
|
|
id: find_run
|
|
run: |
|
|
# Find the workflow run ID for the tag
|
|
RUN_ID=$(gh api \
|
|
-H "Accept: application/vnd.github+json" \
|
|
"/repos/tlsnotary/tlsn/actions/workflows/ci.yml/runs?per_page=100" \
|
|
--jq '.workflow_runs[] | select(.head_branch == "${{ github.event.inputs.tag }}") | .id' | sort | tail -1)
|
|
|
|
if [ -z "$RUN_ID" ]; then
|
|
echo "No run found for tag ${{ github.event.inputs.tag }}"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Found run: $RUN_ID"
|
|
echo "run_id=$RUN_ID" >> "$GITHUB_OUTPUT"
|
|
|
|
# Find the download URL for the build artifact
|
|
DOWNLOAD_URL=$(gh api \
|
|
-H "Accept: application/vnd.github+json" \
|
|
/repos/tlsnotary/tlsn/actions/runs/${RUN_ID}/artifacts \
|
|
--jq '.artifacts[] | select(.name == "${{ github.event.inputs.tag }}-tlsn-wasm-pkg") | .archive_download_url')
|
|
|
|
if [ -z "$DOWNLOAD_URL" ]; then
|
|
echo "No download url for build artifact ${{ github.event.inputs.tag }}-tlsn-wasm-pkg in run $RUN_ID"
|
|
exit 1
|
|
fi
|
|
|
|
# Download and unzip the build artifact
|
|
mkdir tlsn-wasm-pkg
|
|
curl -L -H "Authorization: Bearer ${GH_TOKEN}" \
|
|
-H "Accept: application/vnd.github+json" \
|
|
-o tlsn-wasm-pkg.zip \
|
|
${DOWNLOAD_URL}
|
|
unzip -q tlsn-wasm-pkg.zip -d tlsn-wasm-pkg
|
|
|
|
|
|
- name: NPM Publish for tlsn-wasm
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
run: |
|
|
cd tlsn-wasm-pkg
|
|
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > .npmrc
|
|
npm publish
|
|
rm .npmrc
|