From 09b970852a410085270696f177b99e7d5365379a Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 30 Sep 2024 20:51:00 +0000 Subject: [PATCH] Add release workflow Signed-off-by: Michael Carroll --- .github/workflows/release.yml | 14 ++++++++++++++ .github/workflows/release_prep.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100755 .github/workflows/release_prep.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4d814ec --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,14 @@ +name: Release +on: + push: + tags: + - "v*.*.*" + +jobs: + release: + uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v6 + permissions: + contents: write + with: + release_files: rules_gz-*.tar.gz + prerelease: false diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh new file mode 100755 index 0000000..6b007e7 --- /dev/null +++ b/.github/workflows/release_prep.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# invoked by release workflow +# (via https://github.com/bazel-contrib/.github/blob/master/.github/workflows/release_ruleset.yaml) + +set -o errexit -o nounset -o pipefail + +RULES_NAME="rules_gz" +TAG="${GITHUB_REF_NAME}" +PREFIX="${RULES_NAME}-${TAG:1}" +ARCHIVE="${RULES_NAME}-${TAG:1}.tar.gz" + +# embed version in MODULE.bazel +perl -pi -e "s/version = \"0\.0\.0\",/version = \"${TAG:1}\",/g" MODULE.bazel + +stash_name=`git stash create`; +git archive --format=tar --prefix=${PREFIX}/ "${stash_name}" | gzip > $ARCHIVE + +SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') + +cat << EOF +Add to your \`MODULE.bazel\` file: + +\`\`\`starlark +bazel_dep(name = "${RULES_NAME}", version = "${TAG:1}") +\`\`\` +EOF