Skip to content

Commit aaa54ca

Browse files
authored
chore: automate releases (#189)
This also fixes our current dependency on GitHub archives which are not guaranteed to be stable, https://github.com/bazelbuild/bazel-central-registry/pull/332/files#diff-7288b02983f19cbe12177d5f193a6bfc533e352fc44fbe12cdb93e1c8c28dcd1R4 which requires a special 'skip-url-stability-check' label on the BCR PR Instead, we run 'git archive' to create the release artifact. We can now prune the tests/ folder from that artifact, which lets us remove an exclusion from the presubmit as well. Fixes #188
1 parent 367e3b5 commit aaa54ca

8 files changed

+113
-5
lines changed

.bcr/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Bazel Central Registry
2+
3+
When the ruleset is released, we want it to be published to the
4+
Bazel Central Registry automatically:
5+
<https://registry.bazel.build>
6+
7+
This folder contains configuration files to automate the publish step.
8+
See <https://github.com/bazel-contrib/publish-to-bcr/blob/main/templates/README.md>
9+
for authoritative documentation about these files.

.bcr/metadata.template.json

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
{
22
"homepage": "https://github.com/bazelbuild/rules_proto",
3-
"maintainers": [],
3+
"maintainers": [
4+
{
5+
"github": "googleberg",
6+
"name": "Jerry Berg"
7+
},
8+
{
9+
"github": "zhangskz"
10+
},
11+
{
12+
"email": "[email protected]",
13+
"github": "alexeagle",
14+
"name": "Alex Eagle"
15+
},
16+
{
17+
"email": "[email protected]",
18+
"github": "thesayyn",
19+
"name": "Şahin Yort"
20+
}
21+
],
422
"versions": [],
5-
"yanked_versions": {}
23+
"yanked_versions": {},
624
"repository": [
725
"github:bazelbuild/rules_proto"
826
]

.bcr/source.template.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"integrity": "",
2+
"integrity": "**leave this alone**",
33
"strip_prefix": "{REPO}-{VERSION}",
4-
"url": "https://github.com/{OWNER}/{REPO}/archive/refs/tags/{TAG}.tar.gz"
4+
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz"
55
}

.gitattributes

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# In code review, collapse generated files
2+
docs/*.md linguist-generated=true
3+
4+
# Configuration for 'git archive'
5+
# see https://git-scm.com/docs/git-archive/2.40.0#ATTRIBUTES
6+
# Omit folders that users don't need, making the distribution artifact smaller
7+
tests export-ignore

.github/workflows/release.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Automatically perform a release whenever a new "release-like" tag is pushed to the repo.
2+
name: Release
3+
4+
on:
5+
push:
6+
tags:
7+
# Detect tags that look like a release.
8+
# Note that we don't use a "v" prefix to help anchor this pattern.
9+
# This is purely a matter of preference.
10+
- "*.*.*"
11+
12+
jobs:
13+
release:
14+
# Re-use https://github.com/bazel-contrib/.github/blob/v5/.github/workflows/release_ruleset.yaml
15+
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v5
16+
with:
17+
prerelease: false
18+
release_files: rules_proto-*.tar.gz

.github/workflows/release_prep.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit -o nounset -o pipefail
4+
5+
# Set by GH actions, see
6+
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
7+
readonly TAG=${GITHUB_REF_NAME}
8+
# The prefix is chosen to match what GitHub generates for source archives.
9+
# This guarantees that users can easily switch from a released artifact to a source archive
10+
# with minimal differences in their code (e.g. strip_prefix remains the same)
11+
readonly PREFIX="rules_proto-${TAG}"
12+
readonly ARCHIVE="${PREFIX}.tar.gz"
13+
14+
# NB: configuration for 'git archive' is in /.gitattributes
15+
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
16+
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
17+
18+
# The stdout of this program will be used as the top of the release notes for this release.
19+
cat << EOF
20+
## Using bzlmod with Bazel 6 or later:
21+
22+
1. [Bazel 6] Add \`common --enable_bzlmod\` to \`.bazelrc\`.
23+
24+
2. Add to your \`MODULE.bazel\` file:
25+
26+
\`\`\`starlark
27+
bazel_dep(name = "rules_proto", version = "${TAG}")
28+
\`\`\`
29+
30+
## Using WORKSPACE:
31+
32+
\`\`\`starlark
33+
34+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
35+
36+
http_archive(
37+
name = "rules_proto",
38+
sha256 = "${SHA}",
39+
strip_prefix = "${PREFIX}",
40+
url = "https://github.com/bazelbuild/rules_proto/releases/download/${TAG}/${ARCHIVE}",
41+
)
42+
\`\`\`starlark
43+
EOF

CONTRIBUTING.md

+10
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,13 @@ information on using pull requests.
2626

2727
This project follows [Google's Open Source Community
2828
Guidelines](https://opensource.google.com/conduct/).
29+
30+
## Releasing
31+
32+
To perform a release, simply tag the commit you wish to release, for example:
33+
34+
```
35+
rules_proto$ git fetch
36+
rules_proto$ git tag 1.2.3 origin/main
37+
rules_proto$ git push origin 1.2.3
38+
```

MODULE.bazel

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
"Bazel dependencies"
2+
13
module(
24
name = "rules_proto",
3-
version = "5.3.0-21.7",
5+
# Note: the publish-to-BCR app will patch this line to stamp the version being published.
6+
version = "0.0.0",
47
compatibility_level = 1,
58
)
69

0 commit comments

Comments
 (0)