Skip to content

Commit c070715

Browse files
committed
feat: add build info
1 parent ff79474 commit c070715

File tree

5 files changed

+142
-58
lines changed

5 files changed

+142
-58
lines changed

Diff for: README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Otherwise the version and its components are avaialbe through action outputs.
2424
echo "v${{ steps.semver.outputs.minor }}"
2525
echo "v${{ steps.semver.outputs.patch }}"
2626
echo "v${{ steps.semver.outputs.extra }}"
27+
echo "v${{ steps.semver.outputs.build }}"
2728
```
2829
2930
## Inputs
@@ -48,11 +49,12 @@ The following outputs are available through `steps.<id>.outputs` when the action
4849

4950
| Name | Type | Description | Example |
5051
| ---- | --- | ------------ | ------- |
51-
| `version` | `string` | The full version wihout prefixes | `2.13.34-dev` |
52+
| `version` | `string` | The full version wihout prefixes | `2.13.34-dev+001` |
5253
| `major` | `string` | The major version number | `2` |
5354
| `minor` | `string` | The minor version number | `13` |
5455
| `patch` | `string` | The patch version number | `34` |
5556
| `extra` | `string` | The prerelease version or extra | `dev` |
57+
| `build` | `string` | The build metadata | `001` |
5658

5759
> [!TIP]
5860
> The version is coerced in to a semantic version as per the [resolution strategy](#resolution-strategy), therefore all outputs will be present assuming the action succeeds.

Diff for: src/core/action.test.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('action()', (): void => {
1919
expect(input).toBeCalledTimes(1);
2020
expect(input).toHaveBeenNthCalledWith<[string, ActionInputFunctionOptions]>(1, 'version', { required: true });
2121

22-
expect(output).toBeCalledTimes(5);
22+
expect(output).toBeCalledTimes(6);
2323
expect(output).toHaveBeenNthCalledWith<[string, string]>(1, 'version', '1.2.3');
2424
expect(output).toHaveBeenNthCalledWith<[string, string]>(2, 'major', '1');
2525
expect(output).toHaveBeenNthCalledWith<[string, string]>(3, 'minor', '2');
@@ -34,7 +34,7 @@ describe('action()', (): void => {
3434
const output = fn<ActionOutputFunction>();
3535
const fail = fn<ActionFailFunction>();
3636

37-
input.mockReturnValueOnce('10.23.4');
37+
input.mockReturnValueOnce('v10.23.4');
3838

3939
await action({
4040
input,
@@ -45,7 +45,7 @@ describe('action()', (): void => {
4545
expect(input).toBeCalledTimes(1);
4646
expect(input).toHaveBeenNthCalledWith<[string, ActionInputFunctionOptions]>(1, 'version', { required: true });
4747

48-
expect(output).toBeCalledTimes(5);
48+
expect(output).toBeCalledTimes(6);
4949
expect(output).toHaveBeenNthCalledWith<[string, string]>(1, 'version', '10.23.4');
5050
expect(output).toHaveBeenNthCalledWith<[string, string]>(2, 'major', '10');
5151
expect(output).toHaveBeenNthCalledWith<[string, string]>(3, 'minor', '23');
@@ -60,7 +60,7 @@ describe('action()', (): void => {
6060
const output = fn<ActionOutputFunction>();
6161
const fail = fn<ActionFailFunction>();
6262

63-
input.mockReturnValueOnce('2.3-alpha.2');
63+
input.mockReturnValueOnce('2.3-alpha.2+001');
6464

6565
await action({
6666
input,
@@ -71,12 +71,13 @@ describe('action()', (): void => {
7171
expect(input).toBeCalledTimes(1);
7272
expect(input).toHaveBeenNthCalledWith<[string, ActionInputFunctionOptions]>(1, 'version', { required: true });
7373

74-
expect(output).toBeCalledTimes(5);
74+
expect(output).toBeCalledTimes(6);
7575
expect(output).toHaveBeenNthCalledWith<[string, string]>(1, 'version', '2.3.0-alpha.2');
7676
expect(output).toHaveBeenNthCalledWith<[string, string]>(2, 'major', '2');
7777
expect(output).toHaveBeenNthCalledWith<[string, string]>(3, 'minor', '3');
7878
expect(output).toHaveBeenNthCalledWith<[string, string]>(4, 'patch', '0');
7979
expect(output).toHaveBeenNthCalledWith<[string, string]>(5, 'extra', 'alpha.2');
80+
expect(output).toHaveBeenNthCalledWith<[string, string]>(6, 'build', '001');
8081

8182
expect(fail).toBeCalledTimes(0);
8283
});
@@ -97,12 +98,13 @@ describe('action()', (): void => {
9798
expect(input).toBeCalledTimes(1);
9899
expect(input).toHaveBeenNthCalledWith<[string, ActionInputFunctionOptions]>(1, 'version', { required: true });
99100

100-
expect(output).toBeCalledTimes(5);
101+
expect(output).toBeCalledTimes(6);
101102
expect(output).toHaveBeenNthCalledWith<[string, string]>(1, 'version', '4.36.14');
102103
expect(output).toHaveBeenNthCalledWith<[string, string]>(2, 'major', '4');
103104
expect(output).toHaveBeenNthCalledWith<[string, string]>(3, 'minor', '36');
104105
expect(output).toHaveBeenNthCalledWith<[string, string]>(4, 'patch', '14');
105106
expect(output).toHaveBeenNthCalledWith<[string, string]>(5, 'extra', '');
107+
expect(output).toHaveBeenNthCalledWith<[string, string]>(6, 'build', '');
106108

107109
expect(fail).toBeCalledTimes(0);
108110
});
@@ -123,12 +125,13 @@ describe('action()', (): void => {
123125
expect(input).toBeCalledTimes(1);
124126
expect(input).toHaveBeenNthCalledWith<[string, ActionInputFunctionOptions]>(1, 'version', { required: true });
125127

126-
expect(output).toBeCalledTimes(5);
128+
expect(output).toBeCalledTimes(6);
127129
expect(output).toHaveBeenNthCalledWith<[string, string]>(1, 'version', '5.31.12-beta.1');
128130
expect(output).toHaveBeenNthCalledWith<[string, string]>(2, 'major', '5');
129131
expect(output).toHaveBeenNthCalledWith<[string, string]>(3, 'minor', '31');
130132
expect(output).toHaveBeenNthCalledWith<[string, string]>(4, 'patch', '12');
131133
expect(output).toHaveBeenNthCalledWith<[string, string]>(5, 'extra', 'beta.1');
134+
expect(output).toHaveBeenNthCalledWith<[string, string]>(6, 'build', '');
132135

133136
expect(fail).toBeCalledTimes(0);
134137
});

Diff for: src/core/action.ts

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const action = async (action: ActionDependencies): Promise<void> => {
5555
action.output('minor', validated.part.minor);
5656
action.output('patch', validated.part.patch);
5757
action.output('extra', validated.part.extra);
58+
action.output('build', validated.part.build);
5859
} catch (error: unknown) {
5960
action.fail(`An unexpected error occured: ${error}`);
6061
}

0 commit comments

Comments
 (0)