Skip to content

Commit 62d1a4f

Browse files
ted-xiecopybara-github
authored andcommitted
Set up boilerplate for rules_android BCR
These files were largely copied from rules_android_ndk@v0.1.2. PiperOrigin-RevId: 655607429 Change-Id: I3551c06dff48fb6f3251bb9c59932ba38b59cec4
1 parent f270005 commit 62d1a4f

8 files changed

Lines changed: 131 additions & 0 deletions

File tree

.bcr/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fixedReleaser:
2+
login: ahumesky
3+
email: ahumesky@google.com

.bcr/metadata.template.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"homepage": "https://github.com/bazelbuild/rules_android",
3+
"maintainers": [
4+
{
5+
"email": "ahumesky@google.com",
6+
"github": "ahumesky",
7+
"name": "ahumesky"
8+
},
9+
{
10+
"email": "tedx@google.com",
11+
"github": "ted-xie",
12+
"name": "tedx"
13+
}
14+
],
15+
"repository": [
16+
"github:bazelbuild/rules_android"
17+
],
18+
"versions": [],
19+
"yanked_versions": {}
20+
}

.bcr/presubmit.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
bcr_test_module:
2+
module_path: examples/basicapp
3+
matrix:
4+
platform: ["ubuntu2004", "macos", "windows"]
5+
bazel: ["7.2.1", "rolling"]
6+
tasks:
7+
run_test_module:
8+
name: "Verify build targets with bzlmod"
9+
platform: ${{ platform }}
10+
bazel: ${{ bazel }}
11+
build_targets:
12+
- "//java/com/basicapp:basic_app"

.bcr/source.template.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"integrity": "",
3+
"strip_prefix": "rules_android-{TAG}",
4+
"url": "https://github.com/bazelbuild/rules_android/archive/refs/tags/{TAG}.tar.gz"
5+
}

.github/workflows/ci.bazelrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
4+
# Debug where options came from
5+
build --announce_rc
6+
# This directory is configured in GitHub actions to be persisted between runs.
7+
# We do not enable the repository cache to cache downloaded external artifacts
8+
# as these are generally faster to download again than to fetch them from the
9+
# GitHub actions cache.
10+
build --disk_cache=~/.cache/bazel
11+
# Don't rely on test logs being easily accessible from the test runner,
12+
# though it makes the log noisier.
13+
test --test_output=errors
14+
# Allows tests to run bazelisk-in-bazel, since this is the cache folder used
15+
test --test_env=XDG_CACHE_HOME

.github/workflows/release.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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.
4+
name: Release
5+
6+
on:
7+
push:
8+
tags:
9+
- "v*.*.*"
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
release:
16+
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v6
17+
with:
18+
release_files: rules_android-*.tar.gz
19+
bazel_test_command: "cd examples/basicapp && bazel build java/com/basicapp:basic_app"

.github/workflows/release_prep.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2024 The Bazel Authors. All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -o errexit -o nounset -o pipefail
17+
18+
# Set by GH actions, see
19+
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
20+
TAG=${GITHUB_REF_NAME}
21+
# The prefix is chosen to match what GitHub generates for source archives
22+
# This guarantees that users can easily switch from a released artifact to a source archive
23+
# with minimal differences in their code (e.g. strip_prefix remains the same)
24+
PREFIX="rules_android-${TAG:1}"
25+
ARCHIVE="rules_android-$TAG.tar.gz"
26+
27+
# NB: configuration for 'git archive' is in /.gitattributes
28+
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
29+
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
30+
31+
cat << EOF
32+
## Using Bzlmod with Bazel 6 or greater
33+
34+
1. (Bazel 6 only) Enable with \`common --enable_bzlmod\` in \`.bazelrc\`.
35+
2. Add to your \`MODULE.bazel\` file:
36+
37+
\`\`\`starlark
38+
bazel_dep(name = "rules_android", version = "${TAG:1}")
39+
\`\`\`
40+
41+
## Using WORKSPACE
42+
43+
Paste this snippet into your \`WORKSPACE.bazel\` file:
44+
45+
\`\`\`starlark
46+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
47+
http_archive(
48+
name = "rules_android",
49+
sha256 = "${SHA}",
50+
strip_prefix = "${PREFIX}",
51+
url = "https://github.com/bazelbuild/rules_android/releases/download/${TAG}/${ARCHIVE}",
52+
)
53+
EOF
54+
55+
awk 'f;/--SNIP--/{f=1}' examples/basicapp/WORKSPACE
56+
echo "\`\`\`"

examples/basicapp/WORKSPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ local_repository(
2626
path = "../..", # rules_android's WORKSPACE relative to this inner workspace
2727
)
2828

29+
# --SNIP--: Everything below this line goes into the example WORKSPACE snippet in the release notes.
2930
load("@rules_android//:prereqs.bzl", "rules_android_prereqs")
3031
rules_android_prereqs()
3132
load("@rules_android//:defs.bzl", "rules_android_workspace")

0 commit comments

Comments
 (0)