Skip to content

Commit ee0f5ba

Browse files
mantasmatijMantas Matijosaitisferrarimarco
authored
feat: add ability to select versioning-strategy and release-as (#1121)
Summary This PR adds support for two new inputs to the release-please GitHub Action: `versioning-strategy` Allows users to specify the versioning strategy to use for releases (e.g., default, always-bump-minor, etc.). `release-as`: Allows users to specify the exact version to release as (e.g., 2.0.0). Usage Example ``` - uses: googleapis/release-please-action@v4 with: token: ${{ secrets.GITHUB_TOKEN }} release-type: node versioning-strategy: always-bump-minor release-as: 2.0.0 ``` Motivation These options provide more flexibility and control over how versions are determined and released, addressing use cases where the default behavior is not sufficient. --------- Signed-off-by: Marco Ferrari <ferrarim@google.com> Co-authored-by: Mantas Matijosaitis <mantas.matijosaitis@telesoftas.com> Co-authored-by: Marco Ferrari <ferrarim@google.com>
1 parent 535c413 commit ee0f5ba

3 files changed

Lines changed: 61 additions & 0 deletions

File tree

action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ inputs:
6666
description: 'The proto://host where commits live. Default `https://github.com`'
6767
required: false
6868
default: ${{ github.server_url }}
69+
versioning-strategy:
70+
description: 'The versioning strategy to use.'
71+
required: false
72+
default: 'default'
73+
release-as:
74+
description: 'The version to release as.'
75+
required: false
76+
default: ''
6977
runs:
7078
using: 'node20'
7179
main: 'dist/index.js'

src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ interface ActionInputs {
4343
fork?: boolean;
4444
includeComponentInTag?: boolean;
4545
changelogHost: string;
46+
versioningStrategy?: string;
47+
releaseAs?: string;
4648
}
4749

4850
function parseInputs(): ActionInputs {
@@ -65,6 +67,8 @@ function parseInputs(): ActionInputs {
6567
fork: getOptionalBooleanInput('fork'),
6668
includeComponentInTag: getOptionalBooleanInput('include-component-in-tag'),
6769
changelogHost: core.getInput('changelog-host') || DEFAULT_GITHUB_SERVER_URL,
70+
versioningStrategy: getOptionalInput('versioning-strategy'),
71+
releaseAs: getOptionalInput('release-as'),
6872
};
6973
return inputs;
7074
}
@@ -94,6 +98,8 @@ function loadOrBuildManifest(
9498
releaseType: inputs.releaseType,
9599
includeComponentInTag: inputs.includeComponentInTag,
96100
changelogHost: inputs.changelogHost,
101+
versioning: inputs.versioningStrategy,
102+
releaseAs: inputs.releaseAs,
97103
},
98104
{
99105
fork: inputs.fork,

test/release-please.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,53 @@ describe('release-please-action', () => {
171171
sinon.match.any,
172172
);
173173
});
174+
it('allows specifying versioning-strategy', async () => {
175+
restoreEnv = mockInputs({
176+
'release-type': 'simple',
177+
'versioning-strategy': 'default',
178+
});
179+
fakeManifest.createReleases.resolves([]);
180+
fakeManifest.createPullRequests.resolves([]);
181+
await action.main(fetch);
182+
sinon.assert.calledOnce(fakeManifest.createReleases);
183+
sinon.assert.calledOnce(fakeManifest.createPullRequests);
184+
185+
sinon.assert.calledWith(
186+
fromConfigStub,
187+
sinon.match.any,
188+
sinon.match.string,
189+
sinon.match({
190+
releaseType: 'simple',
191+
versioning: 'default',
192+
}),
193+
sinon.match.object,
194+
sinon.match.any,
195+
);
196+
});
197+
198+
it('allows specifying release-as', async () => {
199+
restoreEnv = mockInputs({
200+
'release-type': 'simple',
201+
'release-as': '2.0.0',
202+
});
203+
fakeManifest.createReleases.resolves([]);
204+
fakeManifest.createPullRequests.resolves([]);
205+
await action.main(fetch);
206+
sinon.assert.calledOnce(fakeManifest.createReleases);
207+
sinon.assert.calledOnce(fakeManifest.createPullRequests);
208+
209+
sinon.assert.calledWith(
210+
fromConfigStub,
211+
sinon.match.any,
212+
sinon.match.string,
213+
sinon.match({
214+
releaseType: 'simple',
215+
releaseAs: '2.0.0',
216+
}),
217+
sinon.match.object,
218+
sinon.match.any,
219+
);
220+
});
174221
});
175222

176223
describe('with manifest', () => {

0 commit comments

Comments
 (0)