2022-11-03 17:21:00 +01:00
import * as core from '@actions/core'
2023-01-24 10:35:51 +01:00
import { getLatestRelease , toSemVer } from '../utils'
2022-11-03 17:21:00 +01:00
import { lt , major , minor , valid } from 'semver'
2023-01-24 10:35:51 +01:00
import { findGraalVMVersion } from '../graalvm'
import { GRAALVM_RELEASES_REPO } from '../constants'
2022-11-03 17:21:00 +01:00
export async function checkForUpdates (
graalVMVersion : string ,
javaVersion : string
) : Promise < void > {
if ( graalVMVersion === '22.3.0' && javaVersion === '11' ) {
core . notice (
'Please consider upgrading your project to Java 17+. The GraalVM 22.3.0 release is the last to support JDK11: https://github.com/oracle/graal/issues/5063'
)
return
}
2023-01-24 10:35:51 +01:00
const latestRelease = await getLatestRelease ( GRAALVM_RELEASES_REPO )
const latestGraalVMVersion = findGraalVMVersion ( latestRelease )
2022-11-03 17:21:00 +01:00
const selectedVersion = toSemVer ( graalVMVersion )
const latestVersion = toSemVer ( latestGraalVMVersion )
if (
valid ( selectedVersion ) &&
valid ( latestVersion ) &&
lt ( selectedVersion , latestVersion )
) {
core . notice (
` A new GraalVM release is available! Please consider upgrading to GraalVM ${ latestGraalVMVersion } . Release notes: https://www.graalvm.org/release-notes/ ${ major (
latestVersion
) } _ $ { minor ( latestVersion ) } / `
)
}
}