Skip to content

Commit 27de946

Browse files
bryanjtckaibloecker
authored andcommitted
feat: add semver option
1 parent 3a68219 commit 27de946

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ This section is just to document the environment variables used by the plugin. A
105105

106106
### Options
107107

108-
As of now, there are no options.
108+
| Option | Description | Type | Default Value |
109+
| -------- | ------------------------------------------------------------ | --------- | ------------- |
110+
| `semver` | Publish only a valid semantic version number. Example: 1.1.1 | `boolean` | `false` |
109111

110112
## Contributing
111113

src/publish.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ const SemanticReleaseError = require('@semantic-release/error');
55

66
const CONTENT_TYPE = 'application/vnd.docker.distribution.manifest.v2+json';
77

8-
const getVersionTags = function (version) {
8+
const getVersionTags = function (version, isSemver) {
99
const major = semver.major(version);
1010
const minor = semver.minor(version);
1111
const patch = semver.patch(version);
1212
const prerelease = semver.prerelease(version)
1313
? `-${semver.prerelease(version).join('.')}`
1414
: '';
1515

16+
if (isSemver) {
17+
return [`${major}.${minor}.${patch}${prerelease}`];
18+
}
1619
return [
1720
`${major}.${minor}.${patch}${prerelease}`,
1821
`${major}.${minor}${prerelease}`,
@@ -73,7 +76,7 @@ module.exports = async (pluginConfig, context) => {
7376

7477
const url = `https://${CI_REGISTRY}/v2/${CI_PROJECT_PATH}/manifests/`;
7578
const manifest = await getManifest(`${url}/${commit}`, Authorization);
76-
const nextVersions = getVersionTags(version);
79+
const nextVersions = getVersionTags(version, pluginConfig.semver ?? false);
7780
nextVersions.forEach(async (item) => {
7881
// eslint-disable-next-line no-unused-vars
7982
const result = await pushTag(`${url}/${item}`, Authorization, manifest);

0 commit comments

Comments
 (0)