Skip to content

Propagate release GPG key lookup failures - #31306

Closed
gztong666 wants to merge 3 commits into
bazelbuild:masterfrom
gztong666:fix/release-gpg-key-lookup
Closed

gztong666 wants to merge 3 commits into
bazelbuild:masterfrom
gztong666:fix/release-gpg-key-lookup

Conversation

@gztong666

@gztong666 gztong666 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

Assign APT_GPG_KEY_ID before exporting it so that set -e observes a failed Secret Manager lookup.

Motivation

export APT_GPG_KEY_ID=$(...) reports the status of the export builtin, which can mask a nonzero exit from gcloud. The release script can therefore continue with an empty key ID after a permissions, network, or Secret Manager failure.

The separate assignment returns gcloud's status and stops the script immediately.

Testing

Verified with a fake gcloud returning a nonzero status that the original form continues and the updated form exits before subsequent release setup.

Build API Changes

No

Checklist

  • I have added tests for the new use cases (manual regression test; this release helper has no unit-test target).
  • I have updated the documentation (not applicable).

Release Notes

RELNOTES: None

Related issue

Fixes #31337

@github-actions github-actions Bot added the awaiting-review PR is awaiting review from an assigned reviewer label Sep 24, 2026
@iancha1992 iancha1992 added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Sep 28, 2026
@gztong666

gztong666 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author

@bazelbuild/triage Hi, this PR is ready for review and linked to its tracking issue. Could you please help route it to an appropriate reviewer when time permits? Thank you.

I missed the 7-business-day guidance when I posted this. Sorry for the premature ping; I'll wait until the recommended time.

Comment thread scripts/ci/build.sh Outdated
# fi

export APT_GPG_KEY_ID=$(gcloud secrets versions access latest --secret="release-key-gpg-id" --project="bazel-public")
APT_GPG_KEY_ID=$(gcloud secrets versions access latest --secret="release-key-gpg-id" --project="bazel-public")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making this fail at top-level will break anyone sourcing scripts/ci/build.sh (e.g. for bazel_build) without bazel-public Secret Manager permissions.

Please resolve APT_GPG_KEY_ID lazily inside ensure_gpg_secret_key_imported() instead (similar to how github_token is fetched in bazel_release on line 153), e.g.:

if [[ -z "${APT_GPG_KEY_ID:-}" ]]; then
  APT_GPG_KEY_ID="$(gcloud secrets versions access latest --secret="release-key-gpg-id" --project="bazel-public")"
  export APT_GPG_KEY_ID
fi

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — addressed in 3d938f9. APT_GPG_KEY_ID is now resolved lazily inside ensure_gpg_secret_key_imported() only when it is unset, and it is exported after the Secret Manager lookup succeeds. Sourcing scripts/ci/build.sh no longer requires access to the bazel-public secret.

@gztong666
gztong666 requested a review from meisterT October 11, 2026 03:03
@meisterT meisterT added copybara:import Trigger copybara to import the PR and removed awaiting-review PR is awaiting review from an assigned reviewer labels Nov 2, 2026
@copybara-service copybara-service Bot closed this in 3a1de6e Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copybara:import Trigger copybara to import the PR team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Release setup can continue after the GPG key lookup fails

3 participants