From 993a90cef93e0a4d2773180bbae6e81ccd68f6e6 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Tue, 14 Feb 2023 06:03:47 -0800 Subject: [PATCH] release: publish release archive (#137) GitHub's stability guarantee for the archive is iffy, and we want metrics on downloads. See https://github.com/bazel-contrib/SIG-rules-authors/issues/11#issuecomment-1411222578 --- .github/workflows/release.yml | 6 ++++-- .../workflows/{workspace_snippet.sh => release_prep.sh} | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) rename .github/workflows/{workspace_snippet.sh => release_prep.sh} (73%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f21c3ca..379b8db9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,8 +19,8 @@ jobs: # Bazelisk will download bazel to here XDG_CACHE_HOME: ~/.cache/bazel-repo run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //... - - name: Prepare workspace snippet - run: .github/workflows/workspace_snippet.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt + - name: Prepare release + run: .github/workflows/release_prep.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt - name: Release uses: softprops/action-gh-release@v1 with: @@ -28,3 +28,5 @@ jobs: # Use GH feature to populate the changelog automatically generate_release_notes: true body_path: release_notes.txt + files: rules_jvm-*.tar.gz + fail_on_unmatched_files: true diff --git a/.github/workflows/workspace_snippet.sh b/.github/workflows/release_prep.sh similarity index 73% rename from .github/workflows/workspace_snippet.sh rename to .github/workflows/release_prep.sh index 6bdba68a..f842b496 100755 --- a/.github/workflows/workspace_snippet.sh +++ b/.github/workflows/release_prep.sh @@ -4,8 +4,11 @@ set -eufo 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="rules_jvm-${TAG:1}" -SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip | shasum -a 256 | awk '{print $1}') +ARCHIVE="rules_jvm-$TAG.tar.gz" +git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE +SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') cat << EOF WORKSPACE snippet: @@ -15,7 +18,7 @@ http_archive( name = "contrib_rules_jvm", sha256 = "${SHA}", strip_prefix = "${PREFIX}", - url = "https://github.com/bazel-contrib/rules_jvm/archive/refs/tags/${TAG}.tar.gz", + url = "https://github.com/bazel-contrib/rules_jvm/releases/download/${TAG}/${ARCHIVE}", ) # Fetches the contrib_rules_jvm dependencies.