Skip to content

Commit 3de8914

Browse files
meteorcloudycopybara-github
authored andcommitted
Support publish-to-bcr workflow with attestations
Copybara Import from #441 BEGIN_PUBLIC Support publish-to-bcr workflow with attestations (#441) Similar to bazelbuild/bazel-skylib#581 Closes #441 END_PUBLIC COPYBARA_INTEGRATE_REVIEW=#441 from meteorcloudy:release d399c29 PiperOrigin-RevId: 783256391 Change-Id: I4ccd53589076c948d34558c307d0213f5110bf2c
1 parent c7e5c8c commit 3de8914

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

.github/workflows/publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish to BCR
2+
on:
3+
# Run the publish workflow after a successful release
4+
# Will be triggered from the release.yaml workflow
5+
workflow_call:
6+
inputs:
7+
tag_name:
8+
required: true
9+
type: string
10+
secrets:
11+
publish_token:
12+
required: true
13+
# In case of problems, let release engineers retry by manually dispatching
14+
# the workflow from the GitHub UI
15+
workflow_dispatch:
16+
inputs:
17+
tag_name:
18+
description: git tag being released
19+
required: true
20+
type: string
21+
jobs:
22+
publish:
23+
uses: bazel-contrib/publish-to-bcr/.github/workflows/[email protected]
24+
with:
25+
tag_name: ${{ inputs.tag_name }}
26+
# GitHub repository which is a fork of the upstream where the Pull Request will be opened.
27+
registry_fork: bazel-io/bazel-central-registry
28+
draft: false
29+
permissions:
30+
attestations: write
31+
contents: write
32+
id-token: write
33+
secrets:
34+
# Necessary to push to the BCR fork, and to open a pull request against a registry
35+
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}

.github/workflows/release.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,38 @@
22
name: Release
33

44
on:
5+
# Can be triggered from the tag.yaml workflow
6+
workflow_call:
7+
inputs:
8+
tag_name:
9+
required: true
10+
type: string
11+
secrets:
12+
publish_token:
13+
required: true
14+
# Or, developers can manually push a tag from their clone
515
push:
616
tags:
717
# Detect tags that look like a release.
818
# Note that we don't use a "v" prefix to help anchor this pattern.
919
# This is purely a matter of preference.
1020
- "*.*.*"
11-
21+
permissions:
22+
id-token: write
23+
attestations: write
24+
contents: write
1225
jobs:
1326
release:
1427
# Re-use https://github.com/bazel-contrib/.github/blob/v7/.github/workflows/release_ruleset.yaml
1528
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v7
1629
with:
1730
prerelease: false
18-
release_files: rules_cc-*.tar.gz
31+
release_files: rules_cc-*.tar.gz
32+
tag_name: ${{ inputs.tag_name || github.ref_name }}
33+
publish:
34+
needs: release
35+
uses: ./.github/workflows/publish.yaml
36+
with:
37+
tag_name: ${{ inputs.tag_name || github.ref_name }}
38+
secrets:
39+
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}

.github/workflows/release_prep.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -o errexit -o nounset -o pipefail
44

55
# Set by GH actions, see
66
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
7-
readonly TAG=${GITHUB_REF_NAME}
7+
readonly TAG=$1
88
# The prefix is chosen to match what GitHub generates for source archives.
99
# This guarantees that users can easily switch from a released artifact to a source archive
1010
# with minimal differences in their code (e.g. strip_prefix remains the same)

0 commit comments

Comments
 (0)