-
Notifications
You must be signed in to change notification settings - Fork 535
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
Add go-version-from-file option #62
Conversation
👋🏻 Is there anything in particular blocking this PR from being merged? |
Echoing the above, is there anything the community can do to help get this enhancement reviewed? It would be very useful to replace a workaround we use in a few dozen repositories that my team manages. |
goodluk so I like to aplikasion |
It would be great if this option can also read and extract the go version from a |
@ccremer I agree that such thing would be helpful, but it seems to me like a separate feature, as the complexity of pulling any content out of |
That's what I meant with
I implied that extracting requires parsing in that context :) I imagined something like
In any case, there are already workarounds to extract the version from go.mod. |
|
I second this, some repositories do not implement a |
Wow Best |
The Go version is already included in Essentially that would be something like this: This could be an alternative option as well. Instead "from file" a "from go mod" or something 🤔 See #174 (comment) |
I think those are two different things. The version in |
Hi, @jojo43 👋 We are planning to implement this feature in the next releases of the action, but your PR is a little bit outdated and may be updated. Are you still interested in contributing 🚀 ? |
@IvanZosimov |
Thanks for your answer, @jojo43 👍 One of our actions: setup-node, already has a pretty similar feature of getting a version of the node from a version file. You may take a look at the action's source code and use the same approach in the setup-go action. What we are planning to implement:
|
@IvanZosimov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jojo43 👋 Thank you very much for your update, it looks great, just a few changes are needed and it will brilliant ! Could I also ask you to sync your branch with the upstream branch and reattach this PR to the main
branch (now it's attached to the master)?
action.yml
Outdated
@@ -4,6 +4,8 @@ author: 'GitHub' | |||
inputs: | |||
go-version: | |||
description: 'The Go version to download (if necessary) and use. Supports semver spec and ranges.' | |||
go-version-from-file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go-version-from-file: | |
go-version-file: |
action.yml
Outdated
@@ -4,6 +4,8 @@ author: 'GitHub' | |||
inputs: | |||
go-version: | |||
description: 'The Go version to download (if necessary) and use. Supports semver spec and ranges.' | |||
go-version-from-file: | |||
description: Path to the file with the Go version. go-version overwrites this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: Path to the file with the Go version. go-version overwrites this. | |
description: 'Path to the go.mod file.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IvanZosimov FWIW as an end user I would find the original description more accurate. While I guess none of us can predict what % of users will end up specifying go.mod
and what other % .go-version
, but I assume (hope) that the intention is to support both and so the description should reflect that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @radeksimko 👋 ! Thank you, that's definitely a good point! We are going to update setup-go documentation with the new chapter related to this functionality with a more broad description of the input.
function resolveVersionInput(): string { | ||
let version = core.getInput('go-version'); | ||
const versionFilePath = core.getInput('go-version-file'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add here the warning when the user specifies both inputs:
if (version && versionFilePath) {
core.warning(
'Both go-version and go-version-file inputs are specified, only go-version will be used'
);
}
src/installer.ts
Outdated
@@ -266,3 +266,12 @@ export function makeSemver(version: string): string { | |||
|
|||
return `${verPart}${prereleasePart}`; | |||
} | |||
|
|||
export function parseGoVersionFile(contents: string, isMod: boolean): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the input go-version-file
should contain the path to a go.mod
file (we'll deliberately ask our customers to put there a path to go.mod
file ), I'd suggest not using isMod
parameter in this function and don't check whether path refers to 'go.mod' file.
src/main.ts
Outdated
if (versionFilePath) { | ||
version = installer.parseGoVersionFile( | ||
fs.readFileSync(versionFilePath).toString(), | ||
path.basename(versionFilePath) === 'go.mod' | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest keeping this conditional statement very similar to the one in setup-node action. Otherwise, some important functionality will be lost.
Hi, @jojo43 👋 Thanks a lot for your updates! Could you also update documentation (the README.md file) and add there this chapter:
|
Shifted chapter related to retrieving go version from go.mod file and updated yml example
Change README.md file
Hi all, Thank you for working on this! While reading this thread, I'm not sure why the Is it just an out of scope for the initial implementation? or it won't be supported by design? |
Hi, @minamijoyo 👋 Thanks a lot for your concerns, actually you are right there, the scope of this PR is to add retrieving Go version from Cheers! |
@IvanZosimov Thank you for the reply. Sounds good 😸 |
I added an option
go-version-from-file
as suggested in #23 (comment) .