Skip to content

Commit f5b7135

Browse files
kormideUebelAndre
andauthored
chore: use publish to bcr reusable workflow for bcr mirroring (#3775)
Migrate rules_rust off of the deprecated Publish to BCR GitHub app to the newer reusable workflow. The reusable workflow has a number of benefits over the app: * It supports build attestations which can be enabled at a later time. * Gives finer grain control over running the publish process—if it fails, you can manually re-run the workflow. * It's more secure—you control the PAT rather than giving the app write permissions. Some actions that maintainer for this ruleset will need to take: * [x] Add a classic PAT named `BCR_PUBLISH_TOKEN` for the repository or org (see [steps](https://github.com/bazel-contrib/publish-to-bcr?tab=readme-ov-file#setup)). I recommend creating a "machine" user for bazelbuild and generating a classic PAT for that user rather than using an individual's PAT. For example, in bazel-contrib we use the [bazel-contrib-bot](https://github.com/bazel-contrib-bot) user to do publishes. * [ ] Uninstall the GitHub app for this repo. * [ ] Test a publish after landing, or wait for the next release. I'll be available to help debug any issues that come up if the workflow fails. --------- Co-authored-by: UebelAndre <github@uebelandre.com>
1 parent e4a4fb6 commit f5b7135

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed

.bcr/config.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
fixedReleaser:
2-
login: scentini
3-
email: 11149636+scentini@users.noreply.github.com
41
moduleRoots:
52
- "."
63
- "extensions/bindgen"

.github/workflows/publish.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# See https://github.com/bazel-contrib/publish-to-bcr
2+
name: Publish to BCR
3+
4+
on:
5+
# Allow the publish workflow to be called from another workflow.
6+
# In this case, we trigger it from the release.yaml workflow.
7+
workflow_call:
8+
inputs:
9+
release_version:
10+
required: true
11+
type: string
12+
secrets:
13+
BCR_PUBLISH_TOKEN:
14+
required: true
15+
# In case of problems, let release engineers retry by manually dispatching
16+
# the workflow from the GitHub UI.
17+
workflow_dispatch:
18+
inputs:
19+
release_version:
20+
required: true
21+
type: string
22+
description: Release version to publish to the Bazel Central Registry
23+
templates_ref:
24+
default: ''
25+
type: string
26+
description: Override the ref to read .bcr templates from
27+
jobs:
28+
publish:
29+
uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v1.1.0
30+
with:
31+
author_name: bazel-io
32+
author_email: 5028808+bazel-io@users.noreply.github.com
33+
attest: false
34+
draft: false
35+
tag_name: ${{ inputs.release_version }}
36+
# Tags don't include a "v" prefix
37+
tag_prefix: ""
38+
# GitHub repository which is a fork of the upstream where the Pull Request will be opened.
39+
registry_fork: bazel-io/bazel-central-registry
40+
templates_ref: ${{ inputs.templates_ref || inputs.release_version }}
41+
permissions:
42+
contents: write
43+
secrets:
44+
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}

.github/workflows/release.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,10 @@ jobs:
315315
asset_name: cargo-bazel-aarch64-unknown-linux-musl
316316
asset_path: ${{ github.workspace }}/artifacts/aarch64-unknown-linux-musl/cargo-bazel
317317
asset_content_type: application/octet-stream
318+
publish:
319+
needs: [archive, release]
320+
uses: ./.github/workflows/publish.yaml
321+
with:
322+
release_version: ${{ needs.archive.outputs.release_version }}
323+
secrets:
324+
BCR_PUBLISH_TOKEN: ${{ secrets.BCR_PUBLISH_TOKEN }}

0 commit comments

Comments
 (0)