diff --git a/.bcr/source.template.json b/.bcr/source.template.json
index f276fcf..1eb36c0 100644
--- a/.bcr/source.template.json
+++ b/.bcr/source.template.json
@@ -1,5 +1,5 @@
{
- "integrity": "",
- "strip_prefix": "robolectric-bazel-{TAG}",
- "url": "https://github.com/robolectric/robolectric-bazel/archive/refs/tags/{TAG}.tar.gz"
+ "integrity": "**filled during publishing**",
+ "strip_prefix": "{REPO}-{TAG}",
+ "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz"
}
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
new file mode 100644
index 0000000..9e047d6
--- /dev/null
+++ b/.github/workflows/release.yaml
@@ -0,0 +1,18 @@
+# Automatically perform a release whenever a new "release-like" tag is pushed to the repo.
+name: Release
+
+on:
+ push:
+ tags:
+ # Detect tags that look like a release.
+ # Note that we don't use a "v" prefix to help anchor this pattern.
+ # This is purely a matter of preference.
+ - "*.*.*"
+
+jobs:
+ release:
+ # Re-use https://github.com/bazel-contrib/.github/blob/v5/.github/workflows/release_ruleset.yaml
+ uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v5
+ with:
+ prerelease: false
+ release_files: roboelectric-bazel-*.tar.gz
diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh
new file mode 100644
index 0000000..72a514a
--- /dev/null
+++ b/.github/workflows/release_prep.sh
@@ -0,0 +1,55 @@
+#!/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
+readonly 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)
+readonly PREFIX="roboelectric-bazel-${TAG}"
+readonly ARCHIVE="${PREFIX}.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}')
+
+# The stdout of this program will be used as the top of the release notes for this release.
+cat << EOF
+### Bzlmod (MODULE.bazel)
+
+> If using Bazel 6, make sure you set the \`--enable_bzlmod\` flag
+
+\`\`\`starlark
+bazel_dep(name = "rules_robolectric", version = "${TAG}")
+
+bazel_dep(name = "rules_jvm_external", version = "5.3")
+maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
+maven.install(
+ artifacts = [
+ "org.robolectric:robolectric:${TAG}",
+ ],
+ repositories = [
+ "https://maven.google.com",
+ "https://repo1.maven.org/maven2",
+ ],
+)
+use_repo(maven, "maven")
+\`\`\`
+
+### Workspace
+
+Add the `robolectric` and `rules_jvm_external` repositories in your WORKSPACE file:
+
+\`\`\`starlark
+http_archive(
+ name = "robolectric",
+ sha256 = "${SHA}",
+ strip_prefix = "${PREFIX}",
+ urls = ["https://github.com/robolectric/robolectric-bazel/releases/download/${TAG}/${ARCHIVE}"],
+)
+EOF
+
+awk 'f;/--SNIP--/{f=1}' examples/simple/WORKSPACE
+echo "\`\`\`"
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..671a2e4
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,9 @@
+## Releasing
+
+To perform a release, simply tag the commit you wish to release, for example:
+
+```
+roboelectric-bazel$ git fetch
+roboelectric-bazel$ git tag 1.2.3 origin/main
+roboelectric-bazel$ git push origin 1.2.3
+```
diff --git a/MODULE.bazel b/MODULE.bazel
index 1971fb2..2d598ca 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -1,6 +1,9 @@
+"Bazel dependencies"
+
module(
name = "rules_robolectric",
- version = "4.11.1",
+ # Note: the publish-to-BCR app will patch this line to stamp the version being published.
+ version = "0.0.0",
bazel_compatibility = [">=6.0.0"],
compatibility_level = 1,
)
diff --git a/README.md b/README.md
index f6cff92..4609872 100644
--- a/README.md
+++ b/README.md
@@ -8,62 +8,14 @@ projects.
-## Usage
-
-### Bzlmod (MODULE.bazel)
-
-```Python
-bazel_dep(name = "rules_robolectric", version = "4.11.1")
-
-bazel_dep(name = "rules_jvm_external", version = "5.3")
-maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
-maven.install(
- artifacts = [
- "org.robolectric:robolectric:4.11.1",
- ],
- repositories = [
- "https://maven.google.com",
- "https://repo1.maven.org/maven2",
- ],
-)
-use_repo(maven, "maven")
-```
+## Installation
-### Workspace
+Follow instructions in the release notes from the release you use:
+
-Add the `robolectric` and `rules_jvm_external` repositories in your WORKSPACE file:
-
-```python
-http_archive(
- name = "robolectric",
- urls = ["https://github.com/robolectric/robolectric-bazel/archive/refs/tags/4.11.1.tar.gz"],
- strip_prefix = "robolectric-bazel-4.11.1",
- sha256 = "get the sha256 from github releases",
-)
-load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories")
-robolectric_repositories()
-
-http_archive(
- name = "rules_jvm_external",
- strip_prefix = "rules_jvm_external-5.3",
- sha256 = "d31e369b854322ca5098ea12c69d7175ded971435e55c18dd9dd5f29cc5249ac",
- url = "https://github.com/bazelbuild/rules_jvm_external/releases/download/5.3/rules_jvm_external-5.3.tar.gz",
-)
-load("@rules_jvm_external//:defs.bzl", "maven_install")
-maven_install(
- artifacts = [
- "org.robolectric:robolectric:4.11.1",
- ],
- repositories = [
- "https://maven.google.com",
- "https://repo1.maven.org/maven2",
- ],
-)
-```
-
-### And Finally
+## Usage
-Then, in your `android_local_test` targets in the BUILD files, depend on the
+In your `android_local_test` targets in the BUILD files, depend on the
Robolectric targets `@maven//:org_robolectric_robolectric` and
`@robolectric//bazel:android-all`:
diff --git a/examples/simple/WORKSPACE b/examples/simple/WORKSPACE
index d102b2d..f4a2fe2 100644
--- a/examples/simple/WORKSPACE
+++ b/examples/simple/WORKSPACE
@@ -7,10 +7,6 @@ local_repository(
path = "../../",
)
-load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories")
-
-robolectric_repositories()
-
http_archive(
name = "bazel_skylib",
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
@@ -32,6 +28,11 @@ load("@rules_android//android:rules.bzl", "android_sdk_repository")
android_sdk_repository(name = "androidsdk")
+#---SNIP--- Below here is re-used in the workspace snippet published on releases
+load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories")
+
+robolectric_repositories()
+
http_archive(
name = "rules_jvm_external",
sha256 = "d31e369b854322ca5098ea12c69d7175ded971435e55c18dd9dd5f29cc5249ac",