Skip to content

Commit 98296da

Browse files
committed
Add release automation
See `RELEASING.md` for directions
1 parent dbfcc76 commit 98296da

File tree

7 files changed

+194
-28
lines changed

7 files changed

+194
-28
lines changed

Makefile.toml

Lines changed: 82 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,90 @@
22
[env]
33
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
44

5-
# Run `cargo make release` to push a new minor release of every crate.
5+
#
6+
# Run `RELEASE_LEVEL=(patch|major|minor) cargo make release` to push a new release of every crate.
7+
# Run `RELEASE_LEVEL=(patch|major|minor) CARGO_MAKE_WORKSPACE_SKIP_MEMBERS="crate1;crate2;" cargo make release`
8+
# to push a new release of some crates.
9+
#
10+
611
[tasks.release]
7-
args = ["release", "--config", "../_build/release.toml"]
12+
condition = { env_set = [ "RELEASE_LEVEL" ] }
13+
workspace = false
14+
env = { "CARGO_MAKE_WORKSPACE_SKIP_MEMBERS" = "integration_tests/*" }
15+
command = "cargo"
16+
args = [ "make", "release-INTERNAL" ]
17+
18+
[tasks.release-some]
19+
condition = { env_set = [ "RELEASE_LEVEL", "CARGO_MAKE_WORKSPACE_SKIP_MEMBERS" ] }
20+
workspace = false
21+
env = { "CARGO_MAKE_WORKSPACE_SKIP_MEMBERS" = "integration_tests/*" }
22+
command = "cargo"
23+
args = [ "make", "release-INTERNAL" ]
24+
25+
# Hack to filter out crates we do not want to release.
26+
# See <https://github.com/sagiegurari/cargo-make/issues/212#issuecomment-481123564>
27+
[tasks.release-INTERNAL]
28+
private = true
29+
condition = { env_set = [ "RELEASE_LEVEL" ] }
30+
command = "cargo-release"
31+
args = ["release", "--config", "../_build/release.toml", "minor"]
832

9-
# Run `cargo make release-patch` to push a new patch release of every crate.
10-
[tasks.release-patch]
11-
args = ["release", "--config", "../_build/release.toml", "patch"]
1233

13-
# Run `cargo make release-dry-run` to do a dry run.
34+
#
35+
# Run `RELEASE_LEVEL=(patch|major|minor) cargo make release-dry-run` to do a dry run.
36+
# Run `RELEASE_LEVEL=(patch|major|minor) CARGO_MAKE_WORKSPACE_SKIP_MEMBERS="crate1;crate2;" cargo make release-some-dry-run`
37+
# to do a dry run with some crates.
38+
#
39+
1440
[tasks.release-dry-run]
41+
condition = { env_set = [ "RELEASE_LEVEL" ] }
42+
workspace = false
43+
env = { "CARGO_MAKE_WORKSPACE_SKIP_MEMBERS" = "integration_tests/*" }
44+
command = "cargo"
45+
args = [ "make", "release-dry-run-INTERNAL" ]
46+
47+
[tasks.release-some-dry-run]
48+
condition = { env_set = [ "CARGO_MAKE_WORKSPACE_SKIP_MEMBERS", "RELEASE_LEVEL" ] }
49+
workspace = false
50+
command = "cargo"
51+
args = [ "make", "release-dry-run-INTERNAL" ]
52+
53+
54+
# Hack to filter out crates we do not want to release.
55+
# See <https://github.com/sagiegurari/cargo-make/issues/212#issuecomment-481123564>
56+
[tasks.release-dry-run-INTERNAL]
57+
private = true
58+
condition = { env_set = [ "RELEASE_LEVEL" ] }
59+
env = { "CARGO_MAKE_WORKSPACE_SKIP_MEMBERS" = "integration_tests/*" }
1560
description = "Run `cargo-release --dry-run` for every crate"
16-
command = "${HOME}/src/cargo-release/target/debug/cargo-release"
17-
args = ["release", "--config", "../_build/release.toml", "--dry-run"]
61+
command = "cargo-release"
62+
args = ["release", "--config", "../_build/release.toml", "--dry-run", "${RELEASE_LEVEL}"]
63+
64+
#
65+
# Run `RELEASE_LEVEL=(patch|major|minor) cargo make release-local-test` to do actually make changes locally but
66+
# not push them up to crates.io or Github.
67+
# Run `RELEASE_LEVEL=(patch|major|minor) cargo make release-some-local-test` to do actually make changes locally but
68+
# not push some crates up to crates.io or Github.
69+
#
70+
71+
[tasks.release-local-test]
72+
condition = { env_set = [ "RELEASE_LEVEL" ] }
73+
workspace = false
74+
env = { "CARGO_MAKE_WORKSPACE_SKIP_MEMBERS" = "integration_tests/*" }
75+
command = "cargo"
76+
args = [ "make", "release-local-test-INTERNAL" ]
77+
78+
[tasks.release-some-local-test]
79+
condition = { env_set = [ "CARGO_MAKE_WORKSPACE_SKIP_MEMBERS", "RELEASE_LEVEL" ] }
80+
workspace = false
81+
command = "cargo"
82+
args = [ "make", "release-local-test-INTERNAL" ]
83+
84+
# Hack to filter out crates we do not want to release.
85+
# See <https://github.com/sagiegurari/cargo-make/issues/212#issuecomment-481123564>
86+
[tasks.release-local-test-INTERNAL]
87+
private = true
88+
condition = { env_set = [ "RELEASE_LEVEL" ] }
89+
description = "Run `cargo-release` for every crate, but only make changes locally"
90+
command = "cargo-release"
91+
args = ["release", "--config", "../_build/release.toml", "--skip-publish", "--skip-push", "--skip-tag", "${RELEASE_LEVEL}"]

RELEASING.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# How to release new crate versions
2+
3+
## Prerequisites
4+
5+
We use [`cargo-make`](cargo-make) and [`cargo-release`](cargo-release) to automate crate releases. You will need to install them locally:
6+
7+
- `cargo install -f cargo-make`
8+
- `cargo install -f cargo-release`
9+
10+
## Preparing for a release
11+
12+
There are two general classes of release and each require running different automation commands:
13+
14+
1. All public workspace crates should be released and all share the same release level ("patch", "minor", "major"). _These commands take the form `release-[whatever]`._
15+
16+
2. A subset of workspace crates need to be released, or not all crate releases share the same release level. _These commands start with `release-skip-[whatever]`._
17+
18+
## Determine new release level
19+
20+
For each crate, determine the desired release level (`patch`, `minor`, `major`). Set the `RELEASE_LEVEL` env variable to the desired release level.
21+
22+
## Determine which crates to exclude
23+
24+
If a subset of workspace crates need to be released, or not all crate releases share the same release level, set the `CARGO_MAKE_WORKSPACE_SKIP_MEMBERS` env
25+
variable to filter out specific workspace crates. The value is a list of semicolon-delineated crate names or a regular expression.
26+
27+
**Important:** You likely want to always exclude `integration_tests/*`.
28+
29+
## Dry run
30+
31+
It is a good idea to do a dry run to sanity check what actions will be performed.
32+
33+
- For case #1 above, run `cargo make release-dry-run`.
34+
35+
If the command finishes super quickly with no output you likely did not set `RELEASE_LEVEL`.
36+
37+
- For case #2 above, run `cargo make release-some-dry-run`.
38+
39+
If the command finishes super quickly with no output you likely did not set `RELEASE_LEVEL` or `CARGO_MAKE_WORKSPACE_SKIP_MEMBERS`.
40+
41+
## Local test
42+
43+
Not everything is captured in the dry run. It is a good idea to run a local test.
44+
In a local test, all the release actions are performed on your local checkout
45+
but nothing is pushed to Github or crates.io.
46+
47+
- For case #1 above, run `cargo make release-local-test`.
48+
49+
If the command finishes super quickly with no output you likely did not set `RELEASE_LEVEL`.
50+
51+
- For case #2 above, run `cargo make release-some-local-test`.
52+
53+
If the command finishes super quickly with no output you likely did not set `RELEASE_LEVEL` or `CARGO_MAKE_WORKSPACE_SKIP_MEMBERS`.
54+
55+
After, your local git repository should have the changes ready to push to Github.
56+
Use `git rebase -i HEAD~10` and drop the new commits.
57+
58+
## Release
59+
60+
After testing locally and via a dry run, it is time to release. A release
61+
consists of bumping versions, starting a new changelog section, pushing a tag to Github, and updating crates.io. This should all be handled by running the automated commands.
62+
63+
- For case #1 above, run `cargo make release`.
64+
65+
If the command finishes super quickly with no output you likely did not set `RELEASE_LEVEL`.
66+
67+
- For case #2 above, run `cargo make release-some`.
68+
69+
If the command finishes super quickly with no output you likely did not set `RELEASE_LEVEL` or `CARGO_MAKE_WORKSPACE_SKIP_MEMBERS`.
70+
71+
[cargo-make]: https://github.com/sagiegurari/cargo-make
72+
[cargo-release]: https://github.com/sunng87/cargo-release
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
[tasks.build-verbose]
3+
condition = { rust_version = { min = "1.31.0" } }
4+
5+
[tasks.build-verbose.windows]
6+
condition = { rust_version = { min = "1.31.0" } }
7+
8+
[tasks.test-verbose]
9+
condition = { rust_version = { min = "1.31.0" } }
10+
11+
[tasks.test-verbose.windows]
12+
condition = { rust_version = { min = "1.31.0" } }
13+
14+
[tasks.ci-coverage-flow]
15+
disabled = true
16+
17+
[tasks.release]
18+
disabled = true
19+
[tasks.release-some]
20+
disabled = true
21+
[tasks.release-local-test]
22+
disabled = true
23+
[tasks.release-some-local-test]
24+
disabled = true
25+
[tasks.release-dry-run]
26+
disabled = true
27+
[tasks.release-some-dry-run]
28+
disabled = true

integration_tests/juniper_tests/Makefile.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ args = ["test", "--verbose"]
77

88
[tasks.release]
99
disabled = true
10-
11-
[tasks.release-patch]
10+
[tasks.release-some]
11+
disabled = true
12+
[tasks.release-local-test]
13+
disabled = true
14+
[tasks.release-some-local-test]
1215
disabled = true
13-
1416
[tasks.release-dry-run]
1517
disabled = true
18+
[tasks.release-some-dry-run]
19+
disabled = true

juniper/Makefile.toml

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

juniper_codegen/Makefile.toml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
[tasks.release]
2-
args = ["release"]
3-
4-
[tasks.release-patch]
5-
args = ["release", "patch"]
6-
7-
[tasks.release-dry-run]
8-
args = ["release", "--dry-run"]
1+
# This is needed as the release config is at a different path than the top-level
2+
# release config.
3+
[tasks.release-local-test-INTERNAL]
4+
args = ["release", "--config", "release.toml", "--skip-publish", "--skip-push", "--skip-tag", "${RELEASE_LEVEL}"]

juniper_codegen/release.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ pro-release-commit-message = "Bump {{crate_name}} version to {{next_version}}"
44
tag-message = "Release {{crate_name}} {{version}}"
55
upload-doc = false
66
pre-release-replacements = [
7-
{file="../juniper/Cargo.toml", search="juniper_codegen = { version = \"0.11.0\"", replace="juniper_codegen = { version = \"{{version}}\""},
7+
{file="../juniper/Cargo.toml", search="juniper_codegen = \\{ version = \"0.11.0\"", replace="juniper_codegen = { version = \"{{version}}\""},
88
{file="release.toml", search="0.11.0", replace="{{version}}"},
99
]

0 commit comments

Comments
 (0)