diff --git a/.bcr/config.yml b/.bcr/config.yml new file mode 100644 index 000000000..e0545a216 --- /dev/null +++ b/.bcr/config.yml @@ -0,0 +1,3 @@ +fixedReleaser: + login: Bencodes + email: ben@ben.cm diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json new file mode 100644 index 000000000..6379769be --- /dev/null +++ b/.bcr/metadata.template.json @@ -0,0 +1,25 @@ +{ + "homepage": "https://github.com/bazelbuild/rules_kotlin", + "maintainers": [ + { + "email": "ben@ben.cm", + "github": "Bencodes", + "name": "Ben Lee" + }, + { + "email": "corbin@mcneely-smith.com", + "github": "restingbull", + "name": "Corbin McNeely-Smith" + }, + { + "email": "nk@snap.com", + "github": "nkoroste", + "name": "Nick Korostelev" + } + ], + "repository": [ + "github:bazelbuild/rules_kotlin" + ], + "versions": [], + "yanked_versions": {} +} diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml new file mode 100644 index 000000000..462beee11 --- /dev/null +++ b/.bcr/presubmit.yml @@ -0,0 +1,12 @@ +matrix: + platform: [ "macos", "ubuntu2004" ] + +tasks: + verify_targets: + name: "Verify build targets" + platform: ${{ platform }} + build_flags: + - "--enable_bzlmod=true" + build_targets: + - "@rules_kotlin//kotlin/..." + - "@rules_kotlin//src/..." diff --git a/.bcr/source.template.json b/.bcr/source.template.json new file mode 100644 index 000000000..967596daf --- /dev/null +++ b/.bcr/source.template.json @@ -0,0 +1,4 @@ +{ + "integrity": "", + "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/rules_kotlin-{TAG}.tar.gz" +} diff --git a/.github/workflows/ci.bazelrc b/.github/workflows/ci.bazelrc new file mode 100644 index 000000000..534a6c010 --- /dev/null +++ b/.github/workflows/ci.bazelrc @@ -0,0 +1,20 @@ +# This file contains Bazel settings to apply on CI only. +# It is referenced with a --bazelrc option in the call to bazel in ci.yaml +common --curses=no +common --enable_bzlmod + +build --verbose_failures +build --worker_verbose + +# Debug where options came from +build --announce_rc +# This directory is configured in GitHub actions to be persisted between runs. +# We do not enable the repository cache to cache downloaded external artifacts +# as these are generally faster to download again than to fetch them from the +# GitHub actions cache. +build --disk_cache=~/.cache/bazel +# Don't rely on test logs being easily accessible from the test runner, +# though it makes the log noisier. +test --test_output=errors +# Allows tests to run bazelisk-in-bazel, since this is the cache folder used +test --test_env=XDG_CACHE_HOME diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9aecf63c7..a740db2b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,45 +1,41 @@ +# 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 Binary Package on: push: tags: - - v* + - "v*.*.*" jobs: - generate: - name: Create release-artifacts + build: runs-on: ubuntu-latest steps: - - name: "Checkout the sources" - uses: actions/checkout@v2.3.1 + - name: Checkout + uses: actions/checkout@v3 + - name: Mount bazel caches + uses: actions/cache@v3 + with: + path: | + ~/.cache/bazel + key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE', 'WORKSPACE.bzlmod') }} + restore-keys: bazel-cache- - name: Install JDK 11 uses: actions/setup-java@v3 with: distribution: "zulu" java-version: "11" - - name: Setup Bazelisk - uses: bazelbuild/setup-bazelisk@v1 - - name: Mount bazel cache - uses: actions/cache@v2 - with: - path: "/home/runner/.cache/bazel" - key: caches-${{ runner.os }}-release - - name: Build release artifact - run: bazelisk build //:rules_kotlin_release - - name: Create release sha256 - run: shasum -a 256 bazel-bin/rules_kotlin_release.tgz > bazel-bin/rules_kotlin_release.tgz.sha256 - - name: Upload bazel-bin/rules_kotlin_release.tgz - uses: svenstaro/upload-release-action@2.2.1 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: bazel-bin/rules_kotlin_release.tgz - asset_name: rules_kotlin_release.tgz - tag: ${{ github.ref }} - overwrite: true - - name: Upload bazel-bin/rules_kotlin_release.tgz.sha256 - uses: svenstaro/upload-release-action@2.2.1 + - name: Prepare release notes and artifacts + env: + # Bazelisk will download bazel to here. + XDG_CACHE_HOME: ~/.cache/bazel-repo + run: .github/workflows/release_prep.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt + - name: Release + uses: softprops/action-gh-release@v1 with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: bazel-bin/rules_kotlin_release.tgz.sha256 - asset_name: rules_kotlin_release.tgz.sha256 - tag: ${{ github.ref }} - overwrite: true + prerelease: true + # Use GH feature to populate the changelog automatically + generate_release_notes: true + body_path: release_notes.txt + fail_on_unmatched_files: true + files: rules_kotlin-*.tar.gz diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh new file mode 100755 index 000000000..21c33d56d --- /dev/null +++ b/.github/workflows/release_prep.sh @@ -0,0 +1,39 @@ +#!/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_kotlin-${TAG:1}" +ARCHIVE="rules_kotlin-$TAG.tar.gz" +bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc build //:rules_kotlin_release +cp bazel-bin/rules_kotlin_release.tgz $ARCHIVE +SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') + +cat << EOF +## Using Bzlmod with Bazel 6 + +1. Enable with \`common --enable_bzlmod\` in \`.bazelrc\`. +2. Add to your \`MODULE.bazel\` file: + +\`\`\`starlark +bazel_dep(name = "rules_kotlin", version = "${TAG:1}") +\`\`\` + +## Using WORKSPACE + +Paste this snippet into your `WORKSPACE.bazel` file: + +\`\`\`starlark +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +http_archive( + name = "rules_kotlin", + sha256 = "${SHA}", + strip_prefix = "${PREFIX}", + url = "https://github.com/buildfoundation/rules_kotlin/releases/download/${TAG}/${ARCHIVE}", +) +EOF + +echo "\`\`\`" diff --git a/CODEOWNERS b/CODEOWNERS index 948fb7e29..f5c9e10da 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @ahumesky @cgruber @djwhang @timpeut @restingbull +* @ahumesky @cgruber @restingbull @Bencodes @nkoroste diff --git a/MODULE.bazel b/MODULE.bazel index 2c8a4a417..00aed8c92 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -29,6 +29,8 @@ remote_android_extensions = use_extension("@bazel_tools//tools/android:android_e use_repo(remote_android_extensions, "android_gmaven_r8", "android_tools") # Development dependencies +# TODO(bencodes) A bunch of these dependencies need to be marked as dev_dependencies but before we can do that +# we need to sort out a few cases around how these rules are consumed in various ways. bazel_dep(name = "rules_jvm_external", version = "5.3") @@ -67,5 +69,3 @@ use_repo(maven, "kotlin_rules_maven") bazel_dep(name = "rules_pkg", version = "0.7.0") bazel_dep(name = "stardoc", version = "0.5.6", repo_name = "io_bazel_stardoc") bazel_dep(name = "rules_proto", version = "5.3.0-21.7") - -register_toolchains("@rules_kotlin//kotlin/internal:default_toolchain") diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod index e8659be81..9cc43bba4 100644 --- a/WORKSPACE.bzlmod +++ b/WORKSPACE.bzlmod @@ -1,7 +1 @@ -load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") -load("@rules_android//android:rules.bzl", "android_sdk_repository") - -maybe( - android_sdk_repository, - name = "androidsdk", -) +android_sdk_repository(name = "androidsdk") diff --git a/WORKSPACE.dev.bazel b/WORKSPACE.dev.bazel index f68db2535..c28227564 100644 --- a/WORKSPACE.dev.bazel +++ b/WORKSPACE.dev.bazel @@ -23,10 +23,4 @@ kotlin_repositories() register_toolchains("@rules_kotlin//kotlin/internal:default_toolchain") -load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") -load("@rules_android//android:rules.bzl", "android_sdk_repository") - -maybe( - android_sdk_repository, - name = "androidsdk", -) +android_sdk_repository(name = "androidsdk") diff --git a/WORKSPACE.release.bazel b/WORKSPACE.release.bazel index f68db2535..c28227564 100644 --- a/WORKSPACE.release.bazel +++ b/WORKSPACE.release.bazel @@ -23,10 +23,4 @@ kotlin_repositories() register_toolchains("@rules_kotlin//kotlin/internal:default_toolchain") -load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") -load("@rules_android//android:rules.bzl", "android_sdk_repository") - -maybe( - android_sdk_repository, - name = "androidsdk", -) +android_sdk_repository(name = "androidsdk")