From eab8828ba79f1d2f8ebe2365bf2ff6d57942e5f7 Mon Sep 17 00:00:00 2001 From: kon72 Date: Mon, 19 Feb 2024 17:22:39 +0900 Subject: [PATCH] Create release notes and upload artifacts automatically --- .github/workflows/ci.yaml | 2 +- .github/workflows/release.yaml | 45 +++++++++++++++++++++++++++++++ .github/workflows/release_prep.sh | 44 ++++++++++++++++++++++++++++++ README.md | 34 ++--------------------- 4 files changed, 92 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/release_prep.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0f181f7..40d3d55 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..27175fe --- /dev/null +++ b/.github/workflows/release.yaml @@ -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 diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh new file mode 100644 index 0000000..247a8f2 --- /dev/null +++ b/.github/workflows/release_prep.sh @@ -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 <