Comments (18)
I'm using this:
jobs:
dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Determine Go version from go.mod
run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
- uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
So I only have to maintain go.mod. Only works if you don't need matrix builds ofc :)
But it would be nice if this action could do that on its own, e.g. have a property go-mod-path: go.mod
from setup-go.
Having an option like this would also allow interoperability with goenv which stores local version in .go-version
file in the root of the repo.
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version-from-file: .go-version
Picking up the version implicitly from there would be even better, but I suppose that would be better job for a more scoped Action with goenv, rather than generic Go one?
At least it seems that there is no precedent for version managers in official setup-language
Actions.
from setup-go.
@jmhodges : how I do it is I extract the Go version to use out of my Docker containers, print it and put it in a GitHub Actions variable. It works with dependabot for automatic updates that way.
from setup-go.
For reference my GitHub Action as seen on iron-go-project:
name: benchmark
on: pull_request
jobs:
gobench:
name: benchmarking
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v2
-
id: vars
run: |
echo ::set-output name=go_version::$(grep '^FROM go' .github/go/Dockerfile | cut -d ' ' -f 2 | cut -d ':' -f 2)
echo "Using Go version ${{ steps.vars.outputs.go_version }}"
-
name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ steps.vars.outputs.go_version }}
My file .github/go/Dockerfile
:
FROM golang:1.14.1
And keeping the file updated automatically in .github/dependabot.yml
:
version: 2
updates:
- package-ecosystem: docker
directory: "/.github/go"
schedule:
interval: daily
time: '04:00'
open-pull-requests-limit: 10
target-branch: dev
from setup-go.
Thanks @ccremer . Came here to see if reading from go.mod
was a feature or request but glad to see a snippet for a workaround. ⭐
I've added that snippet to my Go / GH Actions cookbook section, with a link back here - Setup Go cookbook.
I also did a dive into syntax and examples for both $GITHUB_ENV
and the outputs
approaches and documented here - Persist.
from setup-go.
Thanks @hazcod for sharing your snippet and iron project. The CI flows there are extensive and I can use in my own projects. I've added a link in my own template to your template.
Would you consider turning issues on to make it easier to discuss before making a PR?
from setup-go.
@MichaelCurrin Thank you! Enabled issues.
from setup-go.
I believe this can be closed now that v3 and v3.1.0 now include the go-version-file
input from #62 🎉
Reference: https://github.com/actions/setup-go/releases/tag/v3.1.0
from setup-go.
Hello guys,
As @bflad said, I will close this issue now, due to the fact that it is resolved. If you have any comments or concerns, feel free to leave them here or to create a new issue.
from setup-go.
I was able to verify that go-version-file: '.go-version'
with those file contents being 1.17.8
was able to work as expected, setting up Go 1.17.8 for the job.
from setup-go.
My setup-go config now looks like:
- name: Read Go versions
run: echo "##[set-output name=go_version;]$(cat .github/versions/go)"
id: go_versions
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: ${{ steps.go_versions.outputs.go_version }}
id: go
Example PR that came from it: jmhodges/howsmyssl#267
It'd be nice to get this baked in. The cat
inside it means I can only support one version at a time (I believe) and with a more standard support, we could fix that
from setup-go.
@jmhodges on the set output, note that you should use ::
syntax. ##
was deprecated. See here: https://github.com/actions/toolkit/blob/master/docs/commands.md
@radeksimko - nice idea. Since go-version input is a string, I may just overload that and do special handling for the value .go-version
from setup-go.
Unfortunately, that regex deal wouldn’t give us an auditable version. It’d pick up whatever was the latest version when it happened to run, instead of when told to bump it. There’d be no way to track the PR it came in, etc
from setup-go.
Hi @jmhodges ! Sorry for the late response!
Could you please clarify if the issue is still actual for you?
Thanks!
from setup-go.
@Sergey-Murtazin Speaking for myself and some of my colleagues, this is still actual.
FYI There is also a PR addressing this problem #62 which was raised in July 2020. Would there be interest in merging it, or is there any particular reason not to merge it?
from setup-go.
Yeah, I'm still having this problem.
from setup-go.
Ah, shoot, go-version-file
not being able to specify a patch level means it won't work for me.
This is a bummer because I was hoping dependabot could help me here. (Though, dependabot's gomod
setting seems to not have a setting to touch the go version in go.mod
anyhow)
from setup-go.
Hi, @jmhodges 👋 In your case, instead of specifying path to go.mod
file in the input go-version-file
you can specify path to the go
file that you're using in your projects. In this way you can just keep the go
file up to date and setup-go action will use full semantic version (including patch version) out of that file.
If you have any questions, feel free to ask me 📟
Cheers!
from setup-go.
Related Issues (20)
- Feature - enhance action to support configuration of private package authentication HOT 3
- Long post job cleanup HOT 8
- v4 cache attempt to write to non existent drive on windows HOT 13
- setup-go does not pick up recent Go version leading to create vulnerable builds HOT 6
- support: gotip HOT 6
- https://salla.sa/bero2030.com HOT 1
- Berroe8 HOT 1
- caches grow unbounded HOT 6
- ENOENT: no such file or directory, mkdir '/home/runner' in macos-latest HOT 3
- Use version from module and another version in matrix testing HOT 2
- Allow for collapsing log output HOT 2
- go 1.22.0-rc.1 is not found HOT 2
- setup-go does not work on macos-14 (M1) HOT 6
- How to run tests with latest golang version HOT 9
- More specific handling/detection of Go toolchain versions HOT 3
- Inaccurate description of version in go.mod HOT 2
- Please upgrade `go-actions` to 1.21.8 / 1.22.1 HOT 3
- Signing key has expired HOT 2
- Node16 deprecated HOT 1
- Support custom distribution location override HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from setup-go.