feat: Add using GitHub API latest feature back in

This commit is contained in:
Thomas A. Christensen II 2024-01-25 22:19:34 -06:00
parent 82d97e2453
commit c71f252745

View file

@ -10,7 +10,11 @@ import {
install_nextflow install_nextflow
} from "./functions" } from "./functions"
import { NextflowRelease } from "./nextflow-release" import { NextflowRelease } from "./nextflow-release"
import { pull_releases, setup_octokit } from "./octokit-wrapper" import {
pull_releases,
pull_latest_stable_release,
setup_octokit
} from "./octokit-wrapper"
async function run(): Promise<void> { async function run(): Promise<void> {
// CAPSULE_LOG leads to a bunch of boilerplate being output to the logs: turn // CAPSULE_LOG leads to a bunch of boilerplate being output to the logs: turn
@ -32,13 +36,16 @@ async function run(): Promise<void> {
// Setup the API // Setup the API
const octokit = await setup_octokit(token, cooldown, max_retries) const octokit = await setup_octokit(token, cooldown, max_retries)
const releases = await pull_releases(octokit)
// Get the release info for the desired release // Get the release info for the desired release
let release = {} as NextflowRelease let release = {} as NextflowRelease
let resolved_version = "" let resolved_version = ""
try { try {
release = await get_nextflow_release(version, releases) if (version === "latest" || version === "latest-stable") {
release = await pull_latest_stable_release(octokit)
} else {
const releases = await pull_releases(octokit)
release = await get_nextflow_release(version, releases)
}
resolved_version = release.versionNumber resolved_version = release.versionNumber
core.info( core.info(
`Input version '${version}' resolved to Nextflow ${release["name"]}` `Input version '${version}' resolved to Nextflow ${release["name"]}`