diff --git a/action.yml b/action.yml index 4097d352..b3f3bd63 100644 --- a/action.yml +++ b/action.yml @@ -6,6 +6,10 @@ inputs: description: Swift version to configure required: true default: '6.1.0' + soft-fail-version-check: + description: 'If true, unknown Swift versions will only warn instead of error' + required: false + default: 'false' outputs: version: description: The full Swift version that was configured diff --git a/dist/index.js b/dist/index.js index d94c7e24..dd3509de 100644 --- a/dist/index.js +++ b/dist/index.js @@ -459,6 +459,7 @@ exports.verify = exports.swiftPackage = void 0; const semver = __importStar(__nccwpck_require__(1383)); const core = __importStar(__nccwpck_require__(2186)); const os_1 = __nccwpck_require__(1855); +const softFailVersionCheck = core.getInput("soft-fail-version-check").toLowerCase() === "true"; const VERSIONS_LIST = [ ["6.1.0", [os_1.OS.MacOS, os_1.OS.Ubuntu]], ["6.0.3", [os_1.OS.MacOS, os_1.OS.Ubuntu]], @@ -575,6 +576,10 @@ function verify(version, system) { let systemVersions = AVAILABLE_VERSIONS.filter(([_, os]) => os.includes(system.os)).map(([version, _]) => version); let matchingVersion = evaluateVersions(systemVersions, version); if (matchingVersion === null) { + if (softFailVersionCheck) { + core.warning(`Swift version "${version}" not in the list of tested versions; proceeding anyway because soft-fail-version-check is enabled.`); + return version; + } throw new Error(`Version "${version}" is not available`); } core.debug(`Found matching version ${matchingVersion}`); diff --git a/src/swift-versions.ts b/src/swift-versions.ts index 7394f926..7bef0656 100644 --- a/src/swift-versions.ts +++ b/src/swift-versions.ts @@ -2,6 +2,9 @@ import * as semver from "semver"; import * as core from "@actions/core"; import { System, OS } from "./os"; +const softFailVersionCheck = + core.getInput("soft-fail-version-check").toLowerCase() === "true"; + const VERSIONS_LIST: [string, OS[]][] = [ ["6.1.0", [OS.MacOS, OS.Ubuntu]], ["6.0.3", [OS.MacOS, OS.Ubuntu]], @@ -136,6 +139,12 @@ export function verify(version: string, system: System) { let matchingVersion = evaluateVersions(systemVersions, version); if (matchingVersion === null) { + if (softFailVersionCheck) { + core.warning( + `Swift version "${version}" not in the list of tested versions; proceeding anyway because soft-fail-version-check is enabled.` + ); + return version; + } throw new Error(`Version "${version}" is not available`); }