Skip to content

Fix .swift-version unused when swift-version option unset #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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