Repository navigation
ci(release): migrate npm publishing to OSS Exit Gate - #3294
alonsopf89 wants to merge 7 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request updates the package publishing script .github/scripts/publish_package.sh to use Google Artifact Registry, configures authentication, and uploads a generated deployment manifest to Google Cloud Storage. The review feedback highlights two important issues: first, running npx to authenticate may fail because the private registry is configured before authentication is established, which can be resolved by explicitly specifying the public npm registry; second, a defensive check for the VERSION environment variable should be added to prevent script crashes under set -u.
| registry=https://us-npm.pkg.dev/oss-exit-gate-prod/firebase-admin-node--npm/ | ||
| //us-npm.pkg.dev/oss-exit-gate-prod/firebase-admin-node--npm/:always-auth=true | ||
| NPMRC_EOF | ||
| npx --yes google-artifactregistry-auth --repo-config=.npmrc --credential-config="$HOME/.npmrc" |
There was a problem hiding this comment.
Since .npmrc is configured to use the private Artifact Registry (https://us-npm.pkg.dev/...) and requires authentication (always-auth=true), running npx --yes google-artifactregistry-auth will attempt to fetch the google-artifactregistry-auth package from this private registry. However, because authentication has not yet been configured (which is the purpose of running this tool), the command will fail with a 401 Unauthorized or 403 Forbidden error.\n\nTo resolve this chicken-and-egg problem, explicitly specify the public npm registry when running npx using the --registry flag.
| npx --yes google-artifactregistry-auth --repo-config=.npmrc --credential-config="$HOME/.npmrc" | |
| npx --yes --registry=https://registry.npmjs.org/ google-artifactregistry-auth --repo-config=.npmrc --credential-config="$HOME/.npmrc" |
There was a problem hiding this comment.
Fixed! Added --registry=https://registry.npmjs.org/ to the npx invocation so google-artifactregistry-auth is fetched from the public npm registry prior to authenticating against the private Artifact Registry.
|
|
||
| readonly UNPREFIXED_VERSION=`echo ${VERSION} | cut -c 2-` | ||
| npm publish ./dist/firebase-admin-${UNPREFIXED_VERSION}.tgz --registry https://wombat-dressing-room.appspot.com | ||
| readonly UNPREFIXED_VERSION=$(echo "${VERSION}" | cut -c 2-) |
There was a problem hiding this comment.
Since set -u is enabled, referencing the VERSION environment variable when it is not set will cause the script to crash immediately with an unbound variable error. Adding a defensive check ensures a clear, actionable error message is printed if the variable is missing.
| readonly UNPREFIXED_VERSION=$(echo "${VERSION}" | cut -c 2-) | |
| if [ -z "${VERSION:-}" ]; then\n echo "Error: VERSION environment variable is not set." >&2\n exit 1\nfi\nreadonly UNPREFIXED_VERSION=$(echo "${VERSION}" | cut -c 2-) |
There was a problem hiding this comment.
Fixed! Added the defensive check for ${VERSION:-} before computing UNPREFIXED_VERSION.
dacf87a to
e14e5b7
Compare
e14e5b7 to
d51e3b6
Compare
lahirumaramba
left a comment
There was a problem hiding this comment.
Thanks for migrating this! Overall LGTM! Added one small comment below. Let's hold off on merging until the companion configuration updates are rolled out.
|
|
||
| gcloud storage cp --if-generation-match=0 \ | ||
| "${MANIFEST_PATH}" \ | ||
| "${MANIFEST_BUCKET}/manifest-${RUN_ID}-${RUN_ATTEMPT}.json" |
There was a problem hiding this comment.
nit: Since publishing now finishes asynchronously after the manifest is uploaded, could we echo a brief status message here noting that the release manifest was uploaded and publication will complete asynchronously? Not a blocker, just helps avoid confusion when checking npm right after the workflow turns green.
There was a problem hiding this comment.
Done! Added a brief echo after the manifest upload noting that npm publication will complete asynchronously.
Summary
Migrates
firebase-adminnpm publishing in.github/workflows/release.ymland.github/scripts/publish_package.shfrom legacy Wombat Dressing Room (wombat-dressing-room.appspot.com) to the Google OSS Exit Gate pipeline (firebase-admin-node/npm), coordinated with @DellaBitta.Changes
npm packbefore cloud authentication and inspects the.tgzentries so temporary credential files (gha-creds-*.json,.npmrc, ormanifest.json) are never packed.google-github-actions/auth) with SHA-pinned actions instead of a staticNPM_AUTH_TOKENsecret.umask 077.npmrcunder${RUNNER_TEMP}(cleaned up onEXIT) and version-scopedgcloud artifacts versions delete --delete-tagscleanup.firebase-admin-${UNPREFIXED_VERSION}.tgzto Artifact Registry (https://us-npm.pkg.dev/oss-exit-gate-prod/firebase-admin-node--npm/).publish_all: false) to trigger automated security scanning and publication to npmjs.org.Rollout Notes
Because
firebase-adminpublishes through the shared OSS Exit Gate npm credential, no manual npm token setup or rotation is required. Once the companion OSS Exit Gate configuration updates and this PR are merged, the nextrelease.ymlrun will scan and publish the package to npmjs.org automatically.Verification
firebase-admin@14.5.0,publish_all: false) verified againstfirebase-admin-node--npm.zizmor,Wiz,check-changes, andcla/google).