Skip to content

Commit

Permalink
Merge pull request #24 from sidepelican/main
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun authored Jan 15, 2023
2 parents 8e7c319 + 3d49ab1 commit 1deb850
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 23 deletions.
4 changes: 1 addition & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ branding:
icon: download
inputs:
swift-version:
description: 'Swift version to configure (default: wasm-5.7.1-RELEASE)'
required: true
default: 'wasm-5.7.1-RELEASE'
description: 'Swift version to configure. Reads from .swift-version if unset. Use default value if both are absent.'
runs:
using: 'node16'
main: 'dist/index.js'
13 changes: 7 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions dist/nightly/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/nightly/index.js.map

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const tc = require("@actions/tool-cache");
const os = require("os");
const path = require("path");

const defaultSwiftVersion = "wasm-5.7.1-RELEASE";

async function run(version) {
validateVersion(version);
const platform = resolveHostPlatform();
Expand Down Expand Up @@ -44,8 +46,8 @@ async function installToolchain(url, version, platform) {
return cachedPath;
}

function resolveVersionInput(options = {}) {
const version = core.getInput('swift-version') || options.version;
function resolveVersionInput() {
const version = core.getInput('swift-version');
if (version) {
core.debug(`Using version from input: ${version}`);
return version;
Expand All @@ -57,17 +59,16 @@ function resolveVersionInput(options = {}) {
return versionFile;
}
}
const message = "No Swift version specified. Please specify a version using the 'swift-version' input or a .swift-version file.";
core.error(message);
throw new Error(message);
core.debug(`Using version from default: ${defaultSwiftVersion}`);
return defaultSwiftVersion;
}

function validateVersion(version) {
if (version === "") {
throw new Error("Empty version specified.");
}
if (!version.startsWith("wasm-")) {
throw new Error(`Invalid version specified: ${version}. Version must start with 'wasm-'. For example: 'wasm-5.7.1-RELEASE'`);
throw new Error(`Invalid version specified: ${version}. Version must start with 'wasm-'. For example: '${defaultSwiftVersion}'`);
}
}

Expand Down

0 comments on commit 1deb850

Please sign in to comment.