Skip to content

Commit

Permalink
Add release setup (#6)
Browse files Browse the repository at this point in the history
Also lower the Bazel version requirement to 7.0.2 by opening up
`visibility`.
  • Loading branch information
fmeum authored Jun 5, 2024
1 parent 0415de1 commit e0b81a2
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .bcr/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fixedReleaser:
login: fmeum
email: [email protected]
12 changes: 12 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"homepage": "https://github.com/buildbuddy-io/bazel_env.bzl",
"maintainers": [
{
"email": "[email protected]",
"github": "fmeum",
"name": "Fabian Meumertzheim"
}
],
"versions": [],
"yanked_versions": {}
}
14 changes: 14 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -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:
- "//..."
5 changes: 5 additions & 0 deletions .bcr/source.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"integrity": "",
"strip_prefix": "",
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/bazel_env.bzl-{TAG}.tar.gz"
}
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bazel-*
MODULE.bazel.lock
/.ijwb
3 changes: 2 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<latest commit>",
)
```
Expand Down

0 comments on commit e0b81a2

Please sign in to comment.