diff --git a/.github/issue_template.md b/.github/issue_template.md index 48f48e5b6..3d186d21e 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -6,4 +6,3 @@ Output of `kubectl version`: Cloud Provider/Platform (AKS, GKE, Minikube etc.): - diff --git a/.github/workflows/.goreleaser.yaml b/.github/workflows/.goreleaser.yaml new file mode 100644 index 000000000..62958e9e2 --- /dev/null +++ b/.github/workflows/.goreleaser.yaml @@ -0,0 +1,38 @@ +project_name: helm + +builds: + - id: helm + main: ./cmd/helm + binary: helm + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm64 + goarm: + - 6 + env: + - CGO_ENABLED=0 + - GOFLAGS=-trimpath + ldflags: + - -s -w -extldflags "-static" + flags: + - -tags=netgo + output: _dist/{{ .Os }}-{{ .Arch }}/helm + +archives: + - id: default + name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" + format: tar.gz + files: + - LICENSE + - README.md + - _dist/{{ .Os }}-{{ .Arch }}/helm + +checksum: + name_template: checksums.txt + +snapshot: + name_template: "{{ .Commit }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 96138caf1..1d41e62f8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,14 +31,26 @@ jobs: uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # pin@5.5.0 with: go-version: '${{ env.GOLANG_VERSION }}' + - name: Run unit tests run: make test-coverage + - name: Build Helm Binaries run: | set -eu -o pipefail - make build-cross VERSION="${{ github.ref_name }}" - make dist checksum VERSION="${{ github.ref_name }}" + - name: Run Go Release + uses: goreleaser/goreleaser-action@v6.3.0 + if: success() && startsWith(github.ref, 'refs/tags/') + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + + - name: Verify checksum + run: | + make dist checksum VERSION="${{ github.ref_name }}" - name: Set latest version run: | @@ -93,10 +105,18 @@ jobs: - name: Run unit tests run: make test-coverage - - name: Build Helm Binaries + - name: Run Go Release + uses: goreleaser/goreleaser-action@v6.3.0 + if: success() && startsWith(github.ref, 'refs/tags/') + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + + - name: Verify checksum run: | - make build-cross - make dist checksum VERSION="canary" + make dist checksum VERSION="canary" - name: Upload Binaries uses: bacongobbler/azure-blob-storage-upload@50f7d898b7697e864130ea04c303ca38b5751c50 # pin@3.0.0 diff --git a/Makefile b/Makefile index 0785fdb2e..9889b4936 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,12 @@ BINDIR := $(CURDIR)/bin INSTALL_PATH ?= /usr/local/bin DIST_DIRS := find * -type d -exec -TARGETS := darwin/amd64 darwin/arm64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le linux/s390x linux/riscv64 windows/amd64 windows/arm64 -TARGET_OBJS ?= darwin-amd64.tar.gz darwin-amd64.tar.gz.sha256 darwin-amd64.tar.gz.sha256sum darwin-arm64.tar.gz darwin-arm64.tar.gz.sha256 darwin-arm64.tar.gz.sha256sum linux-amd64.tar.gz linux-amd64.tar.gz.sha256 linux-amd64.tar.gz.sha256sum linux-386.tar.gz linux-386.tar.gz.sha256 linux-386.tar.gz.sha256sum linux-arm.tar.gz linux-arm.tar.gz.sha256 linux-arm.tar.gz.sha256sum linux-arm64.tar.gz linux-arm64.tar.gz.sha256 linux-arm64.tar.gz.sha256sum linux-ppc64le.tar.gz linux-ppc64le.tar.gz.sha256 linux-ppc64le.tar.gz.sha256sum linux-s390x.tar.gz linux-s390x.tar.gz.sha256 linux-s390x.tar.gz.sha256sum linux-riscv64.tar.gz linux-riscv64.tar.gz.sha256 linux-riscv64.tar.gz.sha256sum windows-amd64.zip windows-amd64.zip.sha256 windows-amd64.zip.sha256sum windows-arm64.zip windows-arm64.zip.sha256 windows-arm64.zip.sha256sum BINNAME ?= helm GOBIN = $(shell go env GOBIN) ifeq ($(GOBIN),) GOBIN = $(shell go env GOPATH)/bin endif -GOX = $(GOBIN)/gox GOIMPORTS = $(GOBIN)/goimports ARCH = $(shell go env GOARCH) @@ -131,8 +128,7 @@ test-source-headers: @scripts/validate-license.sh .PHONY: test-acceptance -test-acceptance: TARGETS = linux/amd64 -test-acceptance: build build-cross +test-acceptance: build build-linux-amd64 @if [ -d "${ACCEPTANCE_DIR}" ]; then \ cd ${ACCEPTANCE_DIR} && \ ROBOT_RUN_TESTS=$(ACCEPTANCE_RUN_TESTS) ROBOT_HELM_PATH='$(BINDIR)' make acceptance; \ @@ -167,9 +163,6 @@ gen-test-golden: test-unit # dependencies to the go.mod file. To avoid that we change to a directory # without a go.mod file when downloading the following dependencies -$(GOX): - (cd /; go install github.com/mitchellh/gox@v1.0.2-0.20220701044238-9f712387e2d2) - $(GOIMPORTS): (cd /; go install golang.org/x/tools/cmd/goimports@latest) @@ -177,9 +170,13 @@ $(GOIMPORTS): # release .PHONY: build-cross -build-cross: LDFLAGS += -extldflags "-static" -build-cross: $(GOX) - GOFLAGS="-trimpath" CGO_ENABLED=0 $(GOX) -parallel=3 -output="_dist/{{.OS}}-{{.Arch}}/$(BINNAME)" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/helm +build-cross: + @echo "==> Building cross-platform binaries using GoReleaser" + goreleaser build --clean --skip-validate --single-target + +.PHONY: build-linux-amd64 +build-linux-amd64: + GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(GOFLAGS) -trimpath -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o '$(BINDIR)/$(BINNAME)' ./cmd/helm .PHONY: dist dist: