Implement the "publish-action" action

This commit is contained in:
MaksimZhukov
2021-05-21 19:59:44 +03:00
parent d90d23df2a
commit d8eb8e53b7
22 changed files with 12475 additions and 0 deletions

25
src/version-utils.ts Normal file
View File

@@ -0,0 +1,25 @@
import semverParse from 'semver/functions/parse';
import SemVer from 'semver/classes/semver';
export function isStableSemverVersion(version: SemVer): boolean {
return version.prerelease.length === 0
}
export function getMajorTagFromFullTag(fullTag: string): string {
return fullTag.split('.')[0];
}
export function validateSemverVersionFromTag(tag: string): void {
const semverVersion = semverParse(tag);
if (!semverVersion) {
throw new Error(
`The '${tag}' doesn't satisfy semantic versioning specification`
);
}
if (!isStableSemverVersion(semverVersion)) {
throw new Error(
'It is not allowed to specify pre-release version to update the major tag'
);
}
}