Skip to content

Commit

Permalink
Create release notes and upload artifacts automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
kon72 committed Feb 19, 2024
1 parent a5992f9 commit eab8828
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
run: patch --dry-run -p1 < .bcr/patches/*.patch

- name: bazel test //...
run: bazel --bazelrc=.github/workflows/ci.bazelrc test //...
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //...
env:
ASPECT_RULES_JS_FROZEN_PNPM_LOCK: 1
# bazelisk will download bazel to here
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Cut a release whenever a new tag is pushed to the repo.
# You should use an annotated tag, like `git tag -a v1.2.3`
# and put the release notes into the commit message for the tag.
name: Release

on:
push:
tags:
- 'v*.*.*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Mount bazel caches
uses: actions/cache@v4
with:
path: |
~/.cache/bazel-disk-cache
~/.cache/bazel-repository-cache
~/.cache/xdg-cache
key: >-
bazel-cache-${{ matrix.os }}-
${{ hashFiles('.bazelrc', '.bazelversion', '**/BUILD', '**/BUILD.bazel', '**/*.bzl', 'WORKSPACE', 'WORKSPACE.bazel', 'WORKSPACE.bzlmod', 'MODULE.bazel', 'MODULE.bazel.lock') }}
restore-keys: |
bazel-cache-${{ matrix.os }}-
- name: bazel test //...
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //...
env:
ASPECT_RULES_JS_FROZEN_PNPM_LOCK: 1
# bazelisk will download bazel to here
XDG_CACHE_HOME: ~/.cache/xdg-cache
- name: Prepare release notes and artifacts
run: .github/workflows/release_prep.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt
- name: Release
uses: softprops/action-gh-release@v1
with:
prerelease: ${{ inputs.prerelease }}
# Use GH feature to populate the changelog automatically
generate_release_notes: true
body_path: release_notes.txt
fail_on_unmatched_files: true
files: rules_node_binding-*.tar.gz
44 changes: 44 additions & 0 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

set -o errexit -o nounset -o pipefail

# Set by GH actions, see
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
TAG=${GITHUB_REF_NAME}
# The prefix is chosen to match what GitHub generates for source archives
PREFIX="rules_node_binding-${TAG:1}"
ARCHIVE="rules_node_binding-$TAG.tar.gz"
git archive --format=tar --prefix="${PREFIX}/" "${TAG}" | gzip >"$ARCHIVE"
SHA=$(shasum -a 256 "$ARCHIVE" | awk '{print $1}')

cat <<EOF
## Installation
### If your project adopts [Bzlmod](https://bazel.build/external/migration) system
Add the following to your \`MODULE.bazel\` file:
\`\`\`starlark
bazel_dep(name = "rules_node_binding", version = "${TAG:1}")
\`\`\`
### If your project is using WORKSPACE system
Add the following to your \`WORKSPACE\` file:
\`\`\`starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_node_binding",
sha256 = "${SHA}",
strip_prefix = "${PREFIX}",
url = "https://github.com/aspect-build/rules_js/releases/download/${TAG}/${ARCHIVE}",
)
load("@rules_node_binding//node_binding:repositories.bzl", "rules_node_binding_setup")
rules_node_binding_setup()
\`\`\`
EOF
34 changes: 2 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,8 @@ See [examples](examples) for more details.

## Installation

### If your project adopts [Bzlmod](https://bazel.build/external/migration) system

Add the following to your `MODULE.bazel` file:

```Starlark
bazel_dep(name = "rules_node_binding")
archive_override(
module_name = "rules_node_binding",
integrity = "sha256-yrGTzp9iRs9ZnXdsW3mogn5VAlJRCcREBjeOmhsfoVM=",
strip_prefix = "rules_node_binding-4bd65b67ef73eb5776a0909953323adcfff2ce3d",
urls = ["https://github.com/kon72/rules_node_binding/archive/4bd65b67ef73eb5776a0909953323adcfff2ce3d.tar.gz"],
)
```

### If your project is using WORKSPACE system

Add the following to your `WORKSPACE` file:

```Starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_node_binding",
integrity = "sha256-yrGTzp9iRs9ZnXdsW3mogn5VAlJRCcREBjeOmhsfoVM=",
strip_prefix = "rules_node_binding-4bd65b67ef73eb5776a0909953323adcfff2ce3d",
urls = ["https://github.com/kon72/rules_node_binding/archive/4bd65b67ef73eb5776a0909953323adcfff2ce3d.tar.gz"],
)

load("@rules_node_binding//node_binding:repositories.bzl", "rules_node_binding_setup")

rules_node_binding_setup()
```
See [Release Notes](https://github.com/kon72/rules_node_binding/releases) for
installation instructions.


## FAQ
Expand Down

0 comments on commit eab8828

Please sign in to comment.