release_flow 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +5 -1
- data/lib/release_flow/cli.rb +8 -4
- data/lib/release_flow/release.rb +19 -3
- data/lib/release_flow/version.rb +1 -1
- data/templates/.github/workflows/next_release.yml.erb +47 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3bff2b3e2d03cfe1491426834aaf6d6ea62744912f53fe5cb52d931735197cc7
|
|
4
|
+
data.tar.gz: 1a5efe4c7d41d50665b1244d31857f2ac473d7f28afc2e4c90a4ce48ac0bd11d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 45e3553b0149460e15ceb63ddc8860e2b2f79ed99f750f269ade2580c613d1e9f4c85e3330d0781c2e8d3639d5de323cc149b92dc4dc6df5b99bebad62b395f6
|
|
7
|
+
data.tar.gz: c08f06f5e0f0238cadf7012bdf635e8974a152b1e3c520af227a2693c5ca95779e3aa7fc6dac8d7c708c44b1532be33e34b1f22e0bfbadf898722b944e7c3cf5
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## 0.2.0
|
|
6
|
+
|
|
7
|
+
- A release PR merged on GitHub is shipped by the release workflow: it publishes `v<name>` and merges `main` back into `next`. `init` keeps a workflow already installed, so copy the template's `ship` job into yours, add the production branch to its `pull_request` branches, and add the `base.ref` line to `prepare`'s condition.
|
|
8
|
+
- `cut` names what keeps `main` out of `next`: an open merge-back, a release merged without being shipped (with the `ship` command that finishes it), or a hotfix needing `bin/release merge-back`.
|
|
9
|
+
- `ship` counts `v<name>` as published when another run published it first.
|
|
10
|
+
|
|
11
|
+
## 0.1.1
|
|
12
|
+
|
|
13
|
+
- `ReleaseFlow::CLI.start` takes a `config:`, so a binstub can add a setting `.release_flow.yml` doesn't carry, such as a fork's template read from elsewhere; `--help` returns instead of exiting mid-parse.
|
|
14
|
+
|
|
5
15
|
## 0.1.0
|
|
6
16
|
|
|
7
17
|
- First release: `bin/release prepare`, `cut`, `ship`, `merge-back` and `check`, extracted from ModelRails; `release_flow init` installs the binstub, the release workflow, the release PR template and the `changelog.d/` README.
|
data/README.md
CHANGED
|
@@ -10,6 +10,9 @@ your branch ──merge──▶ next ──cut──▶ release/<name> ──sh
|
|
|
10
10
|
└──────────────── merge-back ───────────────┘
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
The [release map](docs/release_map.html) draws the same flow as a book being
|
|
14
|
+
written, bound and published. Download it and open it in a browser.
|
|
15
|
+
|
|
13
16
|
- **Changelog entries never conflict.** Each PR adds its entry as a file of
|
|
14
17
|
its own in `changelog.d/`. A release gathers them into `CHANGELOG.md`.
|
|
15
18
|
- **A release is exactly what its notes say.** `cut` takes the integration
|
|
@@ -104,7 +107,8 @@ entry in `changelog.d/`. Then run `bin/release merge-back`.
|
|
|
104
107
|
With the workflow switched on, a release is named whenever a PR merges into
|
|
105
108
|
`next` and none is under way, and cut once CI passes there. If CI fails
|
|
106
109
|
where it would cut, the run fails and says so. Shipping stays a person's
|
|
107
|
-
call
|
|
110
|
+
call: run `bin/release ship`, or merge the release PR on GitHub, and the
|
|
111
|
+
workflow publishes `v<name>` and merges `main` back into `next`.
|
|
108
112
|
|
|
109
113
|
### Set up the release token
|
|
110
114
|
|
data/lib/release_flow/cli.rb
CHANGED
|
@@ -7,14 +7,18 @@ module ReleaseFlow
|
|
|
7
7
|
module CLI
|
|
8
8
|
module_function
|
|
9
9
|
|
|
10
|
-
def start(argv, root:)
|
|
11
|
-
config
|
|
10
|
+
def start(argv, root:, config: nil)
|
|
11
|
+
config ||= Config.load(root)
|
|
12
12
|
options = {}
|
|
13
|
-
|
|
13
|
+
parser = OptionParser.new do |o|
|
|
14
14
|
o.banner = "#{Release::USAGE} (see #{config.guide})"
|
|
15
15
|
o.on("--dry-run", "Print the plan without changing anything") { options[:dry_run] = true }
|
|
16
16
|
o.on("--if-needed", "prepare, cut: when there's nothing to do yet, say so and stop without failing") { options[:if_needed] = true }
|
|
17
|
-
|
|
17
|
+
o.on("-h", "--help", "Show this") { options[:help] = true }
|
|
18
|
+
end
|
|
19
|
+
args = parser.parse(argv)
|
|
20
|
+
return puts(parser.help) || 0 if options[:help]
|
|
21
|
+
|
|
18
22
|
Release.new(options, root: root, config: config).run(*args)
|
|
19
23
|
0
|
|
20
24
|
rescue Error, OptionParser::ParseError => e
|
data/lib/release_flow/release.rb
CHANGED
|
@@ -74,7 +74,7 @@ module ReleaseFlow
|
|
|
74
74
|
open = remote_refs.find { |ref| ref.start_with?("refs/heads/release/") && ref != "refs/heads/#{branch}" }
|
|
75
75
|
raise Error, "#{open.delete_prefix("refs/heads/")} is still open: ship it or delete it before cutting another" if open
|
|
76
76
|
commit, waiting = cut_point(name)
|
|
77
|
-
raise Error, "#{production} isn't in #{integration} yet:
|
|
77
|
+
raise Error, "#{production} isn't in #{integration} yet: #{production_catch_up}" unless ancestor?("origin/#{production}", commit)
|
|
78
78
|
require_passing_ci(commit, name)
|
|
79
79
|
|
|
80
80
|
say("== Cut #{branch} in #{@repo} ==")
|
|
@@ -182,6 +182,17 @@ module ReleaseFlow
|
|
|
182
182
|
|
|
183
183
|
def waiting_to_cut?(name) = name && !shipped?(name) && !branch?("release/#{name}")
|
|
184
184
|
|
|
185
|
+
def production_catch_up
|
|
186
|
+
return "merge the open merge-back PR first" if remote_refs.any? { |ref| ref.start_with?("refs/heads/merge-back/") }
|
|
187
|
+
|
|
188
|
+
merged = JSON.parse(gh("pr", "list", "--base", production, "--state", "merged", "--limit", "30", "--json", "number,headRefName,headRefOid"))
|
|
189
|
+
unshipped = merged.find { |pr| (name = pr["headRefName"][Candidate::BRANCH, 1]) && !shipped?(name) }
|
|
190
|
+
return "run bin/release merge-back" unless unshipped
|
|
191
|
+
|
|
192
|
+
"release #{unshipped["headRefName"][Candidate::BRANCH, 1]} merged without being shipped: " \
|
|
193
|
+
"run bin/release ship #{unshipped["number"]} #{unshipped["headRefOid"][0, 7]} to publish it and merge #{production} back"
|
|
194
|
+
end
|
|
195
|
+
|
|
185
196
|
def require_passing_ci(commit, name)
|
|
186
197
|
runs = JSON.parse(gh("run", "list", "--workflow", @config.ci_workflow, "--commit", commit, "--event", "push", "--json", "status,conclusion"))
|
|
187
198
|
unless runs.any? && runs.all? { |run| run["status"] == "completed" }
|
|
@@ -235,8 +246,13 @@ module ReleaseFlow
|
|
|
235
246
|
|
|
236
247
|
notes = fit(Changelog.section(git("show", "#{commit}:CHANGELOG.md"), name).to_s,
|
|
237
248
|
BODY_LIMIT, "the full list is in CHANGELOG.md at v#{name}")
|
|
238
|
-
gh("release", "create", "v#{name}", "--target", commit, "--title", "Release #{name}", "--notes-file", "-", stdin: notes)
|
|
239
|
-
say(" → merged and published v#{name}")
|
|
249
|
+
err, created = gh("release", "create", "v#{name}", "--target", commit, "--title", "Release #{name}", "--notes-file", "-", stdin: notes, status: true)
|
|
250
|
+
return say(" → merged and published v#{name}") if created
|
|
251
|
+
|
|
252
|
+
fetch
|
|
253
|
+
raise Error, "gh release create failed: #{err}" unless tagged?(name)
|
|
254
|
+
|
|
255
|
+
say(" ✓ v#{name} already published")
|
|
240
256
|
end
|
|
241
257
|
|
|
242
258
|
# Pushes the branch unless a stopped run already did, then opens its PR or finds the open one.
|
data/lib/release_flow/version.rb
CHANGED
|
@@ -4,7 +4,7 @@ name: Next release
|
|
|
4
4
|
on:
|
|
5
5
|
pull_request:
|
|
6
6
|
types: [ closed ]
|
|
7
|
-
branches: [ <%= config.integration_branch %> ]
|
|
7
|
+
branches: [ <%= config.integration_branch %>, <%= config.production_branch %> ]
|
|
8
8
|
# Safe: cut acts only on a push to <%= config.integration_branch %>, checks it out by name, and reads only the run's event and result.
|
|
9
9
|
workflow_run: # jactionlint ignore=dangerous-triggers
|
|
10
10
|
workflows: [ <%= ci_name %> ]
|
|
@@ -20,6 +20,7 @@ jobs:
|
|
|
20
20
|
vars.AUTO_RELEASE == 'true' &&
|
|
21
21
|
github.event_name == 'pull_request' &&
|
|
22
22
|
github.event.pull_request.merged &&
|
|
23
|
+
github.event.pull_request.base.ref == '<%= config.integration_branch %>' &&
|
|
23
24
|
github.event.pull_request.head.repo.full_name == github.repository
|
|
24
25
|
concurrency:
|
|
25
26
|
group: next-release-prepare
|
|
@@ -96,3 +97,48 @@ jobs:
|
|
|
96
97
|
run: |
|
|
97
98
|
gh auth setup-git
|
|
98
99
|
bin/release cut --if-needed
|
|
100
|
+
|
|
101
|
+
# A release PR merged with GitHub's button skips ship's publish and merge-back; this finishes them.
|
|
102
|
+
ship:
|
|
103
|
+
if: >-
|
|
104
|
+
vars.AUTO_RELEASE == 'true' &&
|
|
105
|
+
github.event_name == 'pull_request' &&
|
|
106
|
+
github.event.pull_request.merged &&
|
|
107
|
+
github.event.pull_request.base.ref == '<%= config.production_branch %>' &&
|
|
108
|
+
startsWith(github.event.pull_request.head.ref, 'release/') &&
|
|
109
|
+
github.event.pull_request.head.repo.full_name == github.repository
|
|
110
|
+
concurrency:
|
|
111
|
+
group: next-release-ship
|
|
112
|
+
cancel-in-progress: false
|
|
113
|
+
runs-on: ubuntu-latest
|
|
114
|
+
timeout-minutes: 10
|
|
115
|
+
steps:
|
|
116
|
+
- name: Require the release token
|
|
117
|
+
env:
|
|
118
|
+
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
119
|
+
run: |
|
|
120
|
+
if [ -z "$RELEASE_TOKEN" ]; then
|
|
121
|
+
echo "::error title=RELEASE_TOKEN isn't set::AUTO_RELEASE is on, but this repository has no RELEASE_TOKEN secret, so the merged release can't be published. Add one as <%= config.guide %> says under \"Set up the release token\", or set AUTO_RELEASE to false."
|
|
122
|
+
exit 1
|
|
123
|
+
fi
|
|
124
|
+
|
|
125
|
+
- name: Checkout code
|
|
126
|
+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
127
|
+
with:
|
|
128
|
+
ref: <%= config.production_branch %>
|
|
129
|
+
fetch-depth: 0
|
|
130
|
+
persist-credentials: false
|
|
131
|
+
|
|
132
|
+
- name: Set up Ruby
|
|
133
|
+
uses: ruby/setup-ruby@7f797815d8adceb1c412e7abefdd1ab4abc47a5f # v1.335.0
|
|
134
|
+
with:
|
|
135
|
+
bundler-cache: true
|
|
136
|
+
|
|
137
|
+
- name: Publish the release and merge it back
|
|
138
|
+
env:
|
|
139
|
+
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
140
|
+
PR: ${{ github.event.pull_request.number }}
|
|
141
|
+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
|
142
|
+
run: |
|
|
143
|
+
gh auth setup-git
|
|
144
|
+
bin/release ship "$PR" "$HEAD_SHA"
|