-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from qvalentin/master
[FIX] use goreleaser for cross compiling
- Loading branch information
Showing
3 changed files
with
131 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
builds: | ||
- id: darwin-amd64 | ||
main: ./ | ||
binary: helm-ls | ||
goos: | ||
- darwin | ||
goarch: | ||
- amd64 | ||
env: | ||
- CC=o64-clang | ||
- CXX=o64-clang++ | ||
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 }} | ||
- id: darwin-arm64 | ||
binary: helm-ls | ||
main: ./ | ||
goarch: | ||
- arm64 | ||
goos: | ||
- darwin | ||
env: | ||
- CC=oa64-clang | ||
- CXX=oa64-clang++ | ||
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 }} | ||
- id: linux-amd64 | ||
main: ./ | ||
binary: helm-ls | ||
goos: | ||
- linux | ||
goarch: | ||
- amd64 | ||
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 }} | ||
- id: linux-arm64 | ||
main: ./ | ||
binary: helm-ls | ||
goos: | ||
- linux | ||
goarch: | ||
- arm64 | ||
env: | ||
- CC=aarch64-linux-gnu-gcc | ||
- CXX=aarch64-linux-gnu-g++ | ||
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 }} | ||
- id: windows-amd64 | ||
main: ./ | ||
binary: helm-ls | ||
goarch: | ||
- amd64 | ||
goos: | ||
- windows | ||
env: | ||
- CC=x86_64-w64-mingw32-gcc | ||
- CXX=x86_64-w64-mingw32-g++ | ||
flags: | ||
- -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 }} | ||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ .Tag }}" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,8 @@ export ROOT=$(realpath $(dir $(firstword $(MAKEFILE_LIST)))) | |
export BIN=$(ROOT)/bin | ||
export GOBIN?=$(BIN) | ||
export GO=$(shell which go) | ||
export CGO_ENABLED=1 | ||
export GOX=$(BIN)/gox | ||
export XGO=$(BIN)/xgo | ||
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)) | ||
|
@@ -46,10 +45,6 @@ lint: | |
echo "and fix them if necessary before submitting the code for reviewal."; \ | ||
fi | ||
|
||
.PHONY: gox | ||
gox: | ||
@gox -output="dist/helm_ls_{{.OS}}_{{.Arch}}" | ||
|
||
# for ci jobs, runs lint against the changed packages in the commit | ||
ci-lint: | ||
@$(LINTER) $(LINTERCMD) --deadline 10m ./... | ||
|
@@ -62,28 +57,17 @@ install-metalinter: | |
test: | ||
@$(GO) test ./... -v -race | ||
|
||
install-gox: | ||
@$(GO) install github.com/mitchellh/[email protected] | ||
|
||
install-xgo: | ||
@$(GO) install src.techknowlogick.com/xgo@latest | ||
|
||
|
||
.PHONY: build-linux | ||
build-linux: install-xgo | ||
echo ${GO_LDFLAGS} | ||
$(XGO) -dest dist -ldflags '$(GO_LDFLAGS)' -targets 'linux/amd64,linux/arm64' -out helm_ls . | ||
|
||
.PHONY: build-macOS | ||
build-macOS: install-xgo | ||
$(XGO) -dest dist -ldflags '$(GO_LDFLAGS)' -targets 'darwin-10.12/amd64' -out helm_ls . | ||
|
||
.PHONY: build-windows | ||
build-windows: install-xgo | ||
$(XGO) -buildmode exe -dest dist -ldflags '-linkmode external -extldflags "-static" $(GO_LDFLAGS)' -targets 'windows/amd64' -out helm_ls . | ||
|
||
.PHONY: build-artifacts | ||
build-artifacts: | ||
@$(MAKE) build-linux && \ | ||
$(MAKE) build-macOS && \ | ||
$(MAKE) build-windows | ||
.PHONY: build-release | ||
build-release: | ||
@docker run \ | ||
--rm \ | ||
-e CGO_ENABLED=1 \ | ||
-e COMPILED_BY=$(COMPILED_BY) \ | ||
-e BRANCH_NAME=$(BRANCH_NAME) \ | ||
-e BUILD_TIME=$(BUILD_TIME) \ | ||
-e GIT_COMMIT=$(GIT_COMMIT) \ | ||
-v /var/run/docker.sock:/var/run/docker.sock \ | ||
-v `pwd`:/go/src/$(PACKAGE_NAME) \ | ||
-w /go/src/$(PACKAGE_NAME) \ | ||
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \ | ||
--clean --skip-validate --skip-publish --snapshot |