diff --git a/.bcr/README.md b/.bcr/README.md new file mode 100644 index 0000000..44ae7fe --- /dev/null +++ b/.bcr/README.md @@ -0,0 +1,9 @@ +# Bazel Central Registry + +When the ruleset is released, we want it to be published to the +Bazel Central Registry automatically: + + +This folder contains configuration files to automate the publish step. +See +for authoritative documentation about these files. diff --git a/.bcr/config.yml b/.bcr/config.yml new file mode 100644 index 0000000..c78ab7e --- /dev/null +++ b/.bcr/config.yml @@ -0,0 +1,5 @@ +# See https://github.com/bazel-contrib/publish-to-bcr#a-note-on-release-automation + +fixedReleaser: + login: alexeagle + email: alex@aspect.dev diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json new file mode 100644 index 0000000..4d4e3fe --- /dev/null +++ b/.bcr/metadata.template.json @@ -0,0 +1,17 @@ +{ + "homepage": "https://github.com/bazelbuild/rules_license", + "maintainers": [ + { + "github": "aiuto", + "name": "Tony Aiuto" + }, + { + "email": "alex@aspect.dev", + "github": "alexeagle", + "name": "Alex Eagle" + } + ], + "repository": ["github:bazelbuild/rules_license"], + "versions": [], + "yanked_versions": {} +} diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml new file mode 100644 index 0000000..405faef --- /dev/null +++ b/.bcr/presubmit.yml @@ -0,0 +1,13 @@ +matrix: + platform: + - centos7 + - debian10 + - ubuntu2004 + - macos + - windows +tasks: + verify_targets: + name: Verify build targets + platform: ${{ platform }} + build_targets: + - "@rules_license//tests/..." \ No newline at end of file diff --git a/.bcr/source.template.json b/.bcr/source.template.json new file mode 100644 index 0000000..318b0f1 --- /dev/null +++ b/.bcr/source.template.json @@ -0,0 +1,5 @@ +{ + "integrity": "**leave this alone**", + "strip_prefix": "{REPO}-{VERSION}", + "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/rules_license-{TAG}.tar.gz" +} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a09207d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,16 @@ +# 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: + uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v5 + with: + release_files: rules_license-*.tar.gz diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh new file mode 100755 index 0000000..b29efcd --- /dev/null +++ b/.github/workflows/release_prep.sh @@ -0,0 +1,52 @@ +#!/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="rules_license-${TAG}" +readonly ARCHIVE="rules_license-$TAG.tar.gz" + +# Configuration for 'git archive' +# see https://git-scm.com/docs/git-archive/2.40.0#ATTRIBUTES +cat >.git/info/attributes < $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 +## Using bzlmod with Bazel 6 or later: + +1. Add \`common --enable_bzlmod\` to \`.bazelrc\`. + +2. Add to your \`MODULE.bazel\` file: + +\`\`\`starlark +bazel_dep(name = "rules_license", version = "${TAG}") +\`\`\` + +## Using WORKSPACE: + +\`\`\`starlark + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "rules_license", + sha256 = "${SHA}", + strip_prefix = "${PREFIX}", + url = "https://github.com/bazelbuild/rules_license/releases/download/${TAG}/${ARCHIVE}", +) +\`\`\`starlark +EOF diff --git a/MODULE.bazel b/MODULE.bazel index 3d95eba..a5ec02c 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,6 +1,7 @@ module( name = "rules_license", - version = "0.0.7", # Keep in sync with version.bzl + # Note: the publish-to-BCR app will patch this line to stamp the version being published. + version = "0.0.0", compatibility_level = 1, ) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index a5be947..71f7a72 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -31,3 +31,13 @@ implementation. This project follows [Google's Open Source Community Guidelines](https://opensource.google/conduct/). + +## Releasing + +To perform a release, simply tag the commit you wish to release, for example: + +``` +rules_license$ git fetch +rules_license$ git tag 1.2.3 origin/main +rules_license$ git push origin 1.2.3 +``` \ No newline at end of file diff --git a/version.bzl b/version.bzl index b2530e3..5241d01 100644 --- a/version.bzl +++ b/version.bzl @@ -13,4 +13,9 @@ # limitations under the License. """The version of rules_license.""" -version = "0.0.7" +# This is automagically replace by git during git archive using `git export-subst` +# See https://git-scm.com/docs/git-archive/2.29.0#Documentation/git-archive.txt-export-subst +_VERSION_PRIVATE = "$Format:%(describe:tags=true)$" + +# When using rules_license from source rather than from a release artifact, export a placeholder value +version = "0.0.0-unreleased" if _VERSION_PRIVATE.startswith("$Format") else _VERSION_PRIVATE