### Publish multiple modules with module_roots and tag_prefix Source: https://github.com/bazel-contrib/publish-to-bcr/blob/main/README.md Use this workflow to publish multiple modules from the same repository when they are versioned separately on different tags. Set `tag_prefix` to match the release tagging scheme (defaults to "v") and provide `module_roots` to override which modules get published. The example shows a job that triggers only when the release tag starts with "foobar-v" and publishes modules rooted at `./foo` and `./bar`. ```yaml jobs: publish-foobar: if: startsWith(inputs.tag_name, "foobar-v") uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@[version] with: ... tag_prefix: foobar-v # e.g., for tag foobar-v1.2.3 module_roots: | # only publish modules rooted at ./foo and ./bar foo bar ``` -------------------------------- ### Build and verify xzdec.wasm.gz with Bazel Source: https://github.com/bazel-contrib/publish-to-bcr/blob/main/src/infrastructure/xzdec/README.md Run from src/infrastructure/xzdec. Builds the optimized WebAssembly module and compares the generated artifact with the checked-in file. The diff output confirms they are identical. ```bash $ cd src/infrastructure/xzdec $ bazel build -c opt //:xzdec_wasm_gz $ diff -s xzdec.wasm.gz bazel-bin/xzdec_wasm_gz/xzdec.wasm.gz Files xzdec.wasm.gz and bazel-bin/xzdec_wasm_gz/xzdec.wasm.gz are identical $ ``` -------------------------------- ### source.template.json - BCR source template Source: https://github.com/bazel-contrib/publish-to-bcr/blob/main/templates/README.md Template for the BCR source file. Values for {REPO}, {VERSION}, {OWNER}, and {TAG} are substituted automatically. Check that strip_prefix and url match your release archive format; use {REPO}-{VERSION} for GitHub-generated archives or an empty string if no prefix is stripped. The integrity hash is filled automatically. ```jsonc { "integrity": "", // <-- Leave this alone "strip_prefix": "{REPO}-{VERSION}", "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz" } ``` -------------------------------- ### Reference the reusable publish workflow in a publish job Source: https://github.com/bazel-contrib/publish-to-bcr/blob/main/README.md References the reusable publish workflow in a job. Replace the [version] placeholder with the desired version. The registry_fork input must be set to your fork of bazel-central-registry. The attest input enables attestation support; when true, the id-token and attestations permissions are required. The publish_token secret must contain a PAT with workflow and repo permissions. ```yaml jobs: publish: uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@[version] with: tag_name: ${{ inputs.tag_name }} # GitHub repository which is a fork of the upstream where the Pull Request will be opened. registry_fork: my-org/bazel-central-registry # see note on Attestation Support attest: true permissions: contents: write # Necessary if attest:true id-token: write # Necessary if attest:true attestations: write secrets: # Necessary to push to the BCR fork, and to open a pull request against a registry publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }} ``` -------------------------------- ### presubmit.yml - BCR presubmit configuration Source: https://github.com/bazel-contrib/publish-to-bcr/blob/main/templates/README.md Presubmit configuration for BCR CI. Use this file or replace it with your own; it must define essential build and test targets. The bazel version must be specified for all tasks. The tasks run on the BCR's CI pipelines, and it is recommended to use a test workspace that exercises your module with bzlmod. ```yaml bcr_test_module: module_path: "e2e/bzlmod" matrix: platform: ["debian10", "macos", "ubuntu2004", "windows"] bazel: [6.x, 7.x] tasks: run_tests: name: "Run test module" platform: ${{ platform }} bazel: ${{ bazel }} test_targets: - "//..." ``` -------------------------------- ### config.yml - Optional BCR module roots configuration Source: https://github.com/bazel-contrib/publish-to-bcr/blob/main/templates/README.md Optional configuration file to override default BCR behavior. Set moduleRoots to a list of relative paths to Bazel modules if your MODULE.bazel is not in the root or you publish multiple modules. Defaults to ["."]; each module root must have corresponding template files under .bcr with the same relative path. ```yaml moduleRoots: ["."] ``` -------------------------------- ### metadata.template.json - BCR metadata template Source: https://github.com/bazel-contrib/publish-to-bcr/blob/main/templates/README.md Required template for the BCR metadata file. Edit the homepage, maintainer details, and repository fields; replace OWNER and REPO with your canonical repository name. Leave versions and yanked_versions as-is because they are filled automatically. Maintainers will be emailed if a release fails. ```jsonc { "homepage": "YOUR_HOMEPAGE", // <-- Edit this "maintainers": [ { // <-- And this "name": "", "email": "", "github": "", // To find your numeric user ID: // curl https://api.github.com/users/YOUR_USERNAME | jq .id "github_user_id": } ], "repository": [ "github:OWNER/REPO" // <-- Replace OWNER and REPO with the correct values ], "versions": [], "yanked_versions": {} } ``` -------------------------------- ### Include patch in source.json with patch_strip and patches Source: https://github.com/bazel-contrib/publish-to-bcr/blob/main/README.md This JSON snippet shows the expected `source.json` entry when a patch is included in the BCR entry. The patch file must be placed under `.bcr/patches` with a `.patch` extension and in `-p1` format. The `patch_strip` value and the `patches` object with the patch filename and its SHA-256 checksum are required. ```json { ... "patch_strip": 0, "patches": { "remove_dev_deps.patch": "sha256-DXvBJbXZWf3hITOIjeJbgER6UOXIB6ogpgullT+oP4k=" } } ``` -------------------------------- ### Configure workflow triggers with workflow_call and workflow_dispatch Source: https://github.com/bazel-contrib/publish-to-bcr/blob/main/README.md Defines the workflow triggers for the publish workflow. Use this when you want to support both automatic invocation after a release and manual dispatch from the GitHub UI. The tag_name input is required for both triggers. ```yaml on: # Run the publish workflow after a successful release # Will be triggered from the release.yaml workflow workflow_call: inputs: tag_name: required: true type: string # In case of problems, let release engineers retry by manually dispatching # the workflow from the GitHub UI workflow_dispatch: inputs: tag_name: required: true type: string ``` -------------------------------- ### Finalize release with gh release edit Source: https://github.com/bazel-contrib/publish-to-bcr/blob/main/README.md Add this job to your workflow to finalize the release after the publish workflow has uploaded attestations. It uses the GitHub CLI to edit the release and set draft to false. This is required because the publish workflow does not finalize the release. ```yaml publish-release: runs-on: ubuntu-latest needs: publish steps: - run: gh release edit "${{ inputs.tag_name }}" --draft=false --repo "${{ github.repository }}" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.