Skip to content

Commit e0f2f56

Browse files
authored
Manually generate distribution archives (bazel-contrib#1032)
Github has a habit of changing how the automatic source archives are generated (e.g. compression), which changes their checksums, which then breaks users. Instead of risking that happening again, generate the distribution archive as part of the release workflow and upload it to the release. The same mechanism, `git export` is used, so the format and structure is the same as before.
1 parent 488a037 commit e0f2f56

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

.github/workflows/workspace_snippet.sh renamed to .github/workflows/create_archive_and_notes.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
1716
set -o errexit -o nounset -o pipefail
1817

1918
# Set by GH actions, see
2019
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
2120
TAG=${GITHUB_REF_NAME}
21+
# A prefix is added to better match the GitHub generated archives.
2222
PREFIX="rules_python-${TAG}"
23-
SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip | shasum -a 256 | awk '{print $1}')
23+
ARCHIVE="rules_python-$TAG.tar.gz"
24+
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
25+
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
2426

25-
cat << EOF
27+
cat > release_notes.txt << EOF
2628
## Using Bzlmod with Bazel 6
2729
2830
Add to your \`MODULE.bazel\` file:
@@ -65,7 +67,7 @@ http_archive(
6567
name = "rules_python",
6668
sha256 = "${SHA}",
6769
strip_prefix = "${PREFIX}",
68-
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/${TAG}.tar.gz",
70+
url = "https://github.com/bazelbuild/rules_python/releases/download/${TAG}/rules_python-${TAG}.tar.gz",
6971
)
7072
7173
load("@rules_python//python:repositories.bzl", "py_repositories")
@@ -83,7 +85,7 @@ http_archive(
8385
name = "rules_python_gazelle_plugin",
8486
sha256 = "${SHA}",
8587
strip_prefix = "${PREFIX}/gazelle",
86-
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/${TAG}.tar.gz",
88+
url = "https://github.com/bazelbuild/rules_python/releases/download/${TAG}/rules_python-${TAG}.tar.gz",
8789
)
8890
\`\`\`
8991
EOF

.github/workflows/release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ jobs:
2626
steps:
2727
- name: Checkout
2828
uses: actions/checkout@v2
29-
- name: Prepare workspace snippet
30-
run: .github/workflows/workspace_snippet.sh > release_notes.txt
29+
- name: Create release archive and notes
30+
run: .github/workflows/create_archive_and_notes.sh
3131
- name: Release
3232
uses: softprops/action-gh-release@v1
3333
with:
3434
# Use GH feature to populate the changelog automatically
3535
generate_release_notes: true
3636
body_path: release_notes.txt
37+
fail_on_unmatched_files: true
38+
files: rules_python-*.tar.gz

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy