Skip to content

Commit

Permalink
Merge pull request #42 from CodeIntelligenceTesting/bcr
Browse files Browse the repository at this point in the history
Set up "push tag to release" workflow
  • Loading branch information
eed3si9n authored Dec 3, 2023
2 parents 899f8b8 + 16edebf commit 146169b
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 0 deletions.
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Required by the release workflow
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: eed3si9n
email: eed3si9n@gmail.com
15 changes: 15 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"homepage": "https://github.com/bazeltools/bazel_jar_jar",
"maintainers": [
{
"email": "eed3si9n@gmail.com",
"github": "eed3si9n",
"name": "Eugene Yokota"
}
],
"repository": [
"github:bazeltools/bazel_jar_jar"
],
"versions": [],
"yanked_versions": {}
}
17 changes: 17 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
bcr_test_module:
module_path: test
matrix:
platform:
- debian10
- ubuntu2004
- macos
- macos_arm64
- windows
tasks:
run_test_module:
name: Run test module
platform: ${{ platform }}
build_targets:
- //...
test_targets:
- //...
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": "{REPO}-{VERSION}",
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz"
}
1 change: 1 addition & 0 deletions .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Required by the release workflow
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Based on
# https://github.com/bazel-contrib/rules-template/blob/07fefdbc09d7ca2a49d24220e00dac2efc2bf9b7/.github/workflows/release.yml

# 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*.*.*"

jobs:
release:
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v5
with:
release_files: bazel_jar_jar-*.tar.gz
48 changes: 48 additions & 0 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash

# Based on
# https://github.com/bazel-contrib/rules-template/blob/07fefdbc09d7ca2a49d24220e00dac2efc2bf9b7/.github/workflows/release_prep.sh

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="bazel_jar_jar-${TAG:1}"
ARCHIVE="bazel_jar_jar-$TAG.tar.gz"
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')

cat << EOF
## Using Bzlmod
1. Enable with \`common --enable_bzlmod\` in \`.bazelrc\` (default with Bazel 7).
2. Add to your \`MODULE.bazel\` file:
\`\`\`starlark
bazel_dep(name = "bazel_jar_jar", 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 = "bazel_jar_jar",
sha256 = "${SHA}",
strip_prefix = "${PREFIX}",
url = "https://github.com/bazeltools/bazel_jar_jar/releases/download/${TAG}/${ARCHIVE}",
)
load(
"@com_github_johnynek_bazel_jar_jar//:jar_jar.bzl",
"jar_jar_repositories",
)
jar_jar_repositories()
\`\`\`
EOF
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Releasing

As one-time setup, follow the first step of https://github.com/bazel-contrib/publish-to-bcr#how-it-works.

1. Create an annotated tag with `git tag -a v1.2.3`, where the message will be used in the release notes.
2. Push the tag with `git push origin v1.2.3` to trigger the creation of a GitHub pre-release as well as a Bazel Central Registry (BCR) PR.
The PR will be associated with the GitHub account configured in `.bcr/config.yml`.
3. Review the release notes on https://github.com/bazeltools/bazel_jar_jar/releases and mark the release as final.

0 comments on commit 146169b

Please sign in to comment.