From e0b81a2c707c998225e83684a38d15532df6e98f Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Wed, 5 Jun 2024 17:55:35 +0200 Subject: [PATCH] Add release setup (#6) Also lower the Bazel version requirement to 7.0.2 by opening up `visibility`. --- .bcr/config.yml | 3 +++ .bcr/metadata.template.json | 12 +++++++++++ .bcr/presubmit.yml | 14 +++++++++++++ .bcr/source.template.json | 5 +++++ .github/workflows/release.yml | 34 +++++++++++++++++++++++++++++++ .github/workflows/release_prep.sh | 22 ++++++++++++++++++++ .gitignore | 1 + BUILD.bazel | 3 ++- MODULE.bazel | 2 +- README.md | 2 +- 10 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 .bcr/config.yml create mode 100644 .bcr/metadata.template.json create mode 100644 .bcr/presubmit.yml create mode 100644 .bcr/source.template.json create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/release_prep.sh diff --git a/.bcr/config.yml b/.bcr/config.yml new file mode 100644 index 0000000..179c0b6 --- /dev/null +++ b/.bcr/config.yml @@ -0,0 +1,3 @@ +fixedReleaser: + login: fmeum + email: fabian@buildbuddy.io diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json new file mode 100644 index 0000000..0287bf7 --- /dev/null +++ b/.bcr/metadata.template.json @@ -0,0 +1,12 @@ +{ + "homepage": "https://github.com/buildbuddy-io/bazel_env.bzl", + "maintainers": [ + { + "email": "fabian@buildbuddy.io", + "github": "fmeum", + "name": "Fabian Meumertzheim" + } + ], + "versions": [], + "yanked_versions": {} +} diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml new file mode 100644 index 0000000..aae4199 --- /dev/null +++ b/.bcr/presubmit.yml @@ -0,0 +1,14 @@ +bcr_test_module: + module_path: "examples" + matrix: + platform: ["debian10", "macos", "ubuntu2004"] + bazel: ["7.x"] + tasks: + run_tests: + name: "Run test module" + platform: ${{ platform }} + bazel: ${{ bazel }} + build_targets: + - "//..." + test_targets: + - "//..." diff --git a/.bcr/source.template.json b/.bcr/source.template.json new file mode 100644 index 0000000..5583765 --- /dev/null +++ b/.bcr/source.template.json @@ -0,0 +1,5 @@ +{ + "integrity": "", + "strip_prefix": "", + "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/bazel_env.bzl-{TAG}.tar.gz" +} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..27087f1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: Release + +on: + push: + tags: + - 'v*.*.*' + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Test + working-directory: examples + run: bazelisk build //... && bazelisk test //... + + - name: Build release artifacts and prepare release notes + run: | + .github/workflows/release_prep.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt + + - name: Release + # Corresponds to the v2.0.5 tag. + uses: softprops/action-gh-release@69320dbe05506a9a39fc8ae11030b214ec2d1f87 + with: + # Use GH feature to populate the changelog automatically + generate_release_notes: true + body_path: release_notes.txt + fail_on_unmatched_files: true + files: bazel_env.bzl-*.tar.gz diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh new file mode 100644 index 0000000..abc5b81 --- /dev/null +++ b/.github/workflows/release_prep.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Based on +# https://github.com/bazel-contrib/rules-template/blob/a71e0a7624aa6e6fcde3d6623d3cb135fffbe28a/.github/workflows/release_prep.sh#L1 + +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="bazel_env.bzl-${TAG:1}" +ARCHIVE="bazel_env.bzl-$TAG.tar.gz" +git archive --prefix=${PREFIX}/ ${TAG} -o $ARCHIVE + +cat << 'EOF' +Add to your \`MODULE.bazel\` file: + +```starlark +bazel_dep(name = "bazel_env.bzl", version = "${TAG:1}") +``` +EOF diff --git a/.gitignore b/.gitignore index 0d4fed2..9ba1dc7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bazel-* MODULE.bazel.lock +/.ijwb diff --git a/BUILD.bazel b/BUILD.bazel index ecaf40d..3af4b42 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -17,5 +17,6 @@ exports_files( "status.sh.tpl", "launcher.sh.tpl", ], - visibility = ["//visibility:private"], + # TODO: Switch to private visibility once the minimum supported Bazel version is 7.1.0. + visibility = ["//visibility:public"], ) diff --git a/MODULE.bazel b/MODULE.bazel index 48e473a..51ae727 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,7 +1,7 @@ module( name = "bazel_env.bzl", version = "0.0.0", - bazel_compatibility = [">=7.1.2"], + bazel_compatibility = [">=7.0.2"], ) bazel_dep(name = "bazel_skylib", version = "1.6.1") diff --git a/README.md b/README.md index 77f7649..46d8481 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The [example](examples/) includes some commonly used tools and toolchains. bazel_dep(name = "bazel_env.bzl", dev_dependency = True) git_override( module_name = "bazel_env.bzl", - remote = "https://github.com/fmeum/bazel_env.bzl.git", + remote = "https://github.com/buildbuddy-io/bazel_env.bzl.git", commit = "", ) ```