Allow custom value for semver and match type

This commit is contained in:
CrazyMax 2021-03-27 21:46:47 +01:00
parent b171e9c8ea
commit e59258b94d
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
7 changed files with 179 additions and 20 deletions

View file

@ -115,10 +115,16 @@ export class Meta {
}
private procSemver(version: Version, tag: tcl.Tag): Version {
if (!/^refs\/tags\//.test(this.context.ref)) {
if (!/^refs\/tags\//.test(this.context.ref) && tag.attrs['value'].length == 0) {
return version;
}
let vraw = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
let vraw: string;
if (tag.attrs['value'].length > 0) {
vraw = tag.attrs['value'];
} else {
vraw = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
}
if (!semver.valid(vraw)) {
core.warning(`${vraw} is not a valid semver. More info: https://semver.org/`);
return version;
@ -152,10 +158,16 @@ export class Meta {
}
private procMatch(version: Version, tag: tcl.Tag): Version {
if (!/^refs\/tags\//.test(this.context.ref)) {
if (!/^refs\/tags\//.test(this.context.ref) && tag.attrs['value'].length == 0) {
return version;
}
let vraw = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
let vraw: string;
if (tag.attrs['value'].length > 0) {
vraw = tag.attrs['value'];
} else {
vraw = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
}
let latest: boolean = false;
let tmatch;