Skip to content

Commit d90aa1b

Browse files
committed
Use the Publish to BCR reusable GitHub workflow
Updates `.github/workflows/release.yml` and adds `publish-to-bcr.yml` for publishing to the Bazel Central Registry. Part of bazel-contrib#1482 broken out from bazel-contrib#1722. `release.yml` now uses the `release_ruleset` workflow from `bazel-contrib/.github`, which does everything `release.yml` did previously and adds SLSA provenance attestations. `release.yml` then invokes the new `publish-to-bcr.yml` workflow after publishing a successful release to GitHub. Based on aspect-build/rules_lint#498 and aspect-build/rules_lint#501. See `.bcr/README.md`. --- Extracting this from bazel-contrib#1722 makes that pull request more focused, and prevents holding it up based on any discussion around these workflow changes in particular. It's also unclear if the infrastructure will be in place to support these workflows before we're ready to publish the first `rules_scala` module. Though these workflows will supersede the Publish to BCR app, it may take some time to resolve slsa-framework/slsa-verifier#840. aspect-build/rules_lint#508, @alexeagle manually triggered a workflow run based on these workflows, which generated an attestation: - https://github.com/aspect-build/rules_lint/actions/runs/14095611671 - https://github.com/aspect-build/rules_lint/attestations/5857159 Here are some examples of GitHub's attestation UI in general: - https://github.com/aspect-build/rules_lint/attestations And some relevant GitHub docs: - https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#using-secrets-in-a-workflow - https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#secrets-context - https://docs.github.com/en/actions/sharing-automations/reusing-workflows#passing-inputs-and-secrets-to-a-reusable-workflow - https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#onworkflow_callsecrets
1 parent 84e3f44 commit d90aa1b

File tree

3 files changed

+99
-21
lines changed

3 files changed

+99
-21
lines changed

.bcr/README.md

+33-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,44 @@
11
# Bazel Central Registry publication
22

3-
The [Publish to BCR GitHub app](https://github.com/bazel-contrib/publish-to-bcr)
4-
uses these configuration files for publishing Bazel modules to the [Bazel
5-
Central Registry (BCR)](https://registry.bazel.build/).
3+
The [.github/workflows/publish-to-bcr.yml](
4+
../.github/workflows/publish-to-bcr.yml) reusable GitHub workflow uses these
5+
configuration files for publishing Bazel modules to the [Bazel Central Registry
6+
(BCR)](https://registry.bazel.build/). This workflow also produces attestations
7+
required by the [Supply chain Levels for Software Artifacts
8+
(SLSA)](https://slsa.dev/) framework for secure supply chain provenance.
69

7-
- [Publish to BCR workflow setup](
8-
https://github.com/bazel-contrib/publish-to-bcr/tree/main/README.md#setup)
10+
[bazel-contrib/publish-to-bcr](https://github.com/bazel-contrib/publish-to-bcr)
11+
documentation:
12+
13+
- [Publish to BCR workflow setup (from bazel-contrib/publish-to-bcr@fb1dc68)](
14+
https://github.com/bazel-contrib/publish-to-bcr/blob/fb1dc6802c3c999e17ad7afce9474a90bd89e132/README.md#setup)
915
- [.bcr/ templates](
1016
https://github.com/bazel-contrib/publish-to-bcr/tree/main/templates)
17+
- [.github/workflows/publish.yaml reusable workflow](
18+
https://github.com/bazel-contrib/publish-to-bcr/blob/main/.github/workflows/publish.yaml)
1119

1220
Related documentation:
1321

1422
- [bazelbuild/bazel-central-registry](
1523
https://github.com/bazelbuild/bazel-central-registry)
24+
- [SLSA: Provenance](https://slsa.dev/spec/v1.0/provenance)
25+
- [in-toto](https://in-toto.io/)
1626
- [GitHub Actions](https://docs.github.com/actions)
27+
- [Security for GitHub Actions](
28+
https://docs.github.com/en/actions/security-for-github-actions)
29+
- [Security for GitHub Actions: Using artifact attestations](
30+
https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations)
31+
- [actions/attest-build-provenance](
32+
https://github.com/actions/attest-build-provenance)
33+
- [in-toto/attestation](https://github.com/in-toto/attestation)
34+
- [slsa-framework/slsa-verifier](
35+
https://github.com/slsa-framework/slsa-verifier)
36+
37+
---
38+
39+
Originally based on the examples from aspect-build/rules_lint#498 and
40+
aspect-build/rules_lint#501. See also:
41+
42+
- bazelbuild/bazel-central-registry#4060
43+
- bazelbuild/bazel-central-registry#4146
44+
- slsa-framework/slsa-verifier#840

.github/workflows/publish-to-bcr.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Publishes to the Bazel Central Registry. See .bcr/README.md.
2+
name: Publish to the Bazel Central Registry
3+
4+
on:
5+
# Run from release.yml.
6+
workflow_call:
7+
inputs:
8+
tag_name:
9+
required: true
10+
type: string
11+
secrets:
12+
publish_token:
13+
required: true
14+
15+
# In case of problems, enable manual dispatch from the GitHub UI.
16+
workflow_dispatch:
17+
inputs:
18+
tag_name:
19+
required: true
20+
type: string
21+
22+
jobs:
23+
publish-to-bcr:
24+
uses: bazel-contrib/publish-to-bcr/.github/workflows/[email protected]
25+
with:
26+
tag_name: ${{ inputs.tag_name }}
27+
# bazelbuild/bazel-central-registry fork used to open a pull request.
28+
registry_fork: simuons/bazel-central-registry
29+
permissions:
30+
attestations: write
31+
contents: write
32+
id-token: write
33+
secrets:
34+
# Necessary to push to the BCR fork and open a pull request.
35+
publish_token: ${{ secrets.publish_token }}

.github/workflows/release.yml

+31-16
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,36 @@ on:
77
tags:
88
- 'v*.*.*'
99

10-
jobs:
11-
build:
12-
runs-on: ubuntu-latest
13-
steps:
14-
- name: Checkout
15-
uses: actions/checkout@v3
10+
# In case of problems, enable manual dispatch from the GitHub UI.
11+
workflow_dispatch:
12+
inputs:
13+
tag_name:
14+
required: true
15+
type: string
16+
17+
# Based on the following, which uses the `release_ruleset` workflow to generate
18+
# provenance attestation files referenced by the `publish-to-bcr` workflow.
19+
# https://github.com/aspect-build/rules_lint/blob/v1.3.1/.github/workflows/release.yml
1620

17-
- name: Prepare workspace snippet
18-
run: .github/workflows/workspace_snippet.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt
21+
permissions:
22+
attestations: write # Needed to attest provenance
23+
contents: write # Needed to create release
24+
id-token: write # Needed to attest provenance
25+
26+
jobs:
27+
release:
28+
uses: bazel-contrib/.github/.github/workflows/[email protected]
29+
with:
30+
bazel_test_command: "bazel test //src/... //test/... //third_party/..."
31+
prerelease: false
32+
release_files: rules_scala-*.tar.gz
33+
release_prep_command: .github/workflows/workspace_snippet.sh
34+
tag_name: ${{ github.ref_name }}
1935

20-
- name: Release
21-
uses: softprops/action-gh-release@v1
22-
with:
23-
# Use GH feature to populate the changelog automatically
24-
generate_release_notes: true
25-
body_path: release_notes.txt
26-
fail_on_unmatched_files: true
27-
files: rules_scala-*.tar.gz
36+
publish-to-bcr:
37+
needs: release
38+
uses: ./.github/workflows/publish-to-bcr.yml
39+
with:
40+
tag_name: ${{ github.ref_name }}
41+
secrets:
42+
publish_token: ${{ secrets.PUBLISH_TOKEN }}

0 commit comments

Comments
 (0)