Skip to content

Commit f43e8a2

Browse files
authored
Merge pull request #49 from im-open/SRE-208-Output-No-Pre-Release
SRE-208 - Adding additional outputs when setting prerelease input.
2 parents e87a591 + 0ea69b8 commit f43e8a2

5 files changed

Lines changed: 40 additions & 22 deletions

File tree

README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ For pre-release versions the commits on the current branch are used, and for rel
4242

4343
The action will increment the major version if it identifies any of the following patterns in the commit body or notes:
4444
| Pattern | Examples |
45-
|------------------------------------|------------------------------------|
45+
| ---------------------------------- | ---------------------------------- |
4646
| `/\+semver:\s*(breaking\|major)/i` | +semver:breaking, +semver:major |
4747
| `/BREAKING CHANGES?:?/` | BREAKING CHANGE:, BREAKING CHANGES |
4848

4949
The action will increment the minor version if it identifies any of the following patterns in the commit body or notes:
5050
| Pattern | Examples |
51-
|-----------------------------------|---------------------------------------------------|
51+
| --------------------------------- | ------------------------------------------------- |
5252
| `/\+semver:\s*(feature\|minor)/i` | +semver:feature, +semver:minor |
5353
| `/feat\([^)]*\):\s/` | feat(area): something, feat(): something |
5454
| `/feature\([^)]*\):\s/` | feature(area): something, feature(): something |
@@ -60,7 +60,7 @@ If none of the previous patterns match, the action will increment the patch vers
6060
## Inputs
6161

6262
| Parameter | Is Required | Default | Description |
63-
|--------------------------------|--------------------------------------------------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
63+
| ------------------------------ | ------------------------------------------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
6464
| `tag-prefix` | false | `v` | By default the action strips the prefixes off, but any value provided here will be prepended to the next calculated version.<br/><br/>GitHub indicates it is common practice to prefix your version names with the letter `v` (which is the default). If you do not want a prefix use `tag-prefix: none`. |
6565
| `fallback-to-no-prefix-search` | false | `true` | Flag indicating whether it should fallback to a prefix-less search if no tags are found with the current prefix. Helpful when starting to use prefixes with tags. Accepted values: true\|false. |
6666
| `calculate-prerelease-version` | false | `false` | Flag indicating whether to calculate a pre-release version rather than a release version. Accepts: `true\|false`. |
@@ -71,17 +71,19 @@ If none of the previous patterns match, the action will increment the patch vers
7171

7272
Each of the outputs are available as environment variables and as action outputs.
7373

74-
| Output | Description |
75-
|--------------------------------|-----------------------------------------------------------------|
76-
| `NEXT_VERSION` | The next `major.minor.patch` version |
77-
| `NEXT_VERSION_NO_PREFIX` | The next `major.minor.patch` version without the tag prefix |
78-
| `NEXT_MINOR_VERSION` | The next `major.minor` version |
79-
| `NEXT_MINOR_VERSION_NO_PREFIX` | The next `major.minor` version without the tag prefix |
80-
| `NEXT_MAJOR_VERSION` | The next `major` version |
81-
| `NEXT_MAJOR_VERSION_NO_PREFIX` | The next `major` version without the tag prefix |
82-
| `NEXT_VERSION_SHA` | The SHA of the next version as an environment variable |
83-
| `PRIOR_VERSION` | The previous `major.minor.patch` version |
84-
| `PRIOR_VERSION_NO_PREFIX` | The previous `major.minor.patch` version without the tag prefix |
74+
| Output | Description |
75+
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
76+
| `NEXT_VERSION` | The next `major.minor.patch` version |
77+
| `NEXT_VERSION_NO_PREFIX` | The next `major.minor.patch` version without the tag prefix |
78+
| `NEXT_MINOR_VERSION` | The next `major.minor` version |
79+
| `NEXT_MINOR_VERSION_NO_PREFIX` | The next `major.minor` version without the tag prefix |
80+
| `NEXT_MAJOR_VERSION` | The next `major` version |
81+
| `NEXT_MAJOR_VERSION_NO_PREFIX` | The next `major` version without the tag prefix |
82+
| `NEXT_VERSION_SHA` | The SHA of the next version as an environment variable |
83+
| `PRIOR_VERSION` | The previous `major.minor.patch` version |
84+
| `PRIOR_VERSION_NO_PREFIX` | The previous `major.minor.patch` version without the tag prefix |
85+
| `NEXT_RELEASE_VERSION` | The next `major.minor.patch` release version. This version will not contain the branch when calculating a pre-release version. |
86+
| `NEXT_RELEASE_VERSON_NO_PREFIX` | The next `major.minor.patch` version without the tag prefix. This version will not contain the branch when calculating a pre-release version. |
8587

8688
## Breaking Changes
8789

@@ -116,7 +118,7 @@ jobs:
116118

117119
- id: get-version
118120
# You may also reference just the major version.
119-
uses: im-open/git-version-lite@v3.1.0
121+
uses: im-open/git-version-lite@v3.2.0
120122
with:
121123
calculate-prerelease-version: true
122124
branch-name: ${{ github.head_ref }} # github.head_ref works when the trigger is pull_request
@@ -145,7 +147,7 @@ When creating PRs, please review the following guidelines:
145147
This repo uses [git-version-lite] in its workflows to examine commit messages to determine whether to perform a major, minor or patch increment on merge if [source code] changes have been made. The following table provides the fragment that should be included in a commit message to active different increment strategies.
146148

147149
| Increment Type | Commit Message Fragment |
148-
|----------------|---------------------------------------------|
150+
| -------------- | ------------------------------------------- |
149151
| major | +semver:breaking |
150152
| major | +semver:major |
151153
| minor | +semver:feature |

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ outputs:
5252
PRIOR_VERSION_NO_PREFIX:
5353
description: 'The previous major.minor.patch version without the tag prefix.'
5454

55+
NEXT_RELEASE_VERSION:
56+
description: 'The calculated next release version. This version will not contain the branch when calculating a pre-release version.'
57+
58+
NEXT_RELEASE_VERSION_NO_PREFIX:
59+
description: 'The calculated next release version without the tag prefix. This version will not contain the branch when calculating a pre-release version.'
60+
5561
runs:
5662
using: 'node20'
5763
main: 'dist/index.js'

dist/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5182,7 +5182,8 @@ The base commit was found. The prior release version is: ${priorReleaseVersion}
51825182
priorVersion: priorSemver.toString(),
51835183
nextPatch: nextSemver.toString(),
51845184
nextMinor: `${nextSemver.major}.${nextSemver.minor}`,
5185-
nextMajor: `${nextSemver.major}`
5185+
nextMajor: `${nextSemver.major}`,
5186+
nextPatchReleaseVersion: nextSemver.toString()
51865187
};
51875188
}
51885189
function nextPrereleaseVersion2(
@@ -5219,11 +5220,13 @@ The base commit was found. The prior release version is: ${priorReleaseVersion}
52195220
core2.info(`Cleaned Branch Name: '${label}'`);
52205221
const priorSemver = new SemVer(priorReleaseVersion);
52215222
const nextSemver = new SemVer(prereleaseVersion);
5223+
const nextReleaseSemver = new SemVer(nextReleaseVersion3);
52225224
return {
52235225
priorVersion: priorSemver.toString(),
52245226
nextPatch: nextSemver.toString(),
52255227
nextMinor: `${nextSemver.major}.${nextSemver.minor}`,
5226-
nextMajor: `${nextSemver.major}`
5228+
nextMajor: `${nextSemver.major}`,
5229+
nextPatchReleaseVersion: nextReleaseSemver.toString()
52275230
};
52285231
}
52295232
module2.exports = {
@@ -5281,11 +5284,13 @@ async function run() {
52815284
}
52825285
console.log('version to build:');
52835286
console.log(versionToBuild);
5284-
const { nextPatch, nextMinor, nextMajor, priorVersion } = versionToBuild;
5287+
const { nextPatch, nextMinor, nextMajor, priorVersion, nextPatchReleaseVersion } =
5288+
versionToBuild;
52855289
setTheOutputs('PRIOR_VERSION', priorVersion, tagPrefix);
52865290
setTheOutputs('NEXT_VERSION', nextPatch, tagPrefix);
52875291
setTheOutputs('NEXT_MINOR_VERSION', nextMinor, tagPrefix);
52885292
setTheOutputs('NEXT_MAJOR_VERSION', nextMajor, tagPrefix);
5293+
setTheOutputs('NEXT_RELEASE_VERSION', nextPatchReleaseVersion, tagPrefix);
52895294
} catch (error) {
52905295
const versionTxt = calculatePrereleaseVersion ? 'pre-release' : 'release';
52915296
core.setFailed(

src/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@ async function run() {
6161
console.log('version to build:');
6262
console.log(versionToBuild);
6363

64-
const { nextPatch, nextMinor, nextMajor, priorVersion } = versionToBuild;
64+
const { nextPatch, nextMinor, nextMajor, priorVersion, nextPatchReleaseVersion } =
65+
versionToBuild;
6566
setTheOutputs('PRIOR_VERSION', priorVersion, tagPrefix);
6667
setTheOutputs('NEXT_VERSION', nextPatch, tagPrefix);
6768
setTheOutputs('NEXT_MINOR_VERSION', nextMinor, tagPrefix);
6869
setTheOutputs('NEXT_MAJOR_VERSION', nextMajor, tagPrefix);
70+
setTheOutputs('NEXT_RELEASE_VERSION', nextPatchReleaseVersion, tagPrefix);
6971
} catch (error) {
7072
const versionTxt = calculatePrereleaseVersion ? 'pre-release' : 'release';
7173
core.setFailed(

src/version.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ function nextReleaseVersion(defaultReleaseType, tagPrefix, fallbackToNoPrefixSea
163163
priorVersion: priorSemver.toString(),
164164
nextPatch: nextSemver.toString(),
165165
nextMinor: `${nextSemver.major}.${nextSemver.minor}`,
166-
nextMajor: `${nextSemver.major}`
166+
nextMajor: `${nextSemver.major}`,
167+
nextPatchReleaseVersion: nextSemver.toString()
167168
};
168169
}
169170

@@ -205,11 +206,13 @@ function nextPrereleaseVersion(label, defaultReleaseType, tagPrefix, fallbackToN
205206

206207
const priorSemver = new SemVer(priorReleaseVersion);
207208
const nextSemver = new SemVer(prereleaseVersion);
209+
const nextReleaseSemver = new SemVer(nextReleaseVersion);
208210
return {
209211
priorVersion: priorSemver.toString(),
210212
nextPatch: nextSemver.toString(),
211213
nextMinor: `${nextSemver.major}.${nextSemver.minor}`,
212-
nextMajor: `${nextSemver.major}`
214+
nextMajor: `${nextSemver.major}`,
215+
nextPatchReleaseVersion: nextReleaseSemver.toString()
213216
};
214217
}
215218

0 commit comments

Comments
 (0)