Skip to content

Commit 8a5a0bd

Browse files
authored
Add a release workflow. (#993)
* Add a release workflow. * clean up release note generator - do not include google specific maintainer instructions - remove "snip" marks which were needed when you had to copy paste from terminal to github page.
1 parent 2fab459 commit 8a5a0bd

File tree

3 files changed

+93
-18
lines changed

3 files changed

+93
-18
lines changed

.github/workflows/release.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: "Create release"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
required: true
8+
type: string
9+
description: "Match the value in version.bzl"
10+
11+
permissions:
12+
id-token: write
13+
attestations: write
14+
contents: write
15+
16+
jobs:
17+
tests:
18+
name: "Release Tests"
19+
uses: "./.github/workflows/checks.yml"
20+
21+
create_tag:
22+
name: "Create tag"
23+
runs-on:
24+
- "ubuntu-latest"
25+
needs:
26+
- "tests"
27+
28+
steps:
29+
- uses: actions/checkout@v6
30+
31+
- name: "Create tag"
32+
id: "tag"
33+
env:
34+
VERSION: "${{ inputs.version }}"
35+
36+
GIT_AUTHOR_NAME: "${{ github.actor }}"
37+
GIT_AUTHOR_EMAIL: "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
38+
GIT_COMMITTER_NAME: "${{ github.actor }}"
39+
GIT_COMMITTER_EMAIL: "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
40+
run: |
41+
# 3. Push release tag.
42+
git tag "${VERSION}" "HEAD"
43+
git push origin "${VERSION}"
44+
45+
release:
46+
name: "Create GitHub release"
47+
needs:
48+
- "create_tag"
49+
50+
uses: "bazel-contrib/.github/.github/workflows/[email protected]"
51+
with:
52+
# Create a distribution tarball with the release branded in to MODULE.bazel
53+
# The workflow appends `--disk_cache` here. There seems to be now way to
54+
# opt out, so use `|| false` to make it be |stuff we want || false --disk_cache|
55+
bazel_test_command: bazel build //distro:distro || false
56+
release_files: "bazel-bin/distro/rules_pkg-*.tar.gz"
57+
tag_name: "${{ inputs.version }}"

.github/workflows/release_prep.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit -o nounset -o pipefail
4+
5+
# Passed as argument when invoking the script.
6+
TAG="${1}"
7+
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+
PREFIX="rules_pkg--${TAG:1}"
12+
ARCHIVE="rules_pkg-$TAG.tar.gz"
13+
14+
bazel build distro:relnotes
15+
cat bazel-bin/distro/relnotes.txt

pkg/releasing/print_rel_notes.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def print_notes(org, repo, version, tarball_path, mirror_host=None,
3838
deps_method=deps_method, toolchains_method=toolchains_method)
3939
relnotes_template = string.Template(textwrap.dedent(
4040
"""
41-
------------------------ snip ----------------------------
4241
**New Features**
4342
4443
**Incompatible Changes**
@@ -61,8 +60,6 @@ def print_notes(org, repo, version, tarball_path, mirror_host=None,
6160
**Using the rules**
6261
6362
See [the source](https://github.com/${org}/${repo}/tree/${version}).
64-
------------------------ snip ----------------------------
65-
6663
""").strip())
6764
print(relnotes_template.substitute({
6865
'changelog': changelog,
@@ -79,21 +76,27 @@ def print_notes(org, repo, version, tarball_path, mirror_host=None,
7976
version=version,
8077
file=file
8178
)
82-
mirroring_template = string.Template(textwrap.dedent(
83-
"""
84-
85-
!!!: Make sure to copy the file to the release notes.
86-
If you are using Google Cloud Storage, you might use a command like
87-
gsutil cp bazel-bin/distro/${file} gs://bazel-mirror/${path}
88-
gsutil setmeta -h "Cache-Control: public, max-age=31536000" "gs://bazel-mirror/${path}"
89-
""").strip())
90-
print(mirroring_template.substitute({
91-
'org': org,
92-
'repo': repo,
93-
'version': version,
94-
'file': file,
95-
'path': path,
96-
}))
79+
80+
if False:
81+
# TODO: This matters for the Bazel team at Googel, who can mirror it, but
82+
# does not make sense for the rest of the world. Figure out if we should
83+
# keep it or not.
84+
mirroring_template = string.Template(textwrap.dedent(
85+
"""
86+
87+
!!!: Make sure to copy the file to the release notes.
88+
If you are using Google Cloud Storage, you might use a command like
89+
gsutil cp bazel-bin/distro/${file} gs://bazel-mirror/${path}
90+
gsutil setmeta -h "Cache-Control: public, max-age=31536000" "gs://bazel-mirror/${path}"
91+
""").strip())
92+
93+
print(mirroring_template.substitute({
94+
'org': org,
95+
'repo': repo,
96+
'version': version,
97+
'file': file,
98+
'path': path,
99+
}))
97100

98101

99102
def main():

0 commit comments

Comments
 (0)