Skip to content

Commit eab8828

Browse files
committed
Create release notes and upload artifacts automatically
1 parent a5992f9 commit eab8828

File tree

4 files changed

+92
-33
lines changed

4 files changed

+92
-33
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
run: patch --dry-run -p1 < .bcr/patches/*.patch
5959

6060
- name: bazel test //...
61-
run: bazel --bazelrc=.github/workflows/ci.bazelrc test //...
61+
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //...
6262
env:
6363
ASPECT_RULES_JS_FROZEN_PNPM_LOCK: 1
6464
# bazelisk will download bazel to here

.github/workflows/release.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Cut a release whenever a new tag is pushed to the repo.
2+
# You should use an annotated tag, like `git tag -a v1.2.3`
3+
# and put the release notes into the commit message for the tag.
4+
name: Release
5+
6+
on:
7+
push:
8+
tags:
9+
- 'v*.*.*'
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
- name: Mount bazel caches
18+
uses: actions/cache@v4
19+
with:
20+
path: |
21+
~/.cache/bazel-disk-cache
22+
~/.cache/bazel-repository-cache
23+
~/.cache/xdg-cache
24+
key: >-
25+
bazel-cache-${{ matrix.os }}-
26+
${{ hashFiles('.bazelrc', '.bazelversion', '**/BUILD', '**/BUILD.bazel', '**/*.bzl', 'WORKSPACE', 'WORKSPACE.bazel', 'WORKSPACE.bzlmod', 'MODULE.bazel', 'MODULE.bazel.lock') }}
27+
restore-keys: |
28+
bazel-cache-${{ matrix.os }}-
29+
- name: bazel test //...
30+
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //...
31+
env:
32+
ASPECT_RULES_JS_FROZEN_PNPM_LOCK: 1
33+
# bazelisk will download bazel to here
34+
XDG_CACHE_HOME: ~/.cache/xdg-cache
35+
- name: Prepare release notes and artifacts
36+
run: .github/workflows/release_prep.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt
37+
- name: Release
38+
uses: softprops/action-gh-release@v1
39+
with:
40+
prerelease: ${{ inputs.prerelease }}
41+
# Use GH feature to populate the changelog automatically
42+
generate_release_notes: true
43+
body_path: release_notes.txt
44+
fail_on_unmatched_files: true
45+
files: rules_node_binding-*.tar.gz

.github/workflows/release_prep.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
TAG=${GITHUB_REF_NAME}
8+
# The prefix is chosen to match what GitHub generates for source archives
9+
PREFIX="rules_node_binding-${TAG:1}"
10+
ARCHIVE="rules_node_binding-$TAG.tar.gz"
11+
git archive --format=tar --prefix="${PREFIX}/" "${TAG}" | gzip >"$ARCHIVE"
12+
SHA=$(shasum -a 256 "$ARCHIVE" | awk '{print $1}')
13+
14+
cat <<EOF
15+
16+
## Installation
17+
18+
### If your project adopts [Bzlmod](https://bazel.build/external/migration) system
19+
20+
Add the following to your \`MODULE.bazel\` file:
21+
22+
\`\`\`starlark
23+
bazel_dep(name = "rules_node_binding", version = "${TAG:1}")
24+
\`\`\`
25+
26+
### If your project is using WORKSPACE system
27+
28+
Add the following to your \`WORKSPACE\` file:
29+
30+
\`\`\`starlark
31+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
32+
33+
http_archive(
34+
name = "rules_node_binding",
35+
sha256 = "${SHA}",
36+
strip_prefix = "${PREFIX}",
37+
url = "https://github.com/aspect-build/rules_js/releases/download/${TAG}/${ARCHIVE}",
38+
)
39+
40+
load("@rules_node_binding//node_binding:repositories.bzl", "rules_node_binding_setup")
41+
42+
rules_node_binding_setup()
43+
\`\`\`
44+
EOF

README.md

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,8 @@ See [examples](examples) for more details.
2626

2727
## Installation
2828

29-
### If your project adopts [Bzlmod](https://bazel.build/external/migration) system
30-
31-
Add the following to your `MODULE.bazel` file:
32-
33-
```Starlark
34-
bazel_dep(name = "rules_node_binding")
35-
archive_override(
36-
module_name = "rules_node_binding",
37-
integrity = "sha256-yrGTzp9iRs9ZnXdsW3mogn5VAlJRCcREBjeOmhsfoVM=",
38-
strip_prefix = "rules_node_binding-4bd65b67ef73eb5776a0909953323adcfff2ce3d",
39-
urls = ["https://github.com/kon72/rules_node_binding/archive/4bd65b67ef73eb5776a0909953323adcfff2ce3d.tar.gz"],
40-
)
41-
```
42-
43-
### If your project is using WORKSPACE system
44-
45-
Add the following to your `WORKSPACE` file:
46-
47-
```Starlark
48-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
49-
50-
http_archive(
51-
name = "rules_node_binding",
52-
integrity = "sha256-yrGTzp9iRs9ZnXdsW3mogn5VAlJRCcREBjeOmhsfoVM=",
53-
strip_prefix = "rules_node_binding-4bd65b67ef73eb5776a0909953323adcfff2ce3d",
54-
urls = ["https://github.com/kon72/rules_node_binding/archive/4bd65b67ef73eb5776a0909953323adcfff2ce3d.tar.gz"],
55-
)
56-
57-
load("@rules_node_binding//node_binding:repositories.bzl", "rules_node_binding_setup")
58-
59-
rules_node_binding_setup()
60-
```
29+
See [Release Notes](https://github.com/kon72/rules_node_binding/releases) for
30+
installation instructions.
6131

6232

6333
## FAQ

0 commit comments

Comments
 (0)