Closed jay-kinder closed 1 year ago
you are likely not running it against a tag.
This is still causing a problem:
github action:
name: Release Pipeline
on:
push:
tags:
- "*"
jobs:
release:
name: Release New Version
runs-on: ubuntu-latest
steps:
- name: Check Out Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: "./go.mod"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
.goreleaser yaml (I was under the impression the ldflag i want was default, but just to be sure i tried this)
project_name: grole
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
ldflags:
- -s -w -X main.version={{.Version}}
main.go
var version = "dev"
func main(){
fmt.Printf("version: %s 👍\n", version)
}
I've taken lots of functionality out of my main.go, but this is the jist of the issue. This always causes version: dev 👍
to be printed
Thanks
can you make a minimal reproducible example repository?
@jay-kinder try setting it up like this: - -s -w -X "main.version={{.Version}}"
e.g.
project_name: grole
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
ldflags:
- -s -w -X "main.version={{.Version}}"
https://goreleaser.com/cookbooks/using-main.version/
Please let me know if i have misunderstood this, but I was expecting to have a
main.version
ldflag available to me in mymain.go
.I have set it up as above, but always receive a
dev
response when using the-v
flag.If I have misunderstood, is there a way to get hold of this through the action? Thanks