-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(release): automate release archive and publish on GitHub Actions
- Loading branch information
Showing
4 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <<EOF | ||
# Omit folders that users don't need, making the distribution artifact smaller | ||
examples export-ignore | ||
# Substitution for the _VERSION placeholder in version.bzl | ||
version.bzl export-subst | ||
EOF | ||
|
||
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 | ||
## 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters