Skip to content

Conversation

@pcj
Copy link
Contributor

@pcj pcj commented Dec 18, 2025

This PR adds the necessary infrastructure to publish protobuf-javascript to the Bazel Central Registry (BCR), making it easier for Bazel users to consume this module via Bzlmod.

Changes

BCR Configuration:

  • Add .bcr/ directory with BCR metadata templates and configuration
    • metadata.template.json - Module metadata for BCR
    • source.template.json - Source archive configuration
    • presubmit.yml - BCR presubmit validation rules
    • patches/remove-dist.patch - Patch to remove distribution rules (and dev dependencies) from BCR releases

End-to-End Testing:

  • Add e2e/bcr/ test suite to validate BCR integration
    • Test proto code generation with protoc-gen-js
    • Verify JavaScript runtime files are accessible
    • Test scripts to validate generated outputs

Dependencies:

  • Add rules_cc to MODULE.bazel for C++ build support
  • Update MODULE.bazel with proper dependency ordering

Testing

The BCR integration can be tested by running:

(cd e2e/bcr && bazel test //...)

followup to #261

pcj added 5 commits December 17, 2025 15:21
Replaces the Node.js-based generate-version-header.js script with a C++
implementation to eliminate the Node.js runtime dependency from the build
process. The new C++ tool reads package.json and generates the same
version.h header file.

Also fixes Closure Compiler errors under strict mode in
extension_field_binary_info.js and map.js by properly assigning
goog.requireType calls to const variables instead of using standalone
goog.requireType calls.

Changes:
- Add generator/generate-version-header.cc with C++ implementation
- Remove generate-version-header.js
- Update generator/BUILD.bazel to use cc_binary instead of Node.js script
- Add rules_cc dependency to MODULE.bazel
- Update BUILD.bazel to remove deleted script from exports_files
- Fix goog.requireType usage in extension_field_binary_info.js and map.js
@pcj
Copy link
Contributor Author

pcj commented Dec 18, 2025

Claude:

Setup Instructions for BCR Publishing

To enable automated publishing to BCR, you'll need to set up a BCR_PUBLISH_TOKEN:

Generate the Token

  1. Create the token:

    • Go to https://github.com/settings/tokens
    • Click "Generate new token" → "Generate new token (classic)"
    • Give it a name like "BCR Publish Token"
    • Select scopes:
      • repo (Full control of private repositories)
      • workflow (Update GitHub Action workflows)
    • Click "Generate token"
    • Copy the token immediately (you won't see it again)
  2. Add to repository:

    • Go to your repo: Settings → Secrets and variables → Actions
    • Click "New repository secret"
    • Name: BCR_PUBLISH_TOKEN
    • Value: paste the token you copied
    • Click "Add secret"

Note: You must use a Classic PAT (not fine-grained) because fine-grained PATs can't currently open pull requests against public repositories like bazel-central-registry.

@dibenede dibenede self-requested a review December 18, 2025 08:58
Copy link
Contributor

@dibenede dibenede left a comment

Choose a reason for hiding this comment

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

This is great. Thank you for putting this together.

"email": "dibenede@google.com",
"github": "dibenede"
},
{
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't mean to discredit your excellent work, but I don't think we can have non-Google employees on here for security reasons. Reading https://github.com/bazelbuild/bazel-central-registry/blob/main/docs/README.md#approval-and-submission , it sounds like this list grants access to certain BCR approval powers.

I'm happy to credit your work in a different way if you'd like. We probably overdue for some special call outs in a contributors file of some kind.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I was going to mention this in the PR... I don't really care about being attributed in the BCR as a maintainer, but I put it in there in case it would be helpful. Will remove.

Copy link
Contributor

@dibenede dibenede left a comment

Choose a reason for hiding this comment

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

(selected wrong option, meant request changes)

@pcj
Copy link
Contributor Author

pcj commented Dec 18, 2025

Comments addressed. At this point in my own projects I do:

  1. Setup the BCR_PUBLISH_TOKEN in the repository secrets (see above).
  2. Something like git tag v4.0.2 && git push origin v4.0.2 (not sure how this relates to current release process)
  3. Monitor github release action. I can f/u if there are errors.
  4. Await new (auto-generated) PR at https://github.com/bazelbuild/bazel-central-registry/pulls. As a new module it would need a BCR maintainer to approve CI to start (I can ping someone on bazel slack #bzlmod channel). Subsequent releases get auto-merged if CI passes.
  5. Might be (likely) some additional tweaks required to make bazel presumit CI happy.

LMK if I can assist.

@dibenede dibenede merged commit ed7064f into protocolbuffers:main Dec 19, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants