From 74e63edb61019447fd04e2234813483496ba9f67 Mon Sep 17 00:00:00 2001 From: Dominik Giger Date: Mon, 23 Oct 2023 14:37:03 +0200 Subject: [PATCH] Fix goreleaser config. (#627) The 'replacements' parameter was removed in goreleaser. The name now has to be built directly in the file-name template. (See: https://github.com/goreleaser/goreleaser/issues/3588#issuecomment-1326457874) Also updates the branches workflow to directly create+commit to the new branch using the prebuilt GITHUB_TOKEN. This token has by default only read permissions, so write permissions are added to allow it create branches and commit. --- .github/workflows/branch.yml | 18 +++++++----------- .goreleaser.yml | 11 ++++++----- build/Makefile.build | 2 +- build/Makefile.deps | 4 ++-- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/.github/workflows/branch.yml b/.github/workflows/branch.yml index 23116c81..a14e8d2f 100644 --- a/.github/workflows/branch.yml +++ b/.github/workflows/branch.yml @@ -6,6 +6,9 @@ on: tags: - '*.*.*' +permissions: + contents: write + jobs: branch-out: name: Create a github branch @@ -31,22 +34,15 @@ jobs: go-version: "1.20" id: go - - name: Bump main version + - name: Bump patch version run: make patch - - name: Create a github branch - uses: peterjgrainger/action-create-branch@v2.4.0 - env: - GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GH_TOKEN }} - with: - branch: ${{ steps.get_branch.outputs.BRANCH }} - - - name: Commit changes to the minor branch + - name: Create new branch and commit changes to the minor branch uses: EndBug/add-and-commit@v9 with: default_author: user_info message: 'Update patch version' - branch: ${{ steps.get_branch.outputs.BRANCH }} + new_branch: ${{ steps.get_branch.outputs.BRANCH }} author_name: elasticcloudclients author_email: elasticcloudclients@elastic.co @@ -59,7 +55,7 @@ jobs: with: ref: master fetch-depth: 0 - token: ${{ secrets.GH_TOKEN_EXTRA }} + token: ${{ secrets.GITHUB_TOKEN }} - name: Set up Go uses: actions/setup-go@v4 diff --git a/.goreleaser.yml b/.goreleaser.yml index b470f55a..0a6905c0 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -23,7 +23,7 @@ builds: - arm64 ignore: - goos: darwin - goarch: 386 + goarch: "386" ldflags: -s -w -X main.version={{.Env.VERSION }} -X main.commit={{.Commit}} -X main.owner={{.Env.OWNER}} -X main.repo={{.Env.REPO}} -X main.built={{.Env.BUILT}} binary: ecctl archives: @@ -36,15 +36,16 @@ archives: snapshot: name_template: "{{ .Version }}_SNAPSHOT_{{ .ShortCommit }}" nfpms: - - file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" + - file_name_template: >- + {{ .ProjectName }}_{{ .Version }}_{{ .Os }}_ + {{- if eq .Arch "amd64" }}64-bit + {{- else if eq .Arch "386" }}32-bit + {{- else }}{{ .Arch }}{{ end }} license: Apache 2.0 maintainer: Elastic Cloud vendor: Elastic description: ecctl is the CLI for the Elasticsearch Service and Elastic Cloud Enterprise APIs. homepage: https://www.elastic.co/guide/en/ecctl/current/index.html - replacements: - amd64: 64-bit - "386": 32-bit formats: - deb - rpm diff --git a/build/Makefile.build b/build/Makefile.build index d4adaf87..4e4795fb 100644 --- a/build/Makefile.build +++ b/build/Makefile.build @@ -47,7 +47,7 @@ ifneq ($(SKIP_TAG),true) endif @ echo "-> Releasing $(BINARY) $(VERSION)..." @ okta-awscli - @ $(GOBIN)/goreleaser release --skip-validate --rm-dist --release-notes=notes/$(VERSION).md + @ $(GOBIN)/goreleaser release --skip=validate --clean --release-notes=notes/$(VERSION).md ## Generates a changelog file in notes/$(VERSION) for the next release. changelog: diff --git a/build/Makefile.deps b/build/Makefile.deps index 11fcefdd..e4d968f9 100644 --- a/build/Makefile.deps +++ b/build/Makefile.deps @@ -7,7 +7,7 @@ VERSION_DIR:=$(GOBIN)/versions VERSION_GOLICENSER:=v0.3.0 VERSION_GOLANGCILINT:=v1.54.2 VERSION_GOBINDATA:=v0.0.0-20190711162640-ee3c2418e368 -VERSION_GORELEASER:=v1.2.5 +VERSION_GORELEASER:=v1.21.2 VERSION_VERSIONBUMP:=v1.1.0 deps: $(GOBIN)/go-licenser $(GOBIN)/golangci-lint $(GOBIN)/go-bindata @@ -48,7 +48,7 @@ $(VERSION_DIR)/.version-goreleaser-$(VERSION_GORELEASER): | $(VERSION_DIR) $(GOBIN)/goreleaser: $(VERSION_DIR)/.version-goreleaser-$(VERSION_GORELEASER) | $(GOBIN) @ echo "-> Installing goreleaser..." - @ curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh| sh -s -- -b $(GOBIN) $(VERSION_GORELEASER) + @ go install github.com/goreleaser/goreleaser@$(VERSION_GORELEASER) $(VERSION_DIR)/.version-versionbump-$(VERSION_VERSIONBUMP): | $(VERSION_DIR) @ rm -f $(VERSION_DIR)/.version-versionbump-*