Skip to content

Commit 0dd7f9b

Browse files
fix: init version should not be incresed (#15)
1 parent 081a923 commit 0dd7f9b

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ successful completion of all steps and detection of a new version (`post`).
236236

237237
| input | type | default | description |
238238
|--------------|------------------|---------|-------------------------------------------------------------------------|
239-
| init-version | string | 0.0.0 | initial version of the project |
239+
| init-version | string | 0.1.0 | initial version of the project |
240240
| tag-prefix | string | v | tag prefix, useful for versioning multiple components in one repository |
241241
| assets | multiline string | | list of files to be upload as assets |
242242

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ branding:
66
color: purple
77
inputs:
88
init-version:
9-
description: 'The init version of project default: 0.0.0'
9+
description: 'The init version of project default: 0.1.0'
1010
required: false
11-
default: '0.0.0'
11+
default: '0.1.0'
1212
tag-prefix:
1313
description: 'The prefix of version tag, default: v'
1414
required: false

src/main.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const FEATURE_REGEX = new RegExp(/^feat(|\(.+\)): /);
1010
const github = GithubService.create();
1111

1212
async function main() {
13-
const initVersion = core.getInput('init-version') || '0.0.0';
13+
const initVersion = core.getInput('init-version') || '0.1.0';
1414
const tagPrefix = core.getInput('tag-prefix') || 'v';
1515

1616
core.debug(`main: input initVersion: ${initVersion}`);
@@ -121,6 +121,10 @@ function createChangelog(messages: string[]): string[] {
121121
}
122122

123123
function increaseVersionByMessages(version: Version, messages: string[]): Version {
124+
if (version.isIncreased()) {
125+
return version;
126+
}
127+
124128
if (messages.findIndex(breakingChangeTest) >= 0) {
125129
return version.increaseMajor();
126130
}

src/version.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ export class Version {
99
this.increased = increased;
1010
}
1111

12-
public static parse(version?: string, initVersion: string = '0.0.0', prefix: string = 'v') {
12+
public static parse(version?: string, initVersion: string = '0.1.0', prefix: string = 'v') {
1313
if (version === undefined) {
14-
return new Version(new SemVer(initVersion));
14+
return new Version(new SemVer(initVersion), true);
1515
}
1616

1717
const versionWithoutPrefix = version.replace(prefix, '');
@@ -57,6 +57,11 @@ export class Version {
5757
}
5858

5959
private increase(type: 'major' | 'minor' | 'patch'): Version {
60+
// prevent double version increase
61+
if (this.increased) {
62+
return this;
63+
}
64+
6065
const version = new SemVer(this.version.raw);
6166
version.inc(type);
6267

0 commit comments

Comments
 (0)