Skip to content

Commit 11f55e8

Browse files
Add BCR configurations for publishing releases to the central registry (bazelbuild#1038)
Co-authored-by: Corbin McNeely-Smith <[email protected]>
1 parent 55f60ec commit 11f55e8

12 files changed

+136
-55
lines changed

.bcr/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fixedReleaser:
2+
login: Bencodes
3+

.bcr/metadata.template.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"homepage": "https://github.com/bazelbuild/rules_kotlin",
3+
"maintainers": [
4+
{
5+
"email": "[email protected]",
6+
"github": "Bencodes",
7+
"name": "Ben Lee"
8+
},
9+
{
10+
"email": "[email protected]",
11+
"github": "restingbull",
12+
"name": "Corbin McNeely-Smith"
13+
},
14+
{
15+
"email": "[email protected]",
16+
"github": "nkoroste",
17+
"name": "Nick Korostelev"
18+
}
19+
],
20+
"repository": [
21+
"github:bazelbuild/rules_kotlin"
22+
],
23+
"versions": [],
24+
"yanked_versions": {}
25+
}

.bcr/presubmit.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
matrix:
2+
platform: [ "macos", "ubuntu2004" ]
3+
4+
tasks:
5+
verify_targets:
6+
name: "Verify build targets"
7+
platform: ${{ platform }}
8+
build_flags:
9+
- "--enable_bzlmod=true"
10+
build_targets:
11+
- "@rules_kotlin//kotlin/..."
12+
- "@rules_kotlin//src/..."

.bcr/source.template.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"integrity": "",
3+
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/rules_kotlin-{TAG}.tar.gz"
4+
}

.github/workflows/ci.bazelrc

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This file contains Bazel settings to apply on CI only.
2+
# It is referenced with a --bazelrc option in the call to bazel in ci.yaml
3+
common --curses=no
4+
common --enable_bzlmod
5+
6+
build --verbose_failures
7+
build --worker_verbose
8+
9+
# Debug where options came from
10+
build --announce_rc
11+
# This directory is configured in GitHub actions to be persisted between runs.
12+
# We do not enable the repository cache to cache downloaded external artifacts
13+
# as these are generally faster to download again than to fetch them from the
14+
# GitHub actions cache.
15+
build --disk_cache=~/.cache/bazel
16+
# Don't rely on test logs being easily accessible from the test runner,
17+
# though it makes the log noisier.
18+
test --test_output=errors
19+
# Allows tests to run bazelisk-in-bazel, since this is the cache folder used
20+
test --test_env=XDG_CACHE_HOME

.github/workflows/release.yml

+27-31
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,41 @@
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.
14
name: Release Binary Package
25
on:
36
push:
47
tags:
5-
- v*
8+
- "v*.*.*"
69

710
jobs:
8-
generate:
9-
name: Create release-artifacts
11+
build:
1012
runs-on: ubuntu-latest
1113
steps:
12-
- name: "Checkout the sources"
13-
uses: actions/[email protected]
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
- name: Mount bazel caches
17+
uses: actions/cache@v3
18+
with:
19+
path: |
20+
~/.cache/bazel
21+
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE', 'WORKSPACE.bzlmod') }}
22+
restore-keys: bazel-cache-
1423
- name: Install JDK 11
1524
uses: actions/setup-java@v3
1625
with:
1726
distribution: "zulu"
1827
java-version: "11"
19-
- name: Setup Bazelisk
20-
uses: bazelbuild/setup-bazelisk@v1
21-
- name: Mount bazel cache
22-
uses: actions/cache@v2
23-
with:
24-
path: "/home/runner/.cache/bazel"
25-
key: caches-${{ runner.os }}-release
26-
- name: Build release artifact
27-
run: bazelisk build //:rules_kotlin_release
28-
- name: Create release sha256
29-
run: shasum -a 256 bazel-bin/rules_kotlin_release.tgz > bazel-bin/rules_kotlin_release.tgz.sha256
30-
- name: Upload bazel-bin/rules_kotlin_release.tgz
31-
uses: svenstaro/[email protected]
32-
with:
33-
repo_token: ${{ secrets.GITHUB_TOKEN }}
34-
file: bazel-bin/rules_kotlin_release.tgz
35-
asset_name: rules_kotlin_release.tgz
36-
tag: ${{ github.ref }}
37-
overwrite: true
38-
- name: Upload bazel-bin/rules_kotlin_release.tgz.sha256
39-
uses: svenstaro/[email protected]
28+
- name: Prepare release notes and artifacts
29+
env:
30+
# Bazelisk will download bazel to here.
31+
XDG_CACHE_HOME: ~/.cache/bazel-repo
32+
run: .github/workflows/release_prep.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt
33+
- name: Release
34+
uses: softprops/action-gh-release@v1
4035
with:
41-
repo_token: ${{ secrets.GITHUB_TOKEN }}
42-
file: bazel-bin/rules_kotlin_release.tgz.sha256
43-
asset_name: rules_kotlin_release.tgz.sha256
44-
tag: ${{ github.ref }}
45-
overwrite: true
36+
prerelease: true
37+
# Use GH feature to populate the changelog automatically
38+
generate_release_notes: true
39+
body_path: release_notes.txt
40+
fail_on_unmatched_files: true
41+
files: rules_kotlin-*.tar.gz

.github/workflows/release_prep.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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_kotlin-${TAG:1}"
10+
ARCHIVE="rules_kotlin-$TAG.tar.gz"
11+
bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc build //:rules_kotlin_release
12+
cp bazel-bin/rules_kotlin_release.tgz $ARCHIVE
13+
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
14+
15+
cat << EOF
16+
## Using Bzlmod with Bazel 6
17+
18+
1. Enable with \`common --enable_bzlmod\` in \`.bazelrc\`.
19+
2. Add to your \`MODULE.bazel\` file:
20+
21+
\`\`\`starlark
22+
bazel_dep(name = "rules_kotlin", version = "${TAG:1}")
23+
\`\`\`
24+
25+
## Using WORKSPACE
26+
27+
Paste this snippet into your `WORKSPACE.bazel` file:
28+
29+
\`\`\`starlark
30+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
31+
http_archive(
32+
name = "rules_kotlin",
33+
sha256 = "${SHA}",
34+
strip_prefix = "${PREFIX}",
35+
url = "https://github.com/buildfoundation/rules_kotlin/releases/download/${TAG}/${ARCHIVE}",
36+
)
37+
EOF
38+
39+
echo "\`\`\`"

CODEOWNERS

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @ahumesky @cgruber @djwhang @timpeut @restingbull
1+
* @ahumesky @cgruber @restingbull @Bencodes @nkoroste

MODULE.bazel

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ remote_android_extensions = use_extension("@bazel_tools//tools/android:android_e
2929
use_repo(remote_android_extensions, "android_gmaven_r8", "android_tools")
3030

3131
# Development dependencies
32+
# TODO(bencodes) A bunch of these dependencies need to be marked as dev_dependencies but before we can do that
33+
# we need to sort out a few cases around how these rules are consumed in various ways.
3234

3335
bazel_dep(name = "rules_jvm_external", version = "5.3")
3436

@@ -67,5 +69,3 @@ use_repo(maven, "kotlin_rules_maven")
6769
bazel_dep(name = "rules_pkg", version = "0.7.0")
6870
bazel_dep(name = "stardoc", version = "0.5.6", repo_name = "io_bazel_stardoc")
6971
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
70-
71-
register_toolchains("@rules_kotlin//kotlin/internal:default_toolchain")

WORKSPACE.bzlmod

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
2-
load("@rules_android//android:rules.bzl", "android_sdk_repository")
3-
4-
maybe(
5-
android_sdk_repository,
6-
name = "androidsdk",
7-
)
1+
android_sdk_repository(name = "androidsdk")

WORKSPACE.dev.bazel

+1-7
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,4 @@ kotlin_repositories()
2323

2424
register_toolchains("@rules_kotlin//kotlin/internal:default_toolchain")
2525

26-
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
27-
load("@rules_android//android:rules.bzl", "android_sdk_repository")
28-
29-
maybe(
30-
android_sdk_repository,
31-
name = "androidsdk",
32-
)
26+
android_sdk_repository(name = "androidsdk")

WORKSPACE.release.bazel

+1-7
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,4 @@ kotlin_repositories()
2323

2424
register_toolchains("@rules_kotlin//kotlin/internal:default_toolchain")
2525

26-
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
27-
load("@rules_android//android:rules.bzl", "android_sdk_repository")
28-
29-
maybe(
30-
android_sdk_repository,
31-
name = "androidsdk",
32-
)
26+
android_sdk_repository(name = "androidsdk")

0 commit comments

Comments
 (0)