diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index 0cdbb9ba..1540058a 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -21,8 +21,6 @@ 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 @@ -30,10 +28,9 @@ jobs: 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 @@ -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` diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1373c90b..dbd639c1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,6 +2,8 @@ name: Lint on: push: + branches: + - "master" pull_request: jobs: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f14343d1..93789e15 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,6 +2,8 @@ name: Tests on: push: + branches: + - "master" pull_request: jobs: diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 1851f5eb..79616442 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -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: ./ @@ -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 @@ -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 @@ -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 @@ -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: diff --git a/Makefile b/Makefile index 27d3ed48..260f3e0e 100644 --- a/Makefile +++ b/Makefile @@ -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 \ @@ -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) \ diff --git a/cmds/version.go b/cmds/version.go index 8b145c26..b9395393 100644 --- a/cmds/version.go +++ b/cmds/version.go @@ -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") }, } } diff --git a/main.go b/main.go index de233430..6af9da2d 100644 --- a/main.go +++ b/main.go @@ -13,6 +13,7 @@ import ( var ( BranchName string Version string + GitCommit string CompiledBy string BuildTime string ) @@ -36,6 +37,7 @@ func main() { vi := &version.BuildInfo{ Version: Version, Branch: BranchName, + GitCommit: GitCommit, CompiledBy: CompiledBy, GoVersion: runtime.Version(), BuildTime: BuildTime,