diff --git a/.bcr/config.yml b/.bcr/config.yml new file mode 100644 index 000000000..acd5c1338 --- /dev/null +++ b/.bcr/config.yml @@ -0,0 +1,3 @@ +fixedReleaser: + login: ahumesky + email: ahumesky@google.com diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json new file mode 100644 index 000000000..fca5bb9cc --- /dev/null +++ b/.bcr/metadata.template.json @@ -0,0 +1,20 @@ +{ + "homepage": "https://github.com/bazelbuild/rules_android", + "maintainers": [ + { + "email": "ahumesky@google.com", + "github": "ahumesky", + "name": "ahumesky" + }, + { + "email": "tedx@google.com", + "github": "ted-xie", + "name": "tedx" + } + ], + "repository": [ + "github:bazelbuild/rules_android" + ], + "versions": [], + "yanked_versions": {} +} diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml new file mode 100644 index 000000000..8d44d58c5 --- /dev/null +++ b/.bcr/presubmit.yml @@ -0,0 +1,12 @@ +bcr_test_module: + module_path: examples/basicapp + matrix: + platform: ["ubuntu2004", "macos", "windows"] + bazel: ["7.2.1", "rolling"] + tasks: + run_test_module: + name: "Verify build targets with bzlmod" + platform: ${{ platform }} + bazel: ${{ bazel }} + build_targets: + - "//java/com/basicapp:basic_app" diff --git a/.bcr/source.template.json b/.bcr/source.template.json new file mode 100644 index 000000000..b784991b6 --- /dev/null +++ b/.bcr/source.template.json @@ -0,0 +1,5 @@ +{ + "integrity": "", + "strip_prefix": "rules_android-{TAG}", + "url": "https://github.com/bazelbuild/rules_android/archive/refs/tags/{TAG}.tar.gz" +} diff --git a/.github/workflows/ci.bazelrc b/.github/workflows/ci.bazelrc new file mode 100644 index 000000000..3b4aad2af --- /dev/null +++ b/.github/workflows/ci.bazelrc @@ -0,0 +1,15 @@ +# 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 + +# 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 new file mode 100644 index 000000000..18fe50782 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,19 @@ +# 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*.*.*" + +permissions: + contents: write + +jobs: + release: + uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v6 + with: + release_files: rules_android-*.tar.gz + bazel_test_command: "cd examples/basicapp && bazel build java/com/basicapp:basic_app" diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh new file mode 100755 index 000000000..cb76d3f15 --- /dev/null +++ b/.github/workflows/release_prep.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# Copyright 2024 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +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 +# This guarantees that users can easily switch from a released artifact to a source archive +# with minimal differences in their code (e.g. strip_prefix remains the same) +PREFIX="rules_android-${TAG:1}" +ARCHIVE="rules_android-$TAG.tar.gz" + +# NB: configuration for 'git archive' is in /.gitattributes +git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE +SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') + +cat << EOF +## Using Bzlmod with Bazel 6 or greater + +1. (Bazel 6 only) Enable with \`common --enable_bzlmod\` in \`.bazelrc\`. +2. Add to your \`MODULE.bazel\` file: + +\`\`\`starlark +bazel_dep(name = "rules_android", 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_android", + sha256 = "${SHA}", + strip_prefix = "${PREFIX}", + url = "https://github.com/bazelbuild/rules_android/releases/download/${TAG}/${ARCHIVE}", +) +EOF + +awk 'f;/--SNIP--/{f=1}' examples/basicapp/WORKSPACE +echo "\`\`\`" diff --git a/examples/basicapp/WORKSPACE b/examples/basicapp/WORKSPACE index 601e6b807..609012213 100644 --- a/examples/basicapp/WORKSPACE +++ b/examples/basicapp/WORKSPACE @@ -26,6 +26,7 @@ local_repository( path = "../..", # rules_android's WORKSPACE relative to this inner workspace ) +# --SNIP--: Everything below this line goes into the example WORKSPACE snippet in the release notes. load("@rules_android//:prereqs.bzl", "rules_android_prereqs") rules_android_prereqs() load("@rules_android//:defs.bzl", "rules_android_workspace")