From ad27ba4c6dc97d54ca054ccff3de3d2297c57c50 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 30 Nov 2022 10:43:38 +0000 Subject: [PATCH 1/6] docs: go-version-file for other use cases --- README.md | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8ef09d476..cf1b04f9c 100644 --- a/README.md +++ b/README.md @@ -125,11 +125,16 @@ steps: cache-dependency-path: subdir/go.sum - run: go run hello.go ``` -## Getting go version from the go.mod file - -The `go-version-file` input accepts a path to a `go.mod` file or a `go.work` file that contains the version of Go to be used by a project. As the `go.mod` file contains only major and minor (e.g. 1.18) tags, the action will search for the latest available patch version sequentially in the runner's directory with the cached tools, in the [version-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json) file or at the go servers. +## Getting go version from a file If both the `go-version` and the `go-version-file` inputs are provided then the `go-version` input is used. + +If the file contains only major and minor (e.g. 1.18) tags, the action will search for the latest available patch version sequentially in the runner's directory with the cached tools, in the [version-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json) file or at the go servers. + +### If the go.mod file + +The `go-version-file` input accepts a path to a `go.mod` file or a `go.work` file that contains the version of Go to be used by a project. As the `go.mod` file contains only major and minor (e.g. 1.18) tags, the action will follow the above-mentioned approach. + > The action will search for the `go.mod` file relative to the repository root ```yaml @@ -141,6 +146,21 @@ steps: - run: go version ``` +### If a different file + +The `go-version-file` input accepts a path to a file file that contains the version of Go to be used by a project. It supports either major and minor (e.g 1.18) or major, minor and patch (e.g 1.18.7) tags + +> The action will search for the `.go-version` file relative to the repository root + +```yaml +steps: +- uses: actions/checkout@v3 +- uses: actions/setup-go@v3 + with: + go-version-file: 'path/to/.go-version' +- run: go version +``` + ## Matrix testing ```yaml From ef084a2719de0778a2a45cc8a7ce5c26cdb448c9 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 30 Nov 2022 11:09:17 +0000 Subject: [PATCH 2/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cf1b04f9c..5a2a1749e 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ steps: ### If a different file -The `go-version-file` input accepts a path to a file file that contains the version of Go to be used by a project. It supports either major and minor (e.g 1.18) or major, minor and patch (e.g 1.18.7) tags +The `go-version-file` input accepts a path to a file that contains the version of Go to be used by a project. It supports either major and minor (e.g 1.18) or major, minor and patch (e.g 1.18.7) tags. If the file contains only major and minor (e.g. 1.18) tags, the action will follow the above-mentioned approach. > The action will search for the `.go-version` file relative to the repository root From fde5dd24bd8d1dfc2a055288385cb9500846aa93 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 15 Aug 2023 14:23:31 +0200 Subject: [PATCH 3/6] add go-version output when using go.mod --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 913ccd198..f81184c5e 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,8 @@ steps: - run: go version ``` +Finally, the `go-version` output contains the resolved Golang version from the `go.mod` file. + ### If a different file The `go-version-file` input accepts a path to a file that contains the version of Go to be used by a project. It supports either major and minor (e.g 1.18) or major, minor and patch (e.g 1.18.7) tags. If the file contains only major and minor (e.g. 1.18) tags, the action will follow the above-mentioned approach. From 721bdf3e4e1c7f0d1920b41e763c89673da95d4c Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 15 Aug 2023 14:26:05 +0200 Subject: [PATCH 4/6] docs: add tiny reference for the .tool-versions See https://github.com/actions/setup-go/pull/402 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f81184c5e..903e83f0b 100644 --- a/README.md +++ b/README.md @@ -181,9 +181,9 @@ If both the `go-version` and the `go-version-file` inputs are provided then the If the file contains only major and minor (e.g. 1.18) tags, the action will search for the latest available patch version sequentially in the runner's directory with the cached tools, in the [version-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json) file or at the go servers. -### If the go.mod file +### If the go.mod or .tool-versions files -The `go-version-file` input accepts a path to a `go.mod` file or a `go.work` file that contains the version of Go to be used by a project. As the `go.mod` file contains only major and minor (e.g. 1.18) tags, the action will follow the above-mentioned approach. +The `go-version-file` input accepts a path to a `go.mod` file, `.tool-versions` file or a `go.work` file that contains the version of Go to be used by a project. As the `go.mod` file contains only major and minor (e.g. 1.18) tags, the action will follow the above-mentioned approach. > The action will search for the `go.mod` file relative to the repository root From 0fc68764677ba58e54f6823bdee35545d976dc5c Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 15 Aug 2023 14:32:29 +0200 Subject: [PATCH 5/6] docs: multiline sentence add example for using .tool-versions --- README.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 903e83f0b..e7d2c0c5b 100644 --- a/README.md +++ b/README.md @@ -179,11 +179,14 @@ steps: If both the `go-version` and the `go-version-file` inputs are provided then the `go-version` input is used. -If the file contains only major and minor (e.g. 1.18) tags, the action will search for the latest available patch version sequentially in the runner's directory with the cached tools, in the [version-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json) file or at the go servers. +If the file contains only major and minor (e.g. 1.18) tags, the action will search for the latest available patch version +sequentially in the runner's directory with the cached tools, in the [version-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json) +file or at the go servers. ### If the go.mod or .tool-versions files -The `go-version-file` input accepts a path to a `go.mod` file, `.tool-versions` file or a `go.work` file that contains the version of Go to be used by a project. As the `go.mod` file contains only major and minor (e.g. 1.18) tags, the action will follow the above-mentioned approach. +The `go-version-file` input accepts a path to a `go.mod` file, `.tool-versions` file or a `go.work` file that contains the version of Go to be used by a project. +As the `go.mod` file contains only major and minor (e.g. 1.18) tags, the action will follow the above-mentioned approach. > The action will search for the `go.mod` file relative to the repository root @@ -196,7 +199,18 @@ steps: - run: go version ``` -Finally, the `go-version` output contains the resolved Golang version from the `go.mod` file. +The `go-version` output contains the resolved Golang version from the `go.mod` file. + +> The action will search for the `.tool-versions` file relative to the repository root + +```yaml +steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version-file: '.tool-versions' + - run: go version +``` ### If a different file From b544d3a2e3035ca424b12d67115e48d2170286d1 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 15 Aug 2023 14:32:46 +0200 Subject: [PATCH 6/6] add link to the .tool-versions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e7d2c0c5b..1ffbe53e4 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,7 @@ file or at the go servers. ### If the go.mod or .tool-versions files -The `go-version-file` input accepts a path to a `go.mod` file, `.tool-versions` file or a `go.work` file that contains the version of Go to be used by a project. +The `go-version-file` input accepts a path to a `go.mod` file, [.tool-versions](https://asdf-vm.com/manage/configuration.html#tool-versions) file or a `go.work` file that contains the version of Go to be used by a project. As the `go.mod` file contains only major and minor (e.g. 1.18) tags, the action will follow the above-mentioned approach. > The action will search for the `go.mod` file relative to the repository root