Skip to content

Commit 8fc6e82

Browse files
authored
Merge pull request #32 from michmich112/develop Release 1.1.0
Release 1.1.0
2 parents e60707a + d961a27 commit 8fc6e82

716 files changed

Lines changed: 21081 additions & 36349 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ Example: `main.secondary[->patch]`.\
4848
If we have `main:1`, `secondary:0` ,`patch:0` the resulting version printout will be `1.0`.\
4949
If `patch:1` the resulting version printout will be `1.0->1`.
5050

51+
52+
#### **Optional**: `skip`
53+
Adds [SKIP] prefix to the commit message to prevent CI/CD build.
54+
5155
#### **Required**: `version-file`
5256
File path where the current version can be found.
5357

@@ -199,6 +203,9 @@ interface BumperOptionsFile {
199203
200204
// use for custom scheme definitions
201205
schemeDefinition?: string,
206+
207+
// Add the [SKIP] prefix to skip build
208+
skip?: boolean,
202209
203210
// path file containing the current version
204211
// may include line if other possible matches
@@ -223,6 +230,11 @@ interface BumpRule {
223230
* What items in the version number need to be bumped
224231
*/
225232
bump?: string | string[],
233+
234+
/**
235+
* Prefix to apply on the new version
236+
*/
237+
prefix?: string,
226238
227239
/**
228240
* Reset elements in the version number
@@ -232,6 +244,11 @@ interface BumpRule {
232244
* => 1.2.0
233245
*/
234246
reset?: string | string[],
247+
248+
/**
249+
* Suffix to apply on the new version
250+
*/
251+
suffix?: string,
235252
236253
/**
237254
* Indicate that this bump should add a tag to the commit with the new version number
@@ -248,4 +265,10 @@ interface BumpRule {
248265
```
249266

250267
# Contributors
251-
Thank you to [jamieleecho](https://github.com/jamieleecho) for their help and contributions to the project!
268+
Thank you to
269+
- [jamieleecho](https://github.com/jamieleecho)
270+
- [migueltarga](https://github.com/migueltarga)
271+
for their help and contributions to the project!
272+
273+
# Notes
274+
This action uses the `gh-action-stats` package to track usage. See the data collected at [gh-action-stats-js](https://github.com/michmich112/gh-action-stats-js).

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ inputs:
2525
rules:
2626
description: 'List of versioning rules'
2727
required: false
28+
skip:
29+
description: 'Adds [SKIP] prefix to the commit message to prevent CI/CD build'
30+
required: false
2831
# Github token to commit the bumps
2932
github-token:
3033
description: 'Authorized github token'

dist/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4040
Object.defineProperty(exports, "__esModule", { value: true });
4141
const core = __importStar(require("@actions/core"));
4242
const fs = __importStar(require("fs"));
43+
const gh_action_stats_1 = __importDefault(require("gh-action-stats"));
4344
const options_1 = require("./utils/options");
4445
const readline = __importStar(require("readline"));
4546
const gitUtils_1 = require("./utils/gitUtils");
4647
const Git_1 = __importDefault(require("./lib/Git"));
4748
const SUCCESS = 0, FAILURE = 1;
4849
function main() {
4950
return __awaiter(this, void 0, void 0, function* () {
51+
gh_action_stats_1.default();
5052
if (!core.getInput('github-token')) {
5153
core.error("Github token required");
5254
return FAILURE;
@@ -63,7 +65,7 @@ function main() {
6365
const GIT_OPTIONS = {
6466
userName: 'version-bumper',
6567
userEmail: 'bumper@boringday.co',
66-
message: `Updated version ${state.curVersion} -> ${state.newVersion}.`,
68+
message: state.skip ? '[SKIP] ' : '' + `Updated version ${state.curVersion} -> ${state.newVersion}.`,
6769
tag: state.tag ? { name: state.newVersion } : undefined,
6870
token: core.getInput('github-token'),
6971
branch: state.branch

dist/tests/util.test.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,83 @@ describe("Get Current version from files", () => {
333333
expect(e.message).toBe(`No match found in file. Unable to identify current version number.`);
334334
}
335335
}));
336+
describe("Get current version with prefix", () => {
337+
let filePath = "./src/tests/assets/INTEGRATION_VERSION.txt", options = {
338+
scheme: "org_semantic",
339+
versionFile: { path: filePath, line: 4 },
340+
files: [],
341+
rules: [
342+
{
343+
prefix: "v.",
344+
branch: "prefix_1_branch",
345+
bump: "build",
346+
trigger: "commit"
347+
},
348+
{
349+
prefix: "alpha.",
350+
branch: "prefix_2_branch",
351+
bump: "minor",
352+
trigger: "commit"
353+
},
354+
{
355+
suffix: "-ALPHA",
356+
branch: "suffix_1_branch",
357+
bump: "build",
358+
trigger: "commit"
359+
},
360+
{
361+
suffix: "rc",
362+
branch: "suffix_2_branch",
363+
bump: "minor",
364+
trigger: "commit"
365+
}
366+
]
367+
};
368+
test("Get current version that has Prefix 1", () => __awaiter(void 0, void 0, void 0, function* () {
369+
const version = yield utils_1.getCurVersion(options);
370+
expect(version).toBe("v.1.0.2");
371+
}));
372+
test("Get current version that has Prefix 2", () => __awaiter(void 0, void 0, void 0, function* () {
373+
options.versionFile.line = 5;
374+
const version = yield utils_1.getCurVersion(options);
375+
expect(version).toBe("alpha.2.3.5");
376+
}));
377+
test("Get correct version that has both prefixes in front", () => __awaiter(void 0, void 0, void 0, function* () {
378+
options.versionFile.line = 6;
379+
const version = yield utils_1.getCurVersion(options);
380+
expect(version).toBe("v.2.3.5");
381+
}));
382+
test("Get current version that has Suffix 1", () => __awaiter(void 0, void 0, void 0, function* () {
383+
options.versionFile.line = 7;
384+
const version = yield utils_1.getCurVersion(options);
385+
expect(version).toBe("2.3.5-ALPHA");
386+
}));
387+
test("Get current version that has Suffix 2", () => __awaiter(void 0, void 0, void 0, function* () {
388+
options.versionFile.line = 8;
389+
const version = yield utils_1.getCurVersion(options);
390+
expect(version).toBe("6.7.8rc");
391+
}));
392+
test("Get current version that has Prefix 1 and Suffix 1", () => __awaiter(void 0, void 0, void 0, function* () {
393+
options.versionFile.line = 9;
394+
const version = yield utils_1.getCurVersion(options);
395+
expect(version).toBe("v.1.0.2-ALPHA");
396+
}));
397+
test("Get current version that has Prefix 1 and Suffix 2", () => __awaiter(void 0, void 0, void 0, function* () {
398+
options.versionFile.line = 10;
399+
const version = yield utils_1.getCurVersion(options);
400+
expect(version).toBe("v.4.5.6rc");
401+
}));
402+
test("Get current version that has Prefix 2 and Suffix 1", () => __awaiter(void 0, void 0, void 0, function* () {
403+
options.versionFile.line = 11;
404+
const version = yield utils_1.getCurVersion(options);
405+
expect(version).toBe("alpha.3.5.6-ALPHA");
406+
}));
407+
test("Get current version that has Prefix 2 and Suffix 2", () => __awaiter(void 0, void 0, void 0, function* () {
408+
options.versionFile.line = 12;
409+
const version = yield utils_1.getCurVersion(options);
410+
expect(version).toBe("alpha.7.8.9rc");
411+
}));
412+
});
336413
});
337414
describe("Get optional version items", () => {
338415
test("No Optional case.", () => {
@@ -567,6 +644,20 @@ describe("Bump Version tests", () => {
567644
branch: 'master',
568645
bump: 'major',
569646
reset: ['minor', 'build']
647+
},
648+
// on commit to release-candidate branch, bump major, reset minor and build, add -rc as suffix
649+
{
650+
trigger: 'commit',
651+
branch: 'release-candidate',
652+
bump: 'major',
653+
reset: ['minor', 'build'],
654+
suffix: "-rc"
655+
},
656+
// on commit to branch version-tag, add prefix: v.
657+
{
658+
trigger: 'commit',
659+
branch: 'version-tag',
660+
prefix: "v."
570661
}
571662
]
572663
};
@@ -631,6 +722,16 @@ describe("Bump Version tests", () => {
631722
let newVersion = yield utils_1.bumpVersion(options, 'manual', 'master');
632723
expect(newVersion).toBe('2.0.1');
633724
}));
725+
test("Commit trigger with suffix", () => __awaiter(void 0, void 0, void 0, function* () {
726+
options.versionFile.line = 1;
727+
let newVersion = yield utils_1.bumpVersion(options, 'commit', 'release-candidate');
728+
expect(newVersion).toBe('2.0.1-rc');
729+
}));
730+
test("Commit trigger with prefix", () => __awaiter(void 0, void 0, void 0, function* () {
731+
options.versionFile.line = 1;
732+
let newVersion = yield utils_1.bumpVersion(options, 'commit', 'version-tag');
733+
expect(newVersion).toBe("v.1.2.4");
734+
}));
634735
// describe("Pull-request trigger tests", () => {});
635736
// describe("Comment trigger", () => {});
636737
});

dist/utils/options.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
2828
});
2929
};
3030
Object.defineProperty(exports, "__esModule", { value: true });
31-
exports.getBumperState = exports.getTrigger = exports.normalizeFiles = exports.getFiles = exports.getBumperOptions = exports.getBranchFromTrigger = exports.getSchemeDefinition = exports.normalizeOptions = void 0;
31+
exports.getBumperState = exports.getTrigger = exports.normalizeFiles = exports.getSkipOption = exports.getFiles = exports.getBumperOptions = exports.getBranchFromTrigger = exports.getSchemeDefinition = exports.normalizeOptions = void 0;
3232
const definedSchemes = __importStar(require("../schemes.json"));
3333
const utils_1 = require("./utils");
3434
const core = __importStar(require("@actions/core"));
@@ -101,7 +101,7 @@ exports.getBranchFromTrigger = getBranchFromTrigger;
101101
*/
102102
function getBumperOptions() {
103103
return __awaiter(this, void 0, void 0, function* () {
104-
const optionsFile = core.getInput('options-file'), scheme = core.getInput('scheme'), customScheme = core.getInput('custom-scheme'), versionFile = core.getInput('version-file'), files = core.getInput('files'), rules = core.getInput('rules');
104+
const optionsFile = core.getInput('options-file'), scheme = core.getInput('scheme'), skip = core.getInput('skip'), customScheme = core.getInput('custom-scheme'), versionFile = core.getInput('version-file'), files = core.getInput('files'), rules = core.getInput('rules');
105105
let error = ""; // error message
106106
let bumperOptions = {};
107107
let err = (message) => {
@@ -209,6 +209,14 @@ function getFiles(options) {
209209
return normalizeFiles(options.files);
210210
}
211211
exports.getFiles = getFiles;
212+
/**
213+
* Check if should add [SKIP] prefix
214+
* @param options {skip}
215+
*/
216+
function getSkipOption(options) {
217+
return options.skip || false;
218+
}
219+
exports.getSkipOption = getSkipOption;
212220
/**
213221
* Normalize the file format
214222
* @param files
@@ -257,10 +265,11 @@ exports.getTrigger = getTrigger;
257265
*/
258266
function getBumperState(options) {
259267
return __awaiter(this, void 0, void 0, function* () {
260-
const trigger = getTrigger(), branch = getBranchFromTrigger(trigger), schemeRegExp = utils_1.getSchemeRegex(options), schemeDefinition = getSchemeDefinition(options), curVersion = yield utils_1.getCurVersion(options), tag = utils_1.getTag(options, trigger, branch), newVersion = yield utils_1.bumpVersion(options, trigger, branch), files = getFiles(options);
268+
const trigger = getTrigger(), branch = getBranchFromTrigger(trigger), skip = getSkipOption(options), schemeRegExp = utils_1.getSchemeRegex(options), schemeDefinition = getSchemeDefinition(options), curVersion = yield utils_1.getCurVersion(options), tag = utils_1.getTag(options, trigger, branch), newVersion = yield utils_1.bumpVersion(options, trigger, branch), files = getFiles(options);
261269
const state = {
262270
curVersion,
263271
newVersion,
272+
skip,
264273
schemeRegExp,
265274
schemeDefinition,
266275
tag,

0 commit comments

Comments
 (0)