Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(release): clean up ldflags for version #55

Merged
merged 2 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,16 @@ jobs:
go-version: [1.19.1]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
outputs:
version: ${{ steps.build.outputs.version }}
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
- name: release publish
- name: build
run: |
make build-release
printf '::set-output name=version::%s\n' "$(./dist/linux-amd64_linux_amd64_v1/helm-ls version)"

- name: 'Upload macOS-amd64 artifact'
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -144,9 +141,6 @@ jobs:
helm_ls_linux_arm:./helm_ls_linux_arm/helm-ls
helm_ls_linux_arm.sha256sum:./helm_ls_linux_arm.sha256sum
body: |
```
${{ needs.artifacts.outputs.version }}
```
### macOS (x64)
1. Download **helm_ls_darwin_amd64**
2. Run `./helm_ls_darwin_amd64`
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Lint

on:
push:
branches:
- "master"
pull_request:

jobs:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Tests

on:
push:
branches:
- "master"
pull_request:

jobs:
Expand Down
10 changes: 5 additions & 5 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ builds:
flags:
- -mod=readonly
ldflags:
- -s -w -X main.Version={{ .Env.GIT_COMMIT }} -X main.CompiledBy={{ .Env.COMPILED_BY }} -X main.BranchName={{ .Env.BRANCH_NAME }} -X main.BuildTime={{ .Env.BUILD_TIME }}
- -s -w -X main.Version={{ .Env.VERSION }} -X main.GitCommit={{ .Env.GIT_COMMIT }} -X main.CompiledBy={{ .Env.COMPILED_BY }} -X main.Branch={{ .Env.BRANCH_NAME }} -X main.BuildTime={{ .Env.BUILD_TIME }}
- id: darwin-arm64
binary: helm-ls
main: ./
Expand All @@ -26,7 +26,7 @@ builds:
flags:
- -trimpath
ldflags:
- -X main.Version={{ .Env.GIT_COMMIT }} -X main.CompiledBy={{ .Env.COMPILED_BY }} -X main.BranchName={{ .Env.BRANCH_NAME }} -X main.BuildTime={{ .Env.BUILD_TIME }}
- -X main.Version={{ .Env.VERSION }} -X main.GitCommit={{ .Env.GIT_COMMIT }} -X main.CompiledBy={{ .Env.COMPILED_BY }} -X main.Branch={{ .Env.BRANCH_NAME }} -X main.BuildTime={{ .Env.BUILD_TIME }}
- id: linux-amd64
main: ./
binary: helm-ls
Expand All @@ -37,7 +37,7 @@ builds:
flags:
- -mod=readonly
ldflags:
- -s -w -X main.Version={{ .Env.GIT_COMMIT }} -X main.CompiledBy={{ .Env.COMPILED_BY }} -X main.BranchName={{ .Env.BRANCH_NAME }} -X main.BuildTime={{ .Env.BUILD_TIME }}
- -s -w -X main.Version={{ .Env.VERSION }} -X main.GitCommit={{ .Env.GIT_COMMIT }} -X main.CompiledBy={{ .Env.COMPILED_BY }} -X main.Branch={{ .Env.BRANCH_NAME }} -X main.BuildTime={{ .Env.BUILD_TIME }}
- id: linux-arm64
main: ./
binary: helm-ls
Expand All @@ -51,7 +51,7 @@ builds:
flags:
- -trimpath
ldflags:
- -s -w -X main.Version={{ .Env.GIT_COMMIT }} -X main.CompiledBy={{ .Env.COMPILED_BY }} -X main.BranchName={{ .Env.BRANCH_NAME }} -X main.BuildTime={{ .Env.BUILD_TIME }}
- -s -w -X main.Version={{ .Env.VERSION }} -X main.GitCommit={{ .Env.GIT_COMMIT }} -X main.CompiledBy={{ .Env.COMPILED_BY }} -X main.Branch={{ .Env.BRANCH_NAME }} -X main.BuildTime={{ .Env.BUILD_TIME }}
- id: windows-amd64
main: ./
binary: helm-ls
Expand All @@ -66,7 +66,7 @@ builds:
- -trimpath
- -buildmode=exe
ldflags:
- -X main.Version={{ .Env.GIT_COMMIT }} -X main.CompiledBy={{ .Env.COMPILED_BY }} -X main.BranchName={{ .Env.BRANCH_NAME }} -X main.BuildTime={{ .Env.BUILD_TIME }}
- -X main.Version={{ .Env.VERSION }} -X main.GitCommit={{ .Env.GIT_COMMIT }} -X main.CompiledBy={{ .Env.COMPILED_BY }} -X main.Branch={{ .Env.BRANCH_NAME }} -X main.BuildTime={{ .Env.BUILD_TIME }}
checksum:
name_template: 'checksums.txt'
snapshot:
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export PACKAGE_NAME=github.com/mrjosh/helm-ls
export GOLANG_CROSS_VERSION=v1.20.6

$(eval GIT_COMMIT=$(shell git rev-parse --short HEAD))
$(eval BRANCH_NAME=$(shell git rev-parse --abbrev-ref HEAD))
$(eval BRANCH_NAME=$(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match))
$(eval COMPILED_BY=$(shell hostname))
$(eval BUILD_TIME=$(shell date -u '+%Y-%m-%d_%I:%M:%S%p'))

GO_LDFLAGS := -X "main.CompiledBy=${COMPILED_BY}" -X "main.Version=${GIT_COMMIT}" -X "main.BranchName=${BRANCH_NAME}" -X "main.BuildTime=${BUILD_TIME}"
GO_LDFLAGS :=" -X main.Version=${BRANCH_NAME} -X main.CompiledBy=${COMPILED_BY} -X main.GitCommit=${GIT_COMMIT} -X main.Branch=${BRANCH_NAME} -X main.BuildTime=${BUILD_TIME}"

export LINTER=$(GOBIN)/golangci-lint
export LINTERCMD=run --no-config -v \
Expand Down Expand Up @@ -63,6 +63,7 @@ build-release:
--rm \
-e CGO_ENABLED=1 \
-e COMPILED_BY=$(COMPILED_BY) \
-e VERSION=$(BRANCH_NAME) \
-e BRANCH_NAME=$(BRANCH_NAME) \
-e BUILD_TIME=$(BUILD_TIME) \
-e GIT_COMMIT=$(GIT_COMMIT) \
Expand Down
7 changes: 4 additions & 3 deletions cmds/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ func newVersionCmd() *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {
fmt.Fprintf(
cmd.OutOrStdout(),
"%s\n%s\n%s\n%s\n%s\n",
fmt.Sprintf("HelmLs version: %s", versionInfo.Version),
"%s\n%s\n%s\n%s\n%s\n%s\n",
fmt.Sprintf("Helm-ls version: %s", versionInfo.Version),
fmt.Sprintf("Git commit: %s", versionInfo.GitCommit),
fmt.Sprintf("Build type: %s", versionInfo.BuildType),
fmt.Sprintf("Build time: %s", versionInfo.BuildTime),
fmt.Sprintf("Golang: %s", versionInfo.GoVersion),
fmt.Sprintf("Compiled by: %s", versionInfo.CompiledBy),
)
logger.Debug("Additional debug info")
logger.Debug("Additional debug info will be printed")
},
}
}
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
var (
BranchName string
Version string
GitCommit string
CompiledBy string
BuildTime string
)
Expand All @@ -36,6 +37,7 @@ func main() {
vi := &version.BuildInfo{
Version: Version,
Branch: BranchName,
GitCommit: GitCommit,
CompiledBy: CompiledBy,
GoVersion: runtime.Version(),
BuildTime: BuildTime,
Expand Down
Loading