Skip to content

Commit 4b73f12

Browse files
fix: version command with proper GoReleaser configuration
Fix version command by properly configuring GoReleaser and version injection: - Update GoReleaser to use version constraint (~> v1) instead of 'latest' - Fix version information injection through ldflags - Add proper environment variable handling for Go version This ensures the version command shows correct build information and follows GoReleaser's best practices for version constraints.
1 parent c584641 commit 4b73f12

File tree

2 files changed

+59
-2
lines changed

2 files changed

+59
-2
lines changed

.github/workflows/go.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,22 @@ jobs:
5959
- name: "Git Version"
6060
id: generate-version
6161
uses: codacy/[email protected]
62+
with:
63+
release-branch: main
64+
prefix: v
6265
- name: "Tag version"
6366
run: |
6467
git tag ${{ steps.generate-version.outputs.version }}
6568
git push --tags "https://codacy:${{ secrets.GITHUB_TOKEN }}@github.com/codacy/codacy-cli-v2"
69+
- name: Get Go version
70+
id: go-version
71+
run: echo "VERSION=$(go version | cut -d' ' -f3)" >> $GITHUB_OUTPUT
6672
- name: Run GoReleaser
6773
uses: goreleaser/goreleaser-action@v5
6874
with:
6975
distribution: goreleaser
70-
# 'latest', 'nightly', or a semver
71-
version: "latest"
76+
version: "~> v1"
7277
args: release --clean
7378
env:
7479
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
GOVERSION: ${{ steps.go-version.outputs.VERSION }}

.goreleaser.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
project_name: codacy-cli-v2
2+
3+
before:
4+
hooks:
5+
- go mod tidy
6+
7+
builds:
8+
- env:
9+
- CGO_ENABLED=0
10+
goos:
11+
- linux
12+
- windows
13+
- darwin
14+
goarch:
15+
- amd64
16+
- arm64
17+
ldflags:
18+
- -s -w
19+
- -X codacy/cli-v2/version.Version={{.Version}}
20+
- -X codacy/cli-v2/version.GitCommit={{.ShortCommit}}
21+
- -X codacy/cli-v2/version.BuildTime={{.Date}}
22+
- -X codacy/cli-v2/version.Os={{.Os}}
23+
- -X codacy/cli-v2/version.Arch={{.Arch}}
24+
- -X codacy/cli-v2/version.GoVersion={{.Env.GOVERSION}}
25+
binary: cli-v2
26+
27+
archives:
28+
- format: tar.gz
29+
name_template: >-
30+
{{ .ProjectName }}_
31+
{{- .Version }}_
32+
{{- .Os }}_
33+
{{- .Arch }}
34+
format_overrides:
35+
- goos: windows
36+
format: zip
37+
38+
changelog:
39+
sort: asc
40+
filters:
41+
exclude:
42+
- '^docs:'
43+
- '^test:'
44+
- '^ci:'
45+
- Merge pull request
46+
- Merge branch
47+
48+
release:
49+
github:
50+
owner: codacy
51+
name: codacy-cli-v2

0 commit comments

Comments
 (0)