Skip to content

Commit 9ca32bf

Browse files
committed
Add version prefix.
1 parent 143c9d8 commit 9ca32bf

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

README.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ You should use this action in a workflow immediately after checkout. The followi
2929
- `tags`: reverse sorted git tags in semver format
3030
- `nextVersion`: calculated next version (see table above)
3131

32+
For inputs, the following options are available:
33+
34+
- `versionPrefix`: adds a string to the tag.
35+
3236
Example yml:
3337

34-
```
38+
```yaml
3539
- uses: actions/checkout@v2
3640
with:
3741
fetch-depth: 0
@@ -62,15 +66,18 @@ Run the tests
6266
```bash
6367
$ npm test
6468
65-
PASS __tests__/main.test.ts
66-
✓ VPE Versioning #1 (2ms)
67-
✓ VPE Versioning #2 (1ms)
68-
✓ VPE Versioning #3
69-
✓ VPE Versioning #4
70-
✓ VPE Versioning #5 (1ms)
71-
✓ VPE Versioning #6
72-
✓ VPE Versioning #7
73-
✓ VPE Versioning #8
74-
75-
...
69+
PASS __tests__/main.test.ts
70+
√ should use version from package.json if no tag is available (2ms)
71+
√ should bump version if same tag is available
72+
√ should bump version if same tag is available but prefixed
73+
√ should bump version if same tag is available but not prefixed (1ms)
74+
√ should use bump latest pre-release tag if multiple tags are available
75+
√ should use bump latest tag if multiple tags are available sorted the other way around
76+
√ should use bump latest tag if one tag was skipped (1ms)
77+
√ should use major version from major package.json if no tag matched
78+
√ should use pre-release version from pre-release package.json if no tag matched
79+
√ should bump final version if tag already exists and ends with 0
80+
√ should throw an error if final version is already tagged and does not end with 0 (9ms)
81+
√ should throw an error if pre-release version is already tagged and does not end with 0
82+
√ should throw an error for wrong versions (2ms)
7683
```

src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ async function run(): Promise<void> {
7777
console.log(`tags: ${tags}`);
7878

7979
const nextVersion = getNextVersion(version, tags);
80-
core.setOutput('nextVersion', nextVersion);
80+
const prefix = core.getInput('versionPrefix') || '';
81+
core.setOutput('nextVersion', prefix + nextVersion);
8182
console.log(`nextVersion: ${nextVersion}`);
8283
} catch (error) {
8384
core.setFailed(error.message);

0 commit comments

Comments
 (0)