You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+67-8Lines changed: 67 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ Language/content agnostic method of automatically determining the [semantic vers
12
12
13
13
This is accomplished by counting the merges of branches matching the [naming scheme](#branch-naming-scheme) into the [main|master] branch. Folks familiar with Scrum/SAFe or GitFlow/fooFlow strategies will recognize this scheme.
14
14
15
-
**Burning Questions**
15
+
## Burning Questions
16
16
17
17
-**Yes** - This can indeed be implemented in repos that previously used different version increment methods.
18
18
-**Yes** - Jira will recognize the issue tag anywhere in the branch name -- it does not have to be a prefix for the integration to function.
@@ -22,6 +22,7 @@ This is accomplished by counting the merges of branches matching the [naming sch
22
22
23
23
## Recent Changes
24
24
25
+
- 1.1.0: Squash-merge support (PR/MR classified via semver labels), GitLab label lookups, hard-fail on label lookup errors (592), and parallel full-history re-evaluation.
25
26
- 1.0.0: (non-breaking) Addition of support for mono-repos. IE: Discretely version specific directories.
26
27
- NOTE: Github, Jira, etc., were designed to host one product per repo/project. DO NOT create new mono-repo projects unless you're specifically tooling out to support them well.
27
28
- 0.3.1: Update the checkout action version to v4.
@@ -73,6 +74,16 @@ Note: Only required for setting up mono-repo versioning.
73
74
Eg: path/to/bob<br>
74
75
<i>Required:</i> if mono-repo-mode: true<br>
75
76
<i>Default:</i> ''</dd>
77
+
<dt>pr-label-overrides: [string]</dt>
78
+
<dd>Optional debug input for supplying PR label overrides manually.<br>
79
+
Format: '123=semver:patch;124=semver:minor'<br>
80
+
<i>Required:</i> false<br>
81
+
<i>Default:</i> ''</dd>
82
+
<dt>force-re-evaluate: [bool]</dt>
83
+
<dd>Forces a re-evaluation of the entire git history.<br>
84
+
Commit classification runs in parallel using nproc-1 jobs (minimum 1).<br>
85
+
<i>Required:</i> false<br>
86
+
<i>Default:</i> false</dd>
76
87
<dt>force-patch-increment: [bool]</dt>
77
88
<dd>Forces a PATCH increment if no other increment detected.<br>
78
89
(Intended for development purposes only.)<br>
@@ -123,6 +134,7 @@ To make use of the mono-repo support, simply add a block for the director you wi
@@ -211,19 +223,48 @@ This action depends _only_ on the following _branch naming scheme_ being observe
211
223
212
224
For example, the name of the branch for a new awesome feature named Awesome Feature, might be: 'feature/awesome_feature'.
213
225
226
+
### PR Label Precedence
227
+
228
+
When a merged PR has one of the labels 'semver:patch', 'semver:minor', 'semver:major', or 'semver:breaking', that label takes precedence over the branch name for bump selection.
229
+
230
+
Label lookup support by platform:
231
+
232
+
<dl>
233
+
<dt>GitHub</dt>
234
+
<dd>Native label lookup. Requires GITHUB_TOKEN (or AUTOVER_GITHUB_TOKEN) and GITHUB_REPOSITORY.</dd>
<dd>Bitbucket Cloud has no PR labels. Use 'pr-label-overrides' or AUTOVER_PR_LABEL_OVERRIDES.</dd>
239
+
</dl>
240
+
241
+
If a label lookup is configured (credentials present) but cannot complete, the run fails with error 592 rather than silently falling back to branch-name classification.
242
+
243
+
### Squash Merges
244
+
245
+
Squash merges are supported where the PR/MR number can be recovered from the commit:
246
+
247
+
- GitHub: squash commit subjects retain the PR number as a '(#123)' suffix.
248
+
- Bitbucket: commit subjects use 'Merged in <branch> (pull request #123)'.
249
+
- GitLab: the MR reference ('!123') is read from the commit subject or body.
250
+
251
+
Since a squashed commit does not carry the source branch name, classification of squash merges relies on semver labels (or overrides). Unlabeled squash merges are ignored.
252
+
214
253
## Appropriate Use Cases
215
254
216
255
This action is _most_ suitable for git projects with the following operational design:
217
256
218
257
- Each merge into main|master is intended to produce an artifact, following the "everything is potentially releasabe" approach.
219
258
220
259
This action is _not_ suitable for projects requiring:
221
-
- pre-release, beta, etc., type fields. Such projects should depend upon their own language native tooling.
222
-
- specific version numbers to be planned and orchestrated ahead of time (usually marketing efforts).
223
-
- Exception: Major releases. These can be actioned on demand as outlined below.
224
-
- rebase merges. Reminder: this action _depends_ on merge commit messages.
- As long as main|master gets a merge commit message, everyone is happy.
267
+
- Exception: Squash merges where the PR carries a semver label (see Squash Merges above).
227
268
228
269
## Version Format
229
270
@@ -246,11 +287,13 @@ This increment can be accomplished in one of the following ways:
246
287
git tag 1.0.0
247
288
git push --tags
248
289
290
+
In mono-repo mode, the MAJOR indicator must appear on a commit that touches the scoped directory, otherwise that product's history will not include it.
291
+
249
292
## Version Increment Logic
250
293
251
294
For those interested, here's some pseudo code:
252
295
253
-
lastMajor = Extract from previous git tag (why option 1 is recommended)
296
+
lastMajor = Extract from previous git tag on the repo or scoped directory history
254
297
lastMinor = Extract from previous git tag
255
298
lastPatch = Extract from previous git tag
256
299
IF no previous git tag; THEN
@@ -261,6 +304,8 @@ For those interested, here's some pseudo code:
261
304
MAJOR = lastMajor + 1
262
305
MINOR = 0
263
306
PATCH = 0
307
+
ELSEIF merged PR has a semver label; THEN
308
+
use that label's bump instead of the branch name
264
309
ELSEIF merged feature/.* or enhancement/.* branches; THEN
265
310
MAJOR = lastMajor
266
311
MINOR = lastMinor + count of merged branches
@@ -278,6 +323,20 @@ For those interested, here's some pseudo code:
278
323
279
324
- When encountering this scenario, and a build is desired, you can simply create a branch with the appropriate naming convention and an empty commit, then merge it. Or use the bump scripts in the 'scripts/' directory of the repo for this action.
280
325
326
+
- If a PR/MR label lookup is configured but fails (network, auth, etc.), the action fails with:
327
+
328
+
ERROR: 592 - PR/MR label lookup failed!
329
+
330
+
This is intentional: a version must never be computed from incomplete label data.
331
+
332
+
## Local Testing
333
+
334
+
Run the isolated test harness locally with:
335
+
336
+
bash scripts/tests.sh
337
+
338
+
The script creates a temporary git repository, exercises repo and directory versioning paths, validates PR label precedence, squash-merge classification, and parallel full-history re-evaluation, and removes the fixture repo on exit. The same suite runs in CI on every pull request.
339
+
281
340
- Merged branches not conforming to the above naming scheme will simply be ignored.
282
341
- HINT: This can be useful when you don't want to increment the version.
283
342
- Align this with build 'on:push:branches:' workflow configuration to avoid unnecessary builds.
0 commit comments