- verify versions match semver versioning

This commit is contained in:
Mike Penz
2020-10-19 19:58:36 +02:00
parent 4ad1d585c9
commit 2a95fba312
+13 -2
View File
@@ -1,5 +1,6 @@
import {Octokit, RestEndpointMethodTypes} from '@octokit/rest'
import * as core from '@actions/core'
import * as semver from 'semver'
import {SemVer} from 'semver'
export interface TagInfo {
@@ -94,8 +95,18 @@ export class Tags {
2020.3.0
*/
export function sortTags(tags: TagInfo[]): TagInfo[] {
tags.sort((b, a) => {
// filter out tags which do not follow semver
const validatedTags = tags.filter(tag => {
const isValid = semver.valid(tag.name) !== null
if(!isValid) {
core.debug(`⚠️ dropped tag ${tag.name} because it is not a valid semver tag`)
}
return isValid
})
// sort using semver
validatedTags.sort((b, a) => {
return new SemVer(a.name).compare(b.name)
})
return tags
return validatedTags
}