diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index 1a8d0185..0cdbb9ba 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -14,7 +14,6 @@ on: - v* jobs: - artifacts: name: artifacts strategy: @@ -31,42 +30,44 @@ jobs: go-version: ${{ matrix.go-version }} - name: Checkout code uses: actions/checkout@v3 - - - name: Install go dependencies - run: go mod tidy - - - name: Build artifacts - id: build + - name: release publish run: | - make build-artifacts - printf '::set-output name=version::%s\n' "$(./dist/helm_ls_linux_amd64 version)" + 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 with: name: helm_ls_darwin_amd64 - path: ./dist/helm_ls-darwin-10.12-amd64 + path: ./dist/darwin-amd64_darwin_amd64_v1/helm-ls + retention-days: 1 + + - name: 'Upload macOS-arm64 artifact' + uses: actions/upload-artifact@v2 + with: + name: helm_ls_darwin_arm64 + path: ./dist/darwin-arm64_darwin_arm64/helm-ls retention-days: 1 - name: 'Upload linux/amd64 artifact' uses: actions/upload-artifact@v2 with: name: helm_ls_linux_amd64 - path: ./dist/helm_ls-linux-amd64 + path: ./dist/linux-amd64_linux_amd64_v1/helm-ls retention-days: 1 - name: 'Upload linux/arm artifact' uses: actions/upload-artifact@v2 with: name: helm_ls_linux_arm - path: ./dist/helm_ls-linux-arm64 + path: ./dist/linux-arm64_linux_arm64/helm-ls retention-days: 1 - name: 'Upload windows/amd64 artifact' uses: actions/upload-artifact@v2 with: name: helm_ls_windows_amd64 - path: ./dist/helm_ls-windows-4.0-amd64.exe + path: ./dist/windows-amd64_windows_amd64_v1/helm-ls.exe retention-days: 1 publish: @@ -93,22 +94,27 @@ jobs: - name: Generate Linux-64 SHA256 checksums run: | - sha256sum helm_ls_linux_amd64/helm_ls-linux-amd64 > helm_ls_linux_amd64.sha256sum + sha256sum helm_ls_linux_amd64/helm-ls > helm_ls_linux_amd64.sha256sum echo "SHA_LINUX_64=$(cat helm_ls_linux_amd64.sha256sum)" >> $GITHUB_ENV - name: Generate Windows-64 SHA256 checksums run: | - sha256sum helm_ls_windows_amd64/helm_ls-windows-4.0-amd64.exe > helm_ls_windows_amd64.sha256sum + sha256sum helm_ls_windows_amd64/helm-ls.exe > helm_ls_windows_amd64.sha256sum echo "SHA_WINDOWS_64=$(cat helm_ls_windows_amd64.sha256sum)" >> $GITHUB_ENV - name: Generate macOS-amd64 SHA256 checksums run: | - sha256sum helm_ls_darwin_amd64/helm_ls-darwin-10.12-amd64 > helm_ls_darwin_amd64.sha256sum - echo "SHA_MACOS=$(cat helm_ls_darwin_amd64.sha256sum)" >> $GITHUB_ENV + sha256sum helm_ls_darwin_amd64/helm-ls > helm_ls_darwin_amd64.sha256sum + echo "SHA_MACOS_AMD64=$(cat helm_ls_darwin_amd64.sha256sum)" >> $GITHUB_ENV + + - name: Generate macOS-arm64 SHA256 checksums + run: | + sha256sum helm_ls_darwin_arm64/helm-ls > helm_ls_darwin_arm64.sha256sum + echo "SHA_MACOS_ARM64=$(cat helm_ls_darwin_arm64.sha256sum)" >> $GITHUB_ENV - name: Generate Linux-ARM SHA256 checksums run: | - sha256sum helm_ls_linux_arm/helm_ls-linux-arm64 > helm_ls_linux_arm.sha256sum + sha256sum helm_ls_linux_arm/helm-ls > helm_ls_linux_arm.sha256sum echo "SHA_LINUX_ARM=$(cat helm_ls_linux_arm.sha256sum)" >> $GITHUB_ENV - if: env.TAG_NAME == 'master' @@ -127,13 +133,15 @@ jobs: gzip: false allow_override: true files: | - helm_ls_darwin_amd64:./helm_ls_darwin_amd64/helm_ls-darwin-10.12-amd64 + helm_ls_darwin_amd64:./helm_ls_darwin_amd64/helm-ls helm_ls_darwin_amd64.sha256sum:./helm_ls_darwin_amd64.sha256sum - helm_ls_windows_amd64:./helm_ls_windows_amd64/helm_ls-windows-4.0-amd64.exe + helm_ls_darwin_arm64:./helm_ls_darwin_arm64/helm-ls + helm_ls_darwin_arm64.sha256sum:./helm_ls_darwin_arm64.sha256sum + helm_ls_windows_amd64.exe:./helm_ls_windows_amd64/helm-ls.exe helm_ls_windows_amd64.sha256sum:./helm_ls_windows_amd64.sha256sum - helm_ls_linux_amd64:./helm_ls_linux_amd64/helm_ls-linux-amd64 + helm_ls_linux_amd64:./helm_ls_linux_amd64/helm-ls helm_ls_linux_amd64.sha256sum:./helm_ls_linux_amd64.sha256sum - helm_ls_linux_arm:./helm_ls_linux_arm/helm_ls-linux-arm64 + helm_ls_linux_arm:./helm_ls_linux_arm/helm-ls helm_ls_linux_arm.sha256sum:./helm_ls_linux_arm.sha256sum body: | ``` @@ -142,6 +150,9 @@ jobs: ### macOS (x64) 1. Download **helm_ls_darwin_amd64** 2. Run `./helm_ls_darwin_amd64` + ### macOS (ARM) + 1. Download **helm_ls_darwin_arm64** + 2. Run `./helm_ls_darwin_arm64` ### windows (x64) 1. Download **helm_ls_windows_amd64.exe** 2. Run `./helm_ls_windows_amd64.exe` @@ -155,7 +166,8 @@ jobs: ``` ${{ env.SHA_LINUX_64 }} - ${{ env.SHA_MACOS }} + ${{ env.SHA_MACOS_AMD64 }} + ${{ env.SHA_MACOS_ARM64 }} ${{ env.SHA_WINDOWS_64 }} ${{ env.SHA_LINUX_ARM }} ``` diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 00000000..1851f5eb --- /dev/null +++ b/.goreleaser.yaml @@ -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:' + diff --git a/Makefile b/Makefile index 72472e49..27d3ed48 100644 --- a/Makefile +++ b/Makefile @@ -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/gox@v1.0.1 - -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