diff --git a/.bcr/source.template.json b/.bcr/source.template.json index 87414bd..2037471 100644 --- a/.bcr/source.template.json +++ b/.bcr/source.template.json @@ -1,5 +1,5 @@ { "integrity": "", - "strip_prefix": "", - "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/rules_jni-{TAG}.tar.gz" + "strip_prefix": "{REPO}-{VERSION}", + "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz" } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..edb8eb9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,15 @@ +# 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@v7 + with: + release_files: rules_jni-*.tar.gz diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh new file mode 100755 index 0000000..80b4442 --- /dev/null +++ b/.github/workflows/release_prep.sh @@ -0,0 +1,38 @@ +#!/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 +TAG=${GITHUB_REF_NAME} +# The prefix is chosen to match what GitHub generates for source archives +PREFIX="with_cfg.bzl-${TAG:1}" +ARCHIVE="with_cfg.bzl-$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\`. +2. Add to your \`MODULE.bazel\` file: + +\`\`\`starlark +bazel_dep(name = "rules_jni", 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_jni", + sha256 = "${SHA}", + strip_prefix = "${PREFIX}", + url = "https://github.com/fmeum/rules_jni/releases/download/${TAG}/${ARCHIVE}", +) +EOF + +echo "\`\`\`"