Skip to content

Commit

Permalink
Set up boilerplate for rules_android BCR
Browse files Browse the repository at this point in the history
These files were largely copied from [email protected].

PiperOrigin-RevId: 655607429
Change-Id: I3551c06dff48fb6f3251bb9c59932ba38b59cec4
  • Loading branch information
ted-xie authored and copybara-github committed Jul 24, 2024
1 parent f270005 commit 62d1a4f
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 0 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: ahumesky
email: [email protected]
20 changes: 20 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"homepage": "https://github.com/bazelbuild/rules_android",
"maintainers": [
{
"email": "[email protected]",
"github": "ahumesky",
"name": "ahumesky"
},
{
"email": "[email protected]",
"github": "ted-xie",
"name": "tedx"
}
],
"repository": [
"github:bazelbuild/rules_android"
],
"versions": [],
"yanked_versions": {}
}
12 changes: 12 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -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"
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": "rules_android-{TAG}",
"url": "https://github.com/bazelbuild/rules_android/archive/refs/tags/{TAG}.tar.gz"
}
15 changes: 15 additions & 0 deletions .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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"
56 changes: 56 additions & 0 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
@@ -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 "\`\`\`"
1 change: 1 addition & 0 deletions examples/basicapp/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 62d1a4f

Please sign in to comment.