mirror of
https://github.com/MillironX/setup-nextflow.git
synced 2024-11-22 17:59:54 +00:00
refactor: Make tag filtering work on NextflowRelease objects
This commit is contained in:
parent
cdb0393711
commit
bc65c05e25
1 changed files with 12 additions and 16 deletions
|
@ -4,14 +4,12 @@ import retry from "async-retry"
|
||||||
import * as fs from "fs"
|
import * as fs from "fs"
|
||||||
import semver from "semver"
|
import semver from "semver"
|
||||||
|
|
||||||
|
import { NextflowRelease } from "./NextflowRelease"
|
||||||
|
|
||||||
export async function release_data(
|
function tag_filter(version: string): (r: NextflowRelease) => Boolean {
|
||||||
version: string,
|
|
||||||
ok: InstanceType<typeof GitHub>
|
|
||||||
): Promise<object> {
|
|
||||||
// Setup tag-based filtering
|
// Setup tag-based filtering
|
||||||
let filter = (r: object): boolean => {
|
let filter = (r: NextflowRelease): boolean => {
|
||||||
return semver.satisfies(r["tag_name"], version, true)
|
return semver.satisfies(r.versionNumber, version, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the user passed a 'latest*' tag, and override filtering
|
// Check if the user passed a 'latest*' tag, and override filtering
|
||||||
|
@ -20,23 +18,21 @@ export async function release_data(
|
||||||
if (version.includes("-everything")) {
|
if (version.includes("-everything")) {
|
||||||
// No filtering
|
// No filtering
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
filter = (r: object) => {
|
filter = (r: NextflowRelease) => {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
} else if (version.includes("-edge")) {
|
} else if (version.includes("-edge")) {
|
||||||
filter = r => {
|
filter = (r: NextflowRelease) => {
|
||||||
return r["tag_name"].endsWith("-edge")
|
return r.versionNumber.endsWith("-edge")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// This is special: passing 'latest' or 'latest-stable' allows us to use
|
filter = (r: NextflowRelease) => {
|
||||||
// the latest stable GitHub release direct from the API
|
return !r.isEdge
|
||||||
const stable_release = await latest_stable_release_data(ok)
|
}
|
||||||
return stable_release
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return filter
|
||||||
// Get all the releases
|
}
|
||||||
const all_releases: object[] = await all_nf_releases(ok)
|
|
||||||
|
|
||||||
const matching_releases = all_releases.filter(filter)
|
const matching_releases = all_releases.filter(filter)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue