Skip to content

Commit d723304

Browse files
author
jchadwick-buf
authored
Update to new BCR workflow (#402)
The GitHub App for BCR publishing we implemented in Q1 is now deprecated in favor of a new approach using GitHub workflows. I think the main reason for this is to support SLSA attestation for the BCR. Anyway, a few changes needed to be made: - Added myself as a maintainer; not _strictly_ necessary, but it's useful. - Remove "Create Release Draft" workflow; we have to use the BCR release workflow in order to pass attestation. - Add "Publish to BCR" action on release. This does the work that the publish to BCR app did, and creates a PR on the BCR repo when a release is published. - Rename the "Create Release Tag" workflow to just "Release". It still just creates a draft, but the workflow names were confusing before. - Update the Release workflow to use the BCR release workflow. Add necessary permissions for attestation. - Update release_prep.sh to output the release notes snippet to `stdout`. Ensure all other commands that might output to `stdout` are redirected to `stderr`. - Update the `RELEASING.md` documentation. We will need to test this by making a new minor release.
1 parent f9559e5 commit d723304

6 files changed

Lines changed: 58 additions & 66 deletions

File tree

.bcr/metadata.template.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
"name": "Protovalidate Team",
66
"email": "bcr-github@buf.build",
77
"github": "bcr-buf"
8+
},
9+
{
10+
"name": "John Chadwick",
11+
"email": "jchadwick@buf.build",
12+
"github": "jchadwick-buf"
813
}
914
],
10-
"repository": [
11-
"github:bufbuild/protovalidate"
12-
],
15+
"repository": ["github:bufbuild/protovalidate"],
1316
"versions": [],
1417
"yanked_versions": {}
1518
}

.github/workflows/create-release-draft.yaml

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish to BCR
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
tag_name:
9+
description: 'Tag name for release (e.g. "v1.0.0")'
10+
required: true
11+
12+
permissions:
13+
id-token: write
14+
attestations: write
15+
contents: write
16+
17+
jobs:
18+
publish:
19+
uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v0.2.2
20+
with:
21+
tag_name: ${{ inputs.tag_name || github.ref_name }}
22+
registry_fork: bufbuild/bazel-central-registry
23+
secrets:
24+
publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Create release tag
1+
name: Release
22

33
on:
44
workflow_dispatch:
@@ -8,6 +8,8 @@ on:
88
required: true
99

1010
permissions:
11+
id-token: write
12+
attestations: write
1113
contents: write
1214

1315
jobs:
@@ -17,7 +19,7 @@ jobs:
1719
steps:
1820
- name: Checkout
1921
uses: actions/checkout@v4
20-
22+
2123
- name: Create tag
2224
uses: actions/github-script@v7
2325
with:
@@ -52,10 +54,11 @@ jobs:
5254
ref: `refs/tags/${toolsTag}`,
5355
sha: toolsCommitTag.data.sha,
5456
});
55-
56-
create-release-draft:
57-
name: Start release automation
57+
release:
58+
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v7.2.3
5859
needs: create-release-tag
59-
uses: ./.github/workflows/create-release-draft.yaml
6060
with:
61+
release_files: protovalidate-*.tar.gz
62+
prerelease: false
63+
draft: true
6164
tag_name: ${{ github.event.inputs.tag_name }}

.github/workflows/release_prep.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,24 @@ fi
3131

3232
mv MODULE.bazel.tmp MODULE.bazel
3333
>&2 echo "MODULE.bazel contents:"
34-
cat MODULE.bazel
34+
>&2 cat MODULE.bazel
3535

3636
# Create release archive
3737
>&2 echo "# Create release archive ${ARCHIVE}"
38-
git archive \
38+
>&2 git archive \
3939
--prefix="${PREFIX}/" \
4040
--output="${ARCHIVE}" \
4141
"$(git stash create)"
4242

4343
>&2 echo "Release archive ${ARCHIVE} contents:"
44-
tar tvf "${ARCHIVE}"
44+
>&2 tar tvf "${ARCHIVE}"
4545

4646
# Calculate SHA256 sum for WORKSPACE code
4747
SHA256=$(shasum -a 256 "${ARCHIVE}" | awk '{print $1}')
4848

4949
# Generate release notes snippets
5050
>&2 echo "# Generate release notes snippets"
51-
> release_notes.md cat << EOF
51+
cat << EOF
5252
## \`MODULE.bazel\` Usage
5353
\`\`\`bzl
5454
bazel_dep(name = "protovalidate", version = "${TAG:1}")

RELEASING.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Most of the protovalidate release process is automated, but in the event that
99
automation can not be utilized, the manual steps are also included in the
1010
collapsed sections below.
1111

12-
1. **Run the [create release tag] workflow.**
12+
1. **Run the [Release] workflow.**
1313

14-
Go to the [create release tag] workflow page and select <q>Run workflow</q>,
14+
Go to the [Release] workflow page and select <q>Run workflow</q>,
1515
with the desired version tag (e.g. `v1.2.3`).
1616

1717
<details>
@@ -28,31 +28,33 @@ collapsed sections below.
2828
in the event of manually cutting a release.
2929

3030
Note that this workflow creates tags directly on GitHub instead of pushing
31-
tags up, so it will not indirectly trigger the draft release automation in
32-
that way. Instead, a workflow call is used. So, the creat release draft
33-
workflow will appear nested under the create release tag workflow as a step.
31+
tags up, so it will not indirectly trigger automations that trigger on tags.
32+
The BCR release script is run as a workflow call. Creating the tags manually
33+
will not trigger this.
3434

3535
</details>
3636

3737
1. **Find the draft release.**
3838

39-
Upon either pushing a release tag or running the previous workflow, a
40-
release draft should be created. Check for it in the [releases page].
39+
Upon running the previous workflow, a release draft should be created.
40+
Check for it in the [releases page].
4141

42-
If for some reason this doesn't happen, it is possible to directly trigger
43-
the workflow by going to the [create release draft] action and selecting
44-
<q>Run workflow</q>.
42+
If for some reason this doesn't happen, check the workflow log for more
43+
information.
4544

4645
<details>
4746

4847
<summary>Manually creating a release draft</summary>
4948

49+
Note that manually-created releases will not pass attestation and can not
50+
be pushed to the BCR.
51+
5052
To manually create a release draft, run `.github/workflows/release_prep.sh`
5153
with the version tag (e.g. `vX.Y.Z`) as an argument, while checked out to
5254
the release tag/commit:
5355

5456
```
55-
.github/workflows/release_prep.sh v1.2.3
57+
.github/workflows/release_prep.sh v1.2.3 >release_notes.md
5658
```
5759
5860
This will create two files:
@@ -76,8 +78,7 @@ collapsed sections below.
7678
created a new pull request. There may be failures in CI that need to be
7779
addressed.
7880
79-
[create release tag]: https://github.com/bufbuild/protovalidate/actions/workflows/create-release-tag.yaml
80-
[create release draft]: https://github.com/bufbuild/protovalidate/actions/workflows/create-release-draft.yaml
81+
[Release]: https://github.com/bufbuild/protovalidate/actions/workflows/release.yaml
8182
[releases page]: https://github.com/bufbuild/protovalidate/releases
8283
[Bazel Central Registry repository]: https://github.com/bazelbuild/bazel-central-registry/pulls
83-
[Publish to BCR]: https://github.com/apps/publish-to-bcr
84+
[Publish to BCR]: https://github.com/apps/publish-to-bcr

0 commit comments

Comments
 (0)