Warn on invalid semver

This commit is contained in:
CrazyMax 2020-12-01 05:40:42 +01:00
parent ef12c77b87
commit c78798ed86
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
2 changed files with 8 additions and 0 deletions

4
dist/index.js generated vendored
View File

@ -171,6 +171,7 @@ exports.Meta = void 0;
const handlebars = __webpack_require__(7492);
const moment = __webpack_require__(9623);
const semver = __webpack_require__(1383);
const core = __webpack_require__(2186);
class Meta {
constructor(inputs, context, repo) {
this.inputs = inputs;
@ -198,6 +199,9 @@ class Meta {
}
else if (/^refs\/tags\//.test(this.context.ref)) {
version.main = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
if (this.inputs.tagSemver.length > 0 && !semver.valid(version.main)) {
core.warning(`${version.main} is not a valid semver. More info: https://semver.org/`);
}
if (this.inputs.tagSemver.length > 0 && semver.valid(version.main)) {
const sver = semver.parse(version.main, {
includePrerelease: true

View File

@ -2,6 +2,7 @@ import * as handlebars from 'handlebars';
import * as moment from 'moment';
import * as semver from 'semver';
import {Inputs} from './context';
import * as core from '@actions/core';
import {Context} from '@actions/github/lib/context';
import {ReposGetResponseData} from '@octokit/types';
@ -46,6 +47,9 @@ export class Meta {
});
} else if (/^refs\/tags\//.test(this.context.ref)) {
version.main = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
if (this.inputs.tagSemver.length > 0 && !semver.valid(version.main)) {
core.warning(`${version.main} is not a valid semver. More info: https://semver.org/`);
}
if (this.inputs.tagSemver.length > 0 && semver.valid(version.main)) {
const sver = semver.parse(version.main, {
includePrerelease: true