Skip to content

Commit

Permalink
Merge pull request #392 from upamune/fix-go-version-file-path
Browse files Browse the repository at this point in the history
Fix bugs related to `go_version_file` input
  • Loading branch information
shogo82148 committed Aug 15, 2022
2 parents 99a63a1 + e61ede7 commit 70498f2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
4 changes: 3 additions & 1 deletion action.yml
Expand Up @@ -53,7 +53,9 @@ inputs:
go_version:
description: "the version of Go. By default, the latest version of Go 1.x is installed."
required: false
default: "1.x"
go_version_file:
description: "Path to the go.mod file or the file containing only Go version."
required: false
cache:
deprecation: "enable cache"
default: true
Expand Down
12 changes: 7 additions & 5 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.

8 changes: 3 additions & 5 deletions src/main.ts
Expand Up @@ -31,11 +31,9 @@ async function run() {
const cwd = path.relative(process.env["GITHUB_WORKSPACE"] || process.cwd(), workdir);
const enableCache = core.getBooleanInput("cache");

if (goVersion !== "" || goVersionFile !== "") {
await core.group("Installing Go ...", async () => {
await setupGo.run(goVersion, goVersionFile);
});
}
await core.group("Installing Go ...", async () => {
await setupGo.run(goVersion, goVersionFile);
});

const reviewdog = await core.group(
"🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog",
Expand Down
6 changes: 6 additions & 0 deletions src/setup-go/main.ts
Expand Up @@ -9,6 +9,8 @@ import cp from "child_process";
import fs from "fs";
import path from "path";

const defaultGoVersion = "1.x";

export async function run(version: string, versionFilePath: string): Promise<void> {
try {
const versionSpec = resolveVersionInput(version, versionFilePath);
Expand Down Expand Up @@ -100,5 +102,9 @@ function resolveVersionInput(version: string, versionFilePath: string): string {
version = installer.parseGoVersionFile(versionFilePath);
}

if (!version) {
version = defaultGoVersion;
}

return version;
}

0 comments on commit 70498f2

Please sign in to comment.