- use loose semver parsing to support a wider variety of cases

This commit is contained in:
Mike Penz
2020-11-11 13:40:17 +01:00
parent 61475aaa56
commit c29d7639d7
6 changed files with 43 additions and 31 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ export const DefaultConfiguration: Configuration = {
labels: ['test']
}
], // the categories to support for the ordering
ignore_labels: [ "ignore" ], // list of lables being ignored from the changelog
ignore_labels: ['ignore'], // list of lables being ignored from the changelog
transformers: [], // transformers to apply on the PR description according to the `pr_template`
tag_resolver: {
// defines the logic on how to resolve the previous tag, only relevant if `fromTag` is not specified
+9 -2
View File
@@ -110,7 +110,11 @@ export function sortTags(tags: TagInfo[], tagResolver: TagResolver): TagInfo[] {
function semVerSorting(tags: TagInfo[]): TagInfo[] {
// filter out tags which do not follow semver
const validatedTags = tags.filter(tag => {
const isValid = semver.valid(tag.name) !== null
const isValid =
semver.valid(tag.name, {
includePrerelease: true,
loose: true
}) !== null
if (!isValid) {
core.debug(
`⚠️ dropped tag ${tag.name} because it is not a valid semver tag`
@@ -121,7 +125,10 @@ function semVerSorting(tags: TagInfo[]): TagInfo[] {
// sort using semver
validatedTags.sort((b, a) => {
return new SemVer(a.name).compare(b.name)
return new SemVer(a.name, {
includePrerelease: true,
loose: true
}).compare(b.name)
})
return validatedTags
}
+5 -6
View File
@@ -42,12 +42,13 @@ export function buildChangelog(
// bring PRs into the order of categories
const categorized = new Map<Category, string[]>()
const categories = config.categories || DefaultConfiguration.categories
const ignoredLabels = config.ignore_labels || DefaultConfiguration.ignore_labels
const ignoredLabels =
config.ignore_labels || DefaultConfiguration.ignore_labels
for (const category of categories) {
categorized.set(category, [])
}
const categorizedPrs: string[] = []
const ignoredPrs: string[] = []
const uncategorizedPrs: string[] = []
@@ -111,9 +112,7 @@ export function buildChangelog(
for (const pr of ignoredPrs) {
changelogIgnored = `${changelogIgnored + pr}\n`
}
core.info(
`✒️ Wrote ${ignoredPrs.length} ignored pull requests down`
)
core.info(`✒️ Wrote ${ignoredPrs.length} ignored pull requests down`)
// fill template
let transformedChangelog = config.template || DefaultConfiguration.template