From 65bb1f9febc005fba38196c48e6091a3ebee6153 Mon Sep 17 00:00:00 2001 From: Fernando Alonso Pecina Date: Mon, 26 Oct 2026 02:21:51 +0000 Subject: [PATCH 1/7] ci(wbn-sign): add OSS Exit Gate npm publishing workflow Signed-off-by: Fernando Alonso Pecina --- .github/workflows/publish-npm.yml | 65 +++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/publish-npm.yml diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 00000000..8e8667ec --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,65 @@ +name: Publish wbn-sign to npm via OSS Exit Gate + +on: + release: + types: [published] + workflow_dispatch: + +permissions: + contents: read + +jobs: + publish: + runs-on: ubuntu-latest + defaults: + run: + working-directory: js/sign + permissions: + contents: read + id-token: write + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Use Node.js 22.x + uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 + with: + node-version: '22.x' + cache: 'npm' + cache-dependency-path: js/sign/package-lock.json + + - name: Install dependencies, build, and test + run: | + npm ci + npm run build + npm test + + - name: Authenticate to Google Cloud for OSS Exit Gate + id: auth + uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3 + with: + token_format: 'access_token' + workload_identity_provider: 'projects/305452601764/locations/global/workloadIdentityPools/builders/providers/github' + + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db # v3 + + - name: Stage to Artifact Registry and trigger OSS Exit Gate + env: + ACCESS_TOKEN: ${{ steps.auth.outputs.access_token }} + RUN_ID: ${{ github.run_id }} + RUN_ATTEMPT: ${{ github.run_attempt }} + run: | + cat << 'NPMRC' > "$HOME/.npmrc" + registry=https://us-npm.pkg.dev/oss-exit-gate-prod/webpackage--npm/ + //us-npm.pkg.dev/oss-exit-gate-prod/webpackage--npm/:always-auth=true + //us-npm.pkg.dev/oss-exit-gate-prod/webpackage--npm/:_authToken=${ACCESS_TOKEN} + NPMRC + trap 'rm -f "$HOME/.npmrc"' EXIT + npm publish --access public --registry="https://us-npm.pkg.dev/oss-exit-gate-prod/webpackage--npm/" + cat << 'MANIFEST' > manifest.json + { + "publish_all": true + } + MANIFEST + gcloud storage cp manifest.json "gs://oss-exit-gate-prod-projects-bucket/webpackage/npm/manifests/manifest-${RUN_ID}-${RUN_ATTEMPT}.json" From 4fa19f742d4785a9ccbb484c588d46cb7a87cfd0 Mon Sep 17 00:00:00 2001 From: Fernando Alonso Pecina Date: Tue, 27 Oct 2026 17:52:16 +0000 Subject: [PATCH 2/7] ci(wbn-sign): update Node.js version to 24.x per review feedback Signed-off-by: Fernando Alonso Pecina --- .github/workflows/publish-npm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 8e8667ec..839bdc44 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -21,10 +21,10 @@ jobs: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Use Node.js 22.x + - name: Use Node.js 24.x uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 with: - node-version: '22.x' + node-version: '24.x' cache: 'npm' cache-dependency-path: js/sign/package-lock.json From 8bce8f732d076e06698e20f7afacf2b29c61f576 Mon Sep 17 00:00:00 2001 From: alonsopf89 Date: Tue, 27 Oct 2026 19:57:21 +0000 Subject: [PATCH 3/7] fix(ci): use direct WIF auth_token without service_account --- .github/workflows/publish-npm.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 839bdc44..194b3fec 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -38,7 +38,6 @@ jobs: id: auth uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3 with: - token_format: 'access_token' workload_identity_provider: 'projects/305452601764/locations/global/workloadIdentityPools/builders/providers/github' - name: Set up Cloud SDK @@ -46,7 +45,7 @@ jobs: - name: Stage to Artifact Registry and trigger OSS Exit Gate env: - ACCESS_TOKEN: ${{ steps.auth.outputs.access_token }} + ACCESS_TOKEN: ${{ steps.auth.outputs.auth_token }} RUN_ID: ${{ github.run_id }} RUN_ATTEMPT: ${{ github.run_attempt }} run: | From 09604a1429d2036d570bec174c11a067b7e20147 Mon Sep 17 00:00:00 2001 From: Fernando Alonso Date: Thu, 29 Oct 2026 16:16:54 +0000 Subject: [PATCH 4/7] ci(npm): use manual workflow_dispatch per package, targeted manifest, dry_run, and AR cleanup --- .github/workflows/publish-npm.yml | 89 ++++++++++++++++++++++++++----- js/CONTRIBUTING.md | 9 ++++ 2 files changed, 86 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 194b3fec..4c8c1b2b 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -1,9 +1,34 @@ -name: Publish wbn-sign to npm via OSS Exit Gate +# Publishes `wbn` (js/bundle) or `wbn-sign` (js/sign) to npm via Google's +# OSS Exit Gate pipeline. +# +# How to use: +# 1. Bump the `version` in `js/bundle/package.json` (for `wbn`) or +# `js/sign/package.json` (for `wbn-sign`) and merge to `main`. +# 2. Go to Actions -> "Publish to npm via OSS Exit Gate" -> "Run workflow" +# on the `main` branch. +# 3. Select the `package` (`wbn-sign` or `wbn`). +# 4. Set `dry_run` to `true` to test building, WIF authentication, and staging +# to Artifact Registry without publishing to public npm, or `false` to +# trigger the actual public release on npmjs.com. + +name: Publish to npm via OSS Exit Gate on: - release: - types: [published] workflow_dispatch: + inputs: + package: + description: 'Package to publish (wbn-sign or wbn)' + required: true + type: choice + default: 'wbn-sign' + options: + - wbn-sign + - wbn + dry_run: + description: 'Dry run: stage to Artifact Registry to test auth/build, then clean up without publishing to public npm' + required: false + type: boolean + default: false permissions: contents: read @@ -11,12 +36,13 @@ permissions: jobs: publish: runs-on: ubuntu-latest - defaults: - run: - working-directory: js/sign permissions: contents: read id-token: write + env: + PACKAGE_NAME: ${{ inputs.package }} + PACKAGE_DIR: ${{ inputs.package == 'wbn' && 'js/bundle' || 'js/sign' }} + DRY_RUN: ${{ inputs.dry_run }} steps: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -26,9 +52,10 @@ jobs: with: node-version: '24.x' cache: 'npm' - cache-dependency-path: js/sign/package-lock.json + cache-dependency-path: ${{ env.PACKAGE_DIR }}/package-lock.json - - name: Install dependencies, build, and test + - name: Install dependencies, build, and test (${{ inputs.package }}) + working-directory: ${{ env.PACKAGE_DIR }} run: | npm ci npm run build @@ -44,21 +71,59 @@ jobs: uses: google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db # v3 - name: Stage to Artifact Registry and trigger OSS Exit Gate + working-directory: ${{ env.PACKAGE_DIR }} env: ACCESS_TOKEN: ${{ steps.auth.outputs.auth_token }} RUN_ID: ${{ github.run_id }} RUN_ATTEMPT: ${{ github.run_attempt }} run: | + PKG_VERSION=$(node -p "require('./package.json').version") + echo "Preparing ${PACKAGE_NAME}@${PKG_VERSION} (DRY_RUN=${DRY_RUN})..." + + # Clean any prior staged package entry in Artifact Registry so retries + # for the same version do not fail on AR npm version tombstones. + gcloud artifacts packages delete "${PACKAGE_NAME}" \ + --project=oss-exit-gate-prod \ + --repository=webpackage--npm \ + --location=us \ + --quiet || true + cat << 'NPMRC' > "$HOME/.npmrc" registry=https://us-npm.pkg.dev/oss-exit-gate-prod/webpackage--npm/ //us-npm.pkg.dev/oss-exit-gate-prod/webpackage--npm/:always-auth=true - //us-npm.pkg.dev/oss-exit-gate-prod/webpackage--npm/:_authToken=${ACCESS_TOKEN} NPMRC + echo "//us-npm.pkg.dev/oss-exit-gate-prod/webpackage--npm/:_authToken=${ACCESS_TOKEN}" >> "$HOME/.npmrc" trap 'rm -f "$HOME/.npmrc"' EXIT + npm publish --access public --registry="https://us-npm.pkg.dev/oss-exit-gate-prod/webpackage--npm/" - cat << 'MANIFEST' > manifest.json + + cat << MANIFEST > manifest.json { - "publish_all": true + "publish_all": false, + "publishing_groups": [ + { + "packages": [ + { + "name": "${PACKAGE_NAME}", + "version": "${PKG_VERSION}" + } + ] + } + ] } MANIFEST - gcloud storage cp manifest.json "gs://oss-exit-gate-prod-projects-bucket/webpackage/npm/manifests/manifest-${RUN_ID}-${RUN_ATTEMPT}.json" + + echo "Generated manifest.json:" + cat manifest.json + + if [[ "${DRY_RUN}" == "true" ]]; then + echo "Dry run enabled: skipping GCS manifest upload to OSS Exit Gate and cleaning up staged package." + gcloud artifacts packages delete "${PACKAGE_NAME}" \ + --project=oss-exit-gate-prod \ + --repository=webpackage--npm \ + --location=us \ + --quiet || true + exit 0 + fi + + gcloud storage cp manifest.json "gs://oss-exit-gate-prod-projects-bucket/webpackage/npm/manifests/manifest-${PACKAGE_NAME}-${PKG_VERSION}-${RUN_ID}-${RUN_ATTEMPT}.json" diff --git a/js/CONTRIBUTING.md b/js/CONTRIBUTING.md index 8ed987b9..402a858a 100644 --- a/js/CONTRIBUTING.md +++ b/js/CONTRIBUTING.md @@ -20,3 +20,12 @@ extension and then in VScode's settings have the following entries: "editor.defaultFormatter": "esbenp.prettier-vscode" } ``` + +## Publishing `wbn` and `wbn-sign` to npm + +Both `wbn` (`js/bundle`) and `wbn-sign` (`js/sign`) are published independently via the [`.github/workflows/publish-npm.yml`](../.github/workflows/publish-npm.yml) GitHub Actions workflow using Google's OSS Exit Gate pipeline: + +1. Update the `"version"` field in `js/bundle/package.json` (for `wbn`) or `js/sign/package.json` (for `wbn-sign`) and merge the PR into `main`. +2. In GitHub, navigate to **Actions** -> **Publish to npm via OSS Exit Gate** -> **Run workflow** (on the `main` branch). +3. Select the target **`package`** (`wbn-sign` or `wbn`). +4. *(Optional)* Check **`dry_run`** to verify building, testing, Workload Identity Federation authentication, and staging to Artifact Registry without publishing to public npm. Leave `dry_run` unchecked to publish the release to npmjs.com. From 3fc300dc898423354de97676106aea74d9e98618 Mon Sep 17 00:00:00 2001 From: alonsopf89 Date: Wed, 4 Nov 2026 11:34:44 -0800 Subject: [PATCH 5/7] ci: clean up stale releases from staging repo before publishing --- .github/workflows/publish-npm.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 4c8c1b2b..20d44999 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -70,6 +70,25 @@ jobs: - name: Set up Cloud SDK uses: google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db # v3 + - name: Clean up stale releases from staging repo + run: | + # clean up stale releases from staging repo + packages=$(gcloud artifacts packages list \ + --project="oss-exit-gate-prod" \ + --location="us" \ + --repository="webpackage--npm" \ + --format="value(name)" 2>/dev/null) + + echo "${packages}" | xargs -r -I {} sh -c ' + package_name=$(basename "{}") + echo "Deleting package: $package_name..." + gcloud artifacts packages delete "{}" \ + --project="\'"oss-exit-gate-prod"\'" \ + --location="\'"us"\'" \ + --repository="\'webpackage--npm\'" \ + --quiet + ' + - name: Stage to Artifact Registry and trigger OSS Exit Gate working-directory: ${{ env.PACKAGE_DIR }} env: From 959faa225d58f941135a47ff8df294875a7c2d17 Mon Sep 17 00:00:00 2001 From: alonsopf89 Date: Wed, 4 Nov 2026 21:40:07 +0000 Subject: [PATCH 6/7] ci(release): fix quote syntax in stale release cleanup step --- .github/workflows/publish-npm.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 20d44999..10331981 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -83,9 +83,9 @@ jobs: package_name=$(basename "{}") echo "Deleting package: $package_name..." gcloud artifacts packages delete "{}" \ - --project="\'"oss-exit-gate-prod"\'" \ - --location="\'"us"\'" \ - --repository="\'webpackage--npm\'" \ + --project=""oss-exit-gate-prod"" \ + --location=""us"" \ + --repository="webpackage--npm" \ --quiet ' From f209f0fe08f37012fb2e909e38abd8672dcd30e5 Mon Sep 17 00:00:00 2001 From: alonsopf89 Date: Wed, 4 Nov 2026 19:57:40 -0800 Subject: [PATCH 7/7] ci: fix quote syntax in staging repo cleanup step --- .github/workflows/publish-npm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 10331981..84336370 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -83,8 +83,8 @@ jobs: package_name=$(basename "{}") echo "Deleting package: $package_name..." gcloud artifacts packages delete "{}" \ - --project=""oss-exit-gate-prod"" \ - --location=""us"" \ + --project="oss-exit-gate-prod" \ + --location="us" \ --repository="webpackage--npm" \ --quiet '