From c10b1fc9716c2d8e74e4e56878ce5e931d72dffc Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Mon, 30 Jan 2023 22:48:36 +0000 Subject: [PATCH 1/9] Generate tar.gz. manually --- .github/workflows/release.yml | 4 +++- .github/workflows/workspace_snippet.sh | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5b1cde014a..70e69d2d6d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,10 +27,12 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Prepare workspace snippet - run: .github/workflows/workspace_snippet.sh > release_notes.txt + #run: .github/workflows/workspace_snippet.sh > release_notes.txt + run: .github/workflows/workspace_snippet.sh - name: Release uses: softprops/action-gh-release@v1 with: # Use GH feature to populate the changelog automatically generate_release_notes: true body_path: release_notes.txt + files: ${{env.GITHUB_REF_NAME}}.tar.gz diff --git a/.github/workflows/workspace_snippet.sh b/.github/workflows/workspace_snippet.sh index bfc0d8b0e4..4d5f3bcb28 100755 --- a/.github/workflows/workspace_snippet.sh +++ b/.github/workflows/workspace_snippet.sh @@ -20,9 +20,12 @@ set -o errexit -o nounset -o pipefail # https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables TAG=${GITHUB_REF_NAME} PREFIX="rules_python-${TAG}" -SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip | shasum -a 256 | awk '{print $1}') +ARCHIVE="$TAG.tar.gz" +git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE +SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') +#SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip | shasum -a 256 | awk '{print $1}') -cat << EOF +cat > release_notes.txt << EOF ## Using Bzlmod with Bazel 6 Add to your \`MODULE.bazel\` file: From 530777194c9ce8c70bf2ea2598c415a2e321de90 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Mon, 30 Jan 2023 22:59:04 +0000 Subject: [PATCH 2/9] use different name to verify it's uploaded --- .github/workflows/workspace_snippet.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workspace_snippet.sh b/.github/workflows/workspace_snippet.sh index 4d5f3bcb28..407ce43978 100755 --- a/.github/workflows/workspace_snippet.sh +++ b/.github/workflows/workspace_snippet.sh @@ -20,7 +20,7 @@ set -o errexit -o nounset -o pipefail # https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables TAG=${GITHUB_REF_NAME} PREFIX="rules_python-${TAG}" -ARCHIVE="$TAG.tar.gz" +ARCHIVE="$TAG.manual.tar.gz" git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') #SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip | shasum -a 256 | awk '{print $1}') From 21a709281e696f9b2c04c9b83c963112eb7bd5ce Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Mon, 30 Jan 2023 23:04:08 +0000 Subject: [PATCH 3/9] try failing if nothing matches --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 70e69d2d6d..8054a3d4d1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,8 +31,9 @@ jobs: run: .github/workflows/workspace_snippet.sh - name: Release uses: softprops/action-gh-release@v1 + fail_on_unmatched_files: true with: # Use GH feature to populate the changelog automatically generate_release_notes: true body_path: release_notes.txt - files: ${{env.GITHUB_REF_NAME}}.tar.gz + files: *.manual.tar.gz From e89aa38773392c1fd726b42c177eadf48d011eb4 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Mon, 30 Jan 2023 23:14:22 +0000 Subject: [PATCH 4/9] give bad name and see what happens --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8054a3d4d1..57aa019439 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,4 +36,4 @@ jobs: # Use GH feature to populate the changelog automatically generate_release_notes: true body_path: release_notes.txt - files: *.manual.tar.gz + files: fail.manual.tar.gz From ac6cac58707f1234d7a0b23120e556b1bda320e4 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Mon, 30 Jan 2023 23:16:34 +0000 Subject: [PATCH 5/9] fix fail_on_unmatched line --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 57aa019439..56a00389f7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,8 +31,8 @@ jobs: run: .github/workflows/workspace_snippet.sh - name: Release uses: softprops/action-gh-release@v1 - fail_on_unmatched_files: true with: + fail_on_unmatched_files: true # Use GH feature to populate the changelog automatically generate_release_notes: true body_path: release_notes.txt From 23954fe821b613b7d9bb87f4017b1c0e6a8c2947 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Mon, 30 Jan 2023 23:18:19 +0000 Subject: [PATCH 6/9] try using name with known prefix --- .github/workflows/release.yml | 2 +- .github/workflows/workspace_snippet.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 56a00389f7..c5c2de69cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,4 +36,4 @@ jobs: # Use GH feature to populate the changelog automatically generate_release_notes: true body_path: release_notes.txt - files: fail.manual.tar.gz + files: rules_python-*.tar.gz diff --git a/.github/workflows/workspace_snippet.sh b/.github/workflows/workspace_snippet.sh index 407ce43978..a4f6570318 100755 --- a/.github/workflows/workspace_snippet.sh +++ b/.github/workflows/workspace_snippet.sh @@ -20,7 +20,7 @@ set -o errexit -o nounset -o pipefail # https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables TAG=${GITHUB_REF_NAME} PREFIX="rules_python-${TAG}" -ARCHIVE="$TAG.manual.tar.gz" +ARCHIVE="rules_python-$TAG.tar.gz" git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') #SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip | shasum -a 256 | awk '{print $1}') From 290ed6fe4f74ceaf987a1beecc2279e696b1db68 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Mon, 30 Jan 2023 23:45:48 +0000 Subject: [PATCH 7/9] cleanup for pr --- .github/workflows/create_archive_and_notes.sh | 91 +++++++++++++++++++ .github/workflows/release.yml | 7 +- .github/workflows/workspace_snippet.sh | 5 +- 3 files changed, 98 insertions(+), 5 deletions(-) create mode 100755 .github/workflows/create_archive_and_notes.sh mode change 100755 => 100644 .github/workflows/workspace_snippet.sh diff --git a/.github/workflows/create_archive_and_notes.sh b/.github/workflows/create_archive_and_notes.sh new file mode 100755 index 0000000000..29d9e88ca1 --- /dev/null +++ b/.github/workflows/create_archive_and_notes.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +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} +PREFIX="rules_python-${TAG}" +ARCHIVE="rules_python-$TAG.tar.gz" +git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE +SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') + +cat > release_notes.txt << EOF +## Using Bzlmod with Bazel 6 + +Add to your \`MODULE.bazel\` file: + +\`\`\`starlark +bazel_dep(name = "rules_python", version = "${TAG}") + +pip = use_extension("@rules_python//python:extensions.bzl", "pip") + +pip.parse( + name = "pip", + requirements_lock = "//:requirements_lock.txt", +) + +use_repo(pip, "pip") + +# (Optional) Register a specific python toolchain instead of using the host version +python = use_extension("@rules_python//python:extensions.bzl", "python") + +python.toolchain( + name = "python3_9", + python_version = "3.9", +) + +use_repo(python, "python3_9_toolchains") + +register_toolchains( + "@python3_9_toolchains//:all", +) +\`\`\` + +## Using WORKSPACE + +Paste this snippet into your \`WORKSPACE\` file: + +\`\`\`starlark +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "rules_python", + sha256 = "${SHA}", + strip_prefix = "${PREFIX}", + url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/${TAG}.tar.gz", +) + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() +\`\`\` + +### Gazelle plugin + +Paste this snippet into your \`WORKSPACE\` file: + +\`\`\`starlark +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +http_archive( + name = "rules_python_gazelle_plugin", + sha256 = "${SHA}", + strip_prefix = "${PREFIX}/gazelle", + url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/${TAG}.tar.gz", +) +\`\`\` +EOF diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c5c2de69cc..1e89fa85a2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,14 +26,13 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - name: Prepare workspace snippet - #run: .github/workflows/workspace_snippet.sh > release_notes.txt - run: .github/workflows/workspace_snippet.sh + - name: Create release archive and notes + run: .github/workflows/create_archive_and_notes.sh - name: Release uses: softprops/action-gh-release@v1 with: - fail_on_unmatched_files: true # Use GH feature to populate the changelog automatically generate_release_notes: true body_path: release_notes.txt + fail_on_unmatched_files: true files: rules_python-*.tar.gz diff --git a/.github/workflows/workspace_snippet.sh b/.github/workflows/workspace_snippet.sh old mode 100755 new mode 100644 index a4f6570318..581dc5a517 --- a/.github/workflows/workspace_snippet.sh +++ b/.github/workflows/workspace_snippet.sh @@ -20,10 +20,13 @@ set -o errexit -o nounset -o pipefail # https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables TAG=${GITHUB_REF_NAME} PREFIX="rules_python-${TAG}" +# We generate our own .tar.gz file because the GitHub generated archives +# may change in subtle ways, e.g. GitHub might change the compression +# algorithm, which then changes the checksum, which then invalidates +# people's http_archive configs. ARCHIVE="rules_python-$TAG.tar.gz" git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') -#SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip | shasum -a 256 | awk '{print $1}') cat > release_notes.txt << EOF ## Using Bzlmod with Bazel 6 From 8b75fa68c82cb595e13c4a994d72e986bbcb3315 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Tue, 31 Jan 2023 00:03:11 +0000 Subject: [PATCH 8/9] fix urls in release note; doc why prefix is added --- .github/workflows/create_archive_and_notes.sh | 5 +- .github/workflows/workspace_snippet.sh | 95 ------------------- 2 files changed, 3 insertions(+), 97 deletions(-) delete mode 100644 .github/workflows/workspace_snippet.sh diff --git a/.github/workflows/create_archive_and_notes.sh b/.github/workflows/create_archive_and_notes.sh index 29d9e88ca1..37fa36f9cd 100755 --- a/.github/workflows/create_archive_and_notes.sh +++ b/.github/workflows/create_archive_and_notes.sh @@ -19,6 +19,7 @@ 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} +# A prefix is added to better match the GitHub generated archives. PREFIX="rules_python-${TAG}" ARCHIVE="rules_python-$TAG.tar.gz" git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE @@ -67,7 +68,7 @@ http_archive( name = "rules_python", sha256 = "${SHA}", strip_prefix = "${PREFIX}", - url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/${TAG}.tar.gz", + url = "https://github.com/bazelbuild/rules_python/releases/download/${TAG}/rules_python-${TAG}.tar.gz", ) load("@rules_python//python:repositories.bzl", "py_repositories") @@ -85,7 +86,7 @@ http_archive( name = "rules_python_gazelle_plugin", sha256 = "${SHA}", strip_prefix = "${PREFIX}/gazelle", - url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/${TAG}.tar.gz", + url = "https://github.com/bazelbuild/rules_python/releases/download/${TAG}/rules_python-${TAG}.tar.gz", ) \`\`\` EOF diff --git a/.github/workflows/workspace_snippet.sh b/.github/workflows/workspace_snippet.sh deleted file mode 100644 index 581dc5a517..0000000000 --- a/.github/workflows/workspace_snippet.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -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} -PREFIX="rules_python-${TAG}" -# We generate our own .tar.gz file because the GitHub generated archives -# may change in subtle ways, e.g. GitHub might change the compression -# algorithm, which then changes the checksum, which then invalidates -# people's http_archive configs. -ARCHIVE="rules_python-$TAG.tar.gz" -git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE -SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') - -cat > release_notes.txt << EOF -## Using Bzlmod with Bazel 6 - -Add to your \`MODULE.bazel\` file: - -\`\`\`starlark -bazel_dep(name = "rules_python", version = "${TAG}") - -pip = use_extension("@rules_python//python:extensions.bzl", "pip") - -pip.parse( - name = "pip", - requirements_lock = "//:requirements_lock.txt", -) - -use_repo(pip, "pip") - -# (Optional) Register a specific python toolchain instead of using the host version -python = use_extension("@rules_python//python:extensions.bzl", "python") - -python.toolchain( - name = "python3_9", - python_version = "3.9", -) - -use_repo(python, "python3_9_toolchains") - -register_toolchains( - "@python3_9_toolchains//:all", -) -\`\`\` - -## Using WORKSPACE - -Paste this snippet into your \`WORKSPACE\` file: - -\`\`\`starlark -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "rules_python", - sha256 = "${SHA}", - strip_prefix = "${PREFIX}", - url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/${TAG}.tar.gz", -) - -load("@rules_python//python:repositories.bzl", "py_repositories") - -py_repositories() -\`\`\` - -### Gazelle plugin - -Paste this snippet into your \`WORKSPACE\` file: - -\`\`\`starlark -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -http_archive( - name = "rules_python_gazelle_plugin", - sha256 = "${SHA}", - strip_prefix = "${PREFIX}/gazelle", - url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/${TAG}.tar.gz", -) -\`\`\` -EOF From a90f06d59c761c2c806e028ac65d410d204cc40e Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Tue, 31 Jan 2023 17:00:09 +0000 Subject: [PATCH 9/9] Remove whitespace to trigger CI --- .github/workflows/create_archive_and_notes.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/create_archive_and_notes.sh b/.github/workflows/create_archive_and_notes.sh index 37fa36f9cd..549af074eb 100755 --- a/.github/workflows/create_archive_and_notes.sh +++ b/.github/workflows/create_archive_and_notes.sh @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. - set -o errexit -o nounset -o pipefail # Set by GH actions, see