mirror of
https://github.com/googleapis/release-please-action.git
synced 2026-03-28 15:12:33 +00:00
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>
This commit is contained in:
@@ -66,6 +66,14 @@ inputs:
|
|||||||
description: 'The proto://host where commits live. Default `https://github.com`'
|
description: 'The proto://host where commits live. Default `https://github.com`'
|
||||||
required: false
|
required: false
|
||||||
default: ${{ github.server_url }}
|
default: ${{ github.server_url }}
|
||||||
|
versioning-strategy:
|
||||||
|
description: 'The versioning strategy to use.'
|
||||||
|
required: false
|
||||||
|
default: 'default'
|
||||||
|
release-as:
|
||||||
|
description: 'The version to release as.'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node20'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ interface ActionInputs {
|
|||||||
fork?: boolean;
|
fork?: boolean;
|
||||||
includeComponentInTag?: boolean;
|
includeComponentInTag?: boolean;
|
||||||
changelogHost: string;
|
changelogHost: string;
|
||||||
|
versioningStrategy?: string;
|
||||||
|
releaseAs?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseInputs(): ActionInputs {
|
function parseInputs(): ActionInputs {
|
||||||
@@ -65,6 +67,8 @@ function parseInputs(): ActionInputs {
|
|||||||
fork: getOptionalBooleanInput('fork'),
|
fork: getOptionalBooleanInput('fork'),
|
||||||
includeComponentInTag: getOptionalBooleanInput('include-component-in-tag'),
|
includeComponentInTag: getOptionalBooleanInput('include-component-in-tag'),
|
||||||
changelogHost: core.getInput('changelog-host') || DEFAULT_GITHUB_SERVER_URL,
|
changelogHost: core.getInput('changelog-host') || DEFAULT_GITHUB_SERVER_URL,
|
||||||
|
versioningStrategy: getOptionalInput('versioning-strategy'),
|
||||||
|
releaseAs: getOptionalInput('release-as'),
|
||||||
};
|
};
|
||||||
return inputs;
|
return inputs;
|
||||||
}
|
}
|
||||||
@@ -94,6 +98,8 @@ function loadOrBuildManifest(
|
|||||||
releaseType: inputs.releaseType,
|
releaseType: inputs.releaseType,
|
||||||
includeComponentInTag: inputs.includeComponentInTag,
|
includeComponentInTag: inputs.includeComponentInTag,
|
||||||
changelogHost: inputs.changelogHost,
|
changelogHost: inputs.changelogHost,
|
||||||
|
versioning: inputs.versioningStrategy,
|
||||||
|
releaseAs: inputs.releaseAs,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fork: inputs.fork,
|
fork: inputs.fork,
|
||||||
|
|||||||
@@ -171,6 +171,53 @@ describe('release-please-action', () => {
|
|||||||
sinon.match.any,
|
sinon.match.any,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('allows specifying versioning-strategy', async () => {
|
||||||
|
restoreEnv = mockInputs({
|
||||||
|
'release-type': 'simple',
|
||||||
|
'versioning-strategy': 'default',
|
||||||
|
});
|
||||||
|
fakeManifest.createReleases.resolves([]);
|
||||||
|
fakeManifest.createPullRequests.resolves([]);
|
||||||
|
await action.main(fetch);
|
||||||
|
sinon.assert.calledOnce(fakeManifest.createReleases);
|
||||||
|
sinon.assert.calledOnce(fakeManifest.createPullRequests);
|
||||||
|
|
||||||
|
sinon.assert.calledWith(
|
||||||
|
fromConfigStub,
|
||||||
|
sinon.match.any,
|
||||||
|
sinon.match.string,
|
||||||
|
sinon.match({
|
||||||
|
releaseType: 'simple',
|
||||||
|
versioning: 'default',
|
||||||
|
}),
|
||||||
|
sinon.match.object,
|
||||||
|
sinon.match.any,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows specifying release-as', async () => {
|
||||||
|
restoreEnv = mockInputs({
|
||||||
|
'release-type': 'simple',
|
||||||
|
'release-as': '2.0.0',
|
||||||
|
});
|
||||||
|
fakeManifest.createReleases.resolves([]);
|
||||||
|
fakeManifest.createPullRequests.resolves([]);
|
||||||
|
await action.main(fetch);
|
||||||
|
sinon.assert.calledOnce(fakeManifest.createReleases);
|
||||||
|
sinon.assert.calledOnce(fakeManifest.createPullRequests);
|
||||||
|
|
||||||
|
sinon.assert.calledWith(
|
||||||
|
fromConfigStub,
|
||||||
|
sinon.match.any,
|
||||||
|
sinon.match.string,
|
||||||
|
sinon.match({
|
||||||
|
releaseType: 'simple',
|
||||||
|
releaseAs: '2.0.0',
|
||||||
|
}),
|
||||||
|
sinon.match.object,
|
||||||
|
sinon.match.any,
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('with manifest', () => {
|
describe('with manifest', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user