mirror of
https://github.com/actions/publish-action.git
synced 2025-06-05 12:00:39 +02:00

* Add ESLint and Prettier * Rebuild action * Update package.json * Update licenses * Fix review points
26 lines
705 B
TypeScript
26 lines
705 B
TypeScript
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'
|
|
);
|
|
}
|
|
}
|