8000 Simplify release (#587) · axivion/rules_python@0597cdf · GitHub
[go: up one dir, main page]

Skip to content

Commit 0597cdf

Browse files
authored
Simplify release (bazel-contrib#587)
Instead of building our own .tgz file with release artifacts, just let GitHub do it. Makes the release instructions much quicker, and doesn't require a review pass for releases, so we'll do them more frequently. fixes bazel-contrib#586
1 parent da0efdb commit 0597cdf

File tree

13 files changed

+76
-126
lines changed

13 files changed

+76
-126
lines changed

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Cut a release whenever a new tag is pushed to the repo.
2+
name: Release
3+
4+
on:
5+
push:
6+
tags:
7+
- "v*.*.*"
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
- name: bazel test //...
16+
env:
17+
# Bazelisk will download bazel to here
18+
XDG_CACHE_HOME: ~/.cache/bazel-repo
19+
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //...
20+
- name: Prepare workspace snippet
21+
run: .github/workflows/workspace_snippet.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt
22+
- name: Release
23+
uses: softprops/action-gh-release@v1
24+
with:
25+
# Use GH feature to populate the changelog automatically
26+
generate_release_notes: true
27+
body_path: release_notes.txt
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit -o nounset -o pipefail
4+
5+
# Set by GH actions, see
6+
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
7+
TAG=${GITHUB_REF_NAME}
8+
PREFIX="rules_python-${TAG:1}"
9+
SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip | shasum -a 256 | awk '{print $1}')
10+
11+
cat << EOF
12+
WORKSPACE setup:
13+
14+
\`\`\`starlark
15+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
16+
http_archive(
17+
name = "rules_python",
18+
sha256 = "${SHA}",
19+
strip_prefix = "${PREFIX}",
20+
url = "https://github.com/bazelbuild/rules_python/archive/${TAG}.tar.gz",
21+
)
22+
\`\`\`
23+
EOF

BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ filegroup(
2626
name = "distribution",
2727
srcs = [
2828
"BUILD",
29-
"LICENSE",
29+
"WORKSPACE",
3030
"internal_deps.bzl",
3131
"internal_setup.bzl",
3232
"//python:distribution",
3333
"//python/pip_install:distribution",
3434
"//third_party/github.com/bazelbuild/bazel-skylib/lib:distribution",
3535
"//tools:distribution",
3636
],
37-
visibility = ["//distro:__pkg__"],
37+
visibility = ["//examples:__pkg__"],
3838
)
3939

4040
# Reexport of all bzl files used to allow downstream rules to generate docs

DEVELOPING.md

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,11 @@ changes still come under the minor-version digit. So releases with API changes a
1414
those with only bug fixes and other minor changes bump the patch digit.
1515

1616
#### Steps
17-
18-
1. Update `version.bzl` with the new semantic version `X.Y.Z`.
19-
2. Run `bazel build //distro:rules_python-X.Y.Z` to build the distributed tarball.
20-
3. Calculate the Sha256 hash of the tarball. This hash will be used in the `http_archive` rules that download the new release.
21-
1. Example command for OSX: `shasum --algorithm 256 bazel-bin/distro/rules_python-0.1.0.tar.gz`
22-
4. Update nested examples in `examples/*/WORKSPACE` to get the new semantic version with the new `sha256` hash.
23-
5. Create commit called "Release X.Y.Z"
24-
1. ["release 0.1.0"](https://github.com/bazelbuild/rules_python/commit/c8c79aae9aa1b61d199ad03d5fe06338febd0774) is an example commit.
25-
6. Tag that commit as `X.Y.Z`. Eg. `git tag X.Y.Z`
26-
7. Push the commit and the new tag to `main`.
27-
8. Run `bazel build //distro:relnotes` from within workspace and then from repo root run `cat bazel-bin/distro/relnotes.txt` to get the 'install instructions' that are added as release notes.
28-
1. Check the `sha256` value matches the one you calculated earlier.
29-
9. ["Draft a new release"](https://github.com/bazelbuild/rules_python/releases/new) in Github (manual for now), selecting the recently pushed `X.Y.Z` tag.
30-
Upload the release artifact from `rules_python-[version].tar.gz`. Also copy the `relnotes.txt` from step 8, adding anything extra if desired.
17+
1. Determine what will be the next release, following semver.
18+
1. Create a tag and push, e.g. `git tag 0.5.0 upstream/main && git push upstream --tags`
19+
1. Watch the release automation run on https://github.com/bazelbuild/rules_python/actions
3120

3221
#### After release creation in Github
3322

34-
1. Update `README.md` to point at new release.
35-
2. Ping @philwo to get the new release added to mirror.bazel.build. See [this comment on issue #400](https://github.com/bazelbuild/rules_python/issues/400#issuecomment-779159530) for more context.
36-
3. Announce the release in the #python channel in the Bazel slack (bazelbuild.slack.com).
23+
1. Ping @philwo to get the new release added to mirror.bazel.build. See [this comment on issue #400](https://github.com/bazelbuild/rules_python/issues/400#issuecomment-779159530) for more context.
24+
1. Announce the release in the #python channel in the Bazel slack (bazelbuild.slack.com).

README.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,10 @@ contribute](CONTRIBUTING.md) page for information on our development workflow.
3636
## Getting started
3737

3838
To import rules_python in your project, you first need to add it to your
39-
`WORKSPACE` file:
39+
`WORKSPACE` file, using the snippet provided in the
40+
[release you choose](https://github.com/bazelbuild/rules_python/releases)
4041

41-
```python
42-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
43-
http_archive(
44-
name = "rules_python",
45-
url = "https://github.com/bazelbuild/rules_python/releases/download/0.5.0/rules_python-0.5.0.tar.gz",
46-
sha256 = "cd6730ed53a002c56ce4e2f396ba3b3be262fd7cb68339f0377a45e8227fe332",
47-
)
48-
```
49-
50-
To depend on a particular unreleased version (not recommended), you can do:
42+
To depend on a particular unreleased version, you can do:
5143

5244
```python
5345
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

distro/BUILD

Lines changed: 0 additions & 30 deletions
This file was deleted.

examples/pip_install/WORKSPACE

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ http_archive(
1111
],
1212
)
1313

14-
http_archive(
14+
local_repository(
1515
name = "rules_python",
16-
sha256 = "cd6730ed53a002c56ce4e2f396ba3b3be262fd7cb68339f0377a45e8227fe332",
17-
url = "https://github.com/bazelbuild/rules_python/releases/download/0.5.0/rules_python-0.5.0.tar.gz",
16+
path = "../..",
1817
)
1918

2019
load("@rules_python//python:pip.bzl", "pip_install")

examples/pip_parse/WORKSPACE

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
workspace(name = "example_repo")
22

3-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4-
5-
http_archive(
3+
local_repository(
64
name = "rules_python",
7-
sha256 = "cd6730ed53a002c56ce4e2f396ba3b3be262fd7cb68339f0377a45e8227fe332",
8-
url = "https://github.com/bazelbuild/rules_python/releases/download/0.5.0/rules_python-0.5.0.tar.gz",
5+
path = "../..",
96
)
107

118
load("@rules_python//python:pip.bzl", "pip_parse")

examples/py_import/WORKSPACE

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
workspace(name = "py_import")
22

3-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4-
5-
http_archive(
3+
local_repository(
64
name = "rules_python",
7-
sha256 = "cd6730ed53a002c56ce4e2f396ba3b3be262fd7cb68339f0377a45e8227fe332",
8-
url = "https://github.com/bazelbuild/rules_python/releases/download/0.5.0/rules_python-0.5.0.tar.gz",
5+
path = "../..",
96
)
107

118
load("@rules_python//python:pip.bzl", "pip_install")

examples/relative_requirements/WORKSPACE

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
workspace(name = "example_repo")
22

3-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4-
5-
http_archive(
3+
local_repository(
64
name = "rules_python",
7-
sha256 = "cd6730ed53a002c56ce4e2f396ba3b3be262fd7cb68339f0377a45e8227fe332",
8-
url = "https://github.com/bazelbuild/rules_python/releases/download/0.5.0/rules_python-0.5.0.tar.gz",
5+
path = "../..",
96
)
107

118
load("@rules_python//python:pip.bzl", "pip_install")

0 commit comments

Comments
 (0)
0