Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually generate distribution archives #1032

Merged
merged 9 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ 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}"
SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip | shasum -a 256 | awk '{print $1}')
ARCHIVE="rules_python-$TAG.tar.gz"
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a prefix here and asking users to add strip_prefix in http_archive seem unnecessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing it was done that way to match the github-generated archives? I'm just leaving it as is for now so that it's less config people need to change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of today's incident, there is no point of matching the sha256 of github-generated archives. FYI: rules_go and Gazelle's release archives are independent from github-generated ones too:
https://github.com/bazelbuild/rules_go/releases/tag/v0.38.1
https://github.com/bazelbuild/bazel-gazelle/releases/tag/v0.29.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I know. I'm not trying to match the sha256. I'm just keeping the structure the same, because it's a nicety to not have to change both url and the strip_prefix setting.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for keeping it the same

SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')

cat << EOF
cat > release_notes.txt << EOF
## Using Bzlmod with Bazel 6

Add to your \`MODULE.bazel\` file:
Expand Down Expand Up @@ -65,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")
Expand All @@ -83,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
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Prepare workspace snippet
run: .github/workflows/workspace_snippet.sh > release_notes.txt
- name: Create release archive and notes
run: .github/workflows/create_archive_and_notes.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
fail_on_unmatched_files: true
files: rules_python-*.tar.gz