Compare commits

...

13 Commits

Author SHA1 Message Date
Victor Martinez
08276c43a9
Merge b544d3a2e3 into 883490dfd0 2023-08-30 09:39:04 +02:00
Marko Zivic
883490dfd0
Merge pull request #417 from artemgavrilov/main
Improve documentation regarding dependencies caching
2023-08-30 09:35:35 +02:00
Artem Gavrilov
d45ebba0ce
Rephrase sentence
Co-authored-by: Ivan <98037481+IvanZosimov@users.noreply.github.com>
2023-08-29 15:43:02 +02:00
Artem Gavrilov
317c6617fa
Replace wildcards term with globs. 2023-08-28 12:47:43 +02:00
Artem Gavrilov
f90673ad64
Merge pull request #1 from artemgavrilov/caching-docs-improvement
Improve documentation regarding dependencies caching
2023-08-25 12:37:15 +02:00
Artem Gavrilov
8018234347
Improve documentation regarding dependencies cachin 2023-08-25 12:31:19 +02:00
Victor Martinez
b544d3a2e3
add link to the .tool-versions 2023-08-15 14:32:46 +02:00
Victor Martinez
0fc6876467
docs: multiline sentence
add example for using .tool-versions
2023-08-15 14:32:29 +02:00
Victor Martinez
721bdf3e4e
docs: add tiny reference for the .tool-versions
See https://github.com/actions/setup-go/pull/402
2023-08-15 14:26:05 +02:00
Victor Martinez
fde5dd24bd
add go-version output when using go.mod 2023-08-15 14:23:31 +02:00
Victor Martinez
4878e37175
Merge remote-tracking branch 'upstream/main' into feature/go-file-version
* upstream/main: (47 commits)
  Fix Install on Windows is very slow (#393)
  Bump word-wrap from 1.2.3 to 1.2.4
  Fix licensing for Semver 6.3.1
  Rebuild after updating Semver
  Bump semver from 6.3.0 to 6.3.1
  Bump tough-cookie and @azure/ms-rest-js (#392)
  Limit to Linux only
  Add imageOS to primaryKey
  Add note about YAML parsing versions (#382)
  Added a description that go-version should be specified as a string type (#367)
  Update action.yml (#379)
  Move eslint-plugin-node to dev dependencies
  Install eslint-plugin-node
  Update configuration files
  Bump @actions/cache dependency to v3.2.1 (#374)
  Update xml2js (#370)
  Fix glob bug in package.json scripts section (#359)
  update README fo v4 (#354)
  Update configuration files (#348)
  Add Go bin if go-version input is empty (#351)
  ...
2023-08-15 14:20:22 +02:00
Victor Martinez
ef084a2719
Update README.md 2022-11-30 11:09:17 +00:00
Victor Martinez
ad27ba4c6d
docs: go-version-file for other use cases 2022-11-30 10:43:38 +00:00

View File

@ -59,11 +59,11 @@ steps:
```
> **Note**: Due to the peculiarities of YAML parsing, it is recommended to wrap the version in single quotation marks:
>
>
> ```yaml
> go-version: '1.20'
> ```
>
>
> The recommendation is based on the YAML parser's behavior, which interprets non-wrapped values as numbers and, in the case of version 1.20, trims it down to 1.2, which may not be very obvious.
Matching an unstable pre-release:
@ -159,9 +159,9 @@ The `cache` input is optional, and caching is turned on by default.
The action defaults to search for the dependency file - go.sum in the repository root, and uses its hash as a part of
the cache key. Use `cache-dependency-path` input for cases when multiple dependency files are used, or they are located
in different subdirectories.
in different subdirectories. The input supports glob patterns.
If some problem that prevents success caching happens then the action issues the warning in the log and continues the execution of the pipeline.
If some problem that prevents success caching happens then the action issues the warning in the log and continues the execution of the pipeline.
**Caching in monorepos**
@ -172,19 +172,26 @@ steps:
with:
go-version: '1.17'
check-latest: true
cache-dependency-path: subdir/go.sum
cache-dependency-path: |
subdir/go.sum
tools/go.sum
# cache-dependency-path: "**/*.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 [versions-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 or .tool-versions files
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
```yaml
@ -196,6 +203,34 @@ steps:
- run: go version
```
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
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
```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