From 0192ac7deac7f8671b906102faedcdde4d259bf6 Mon Sep 17 00:00:00 2001 From: sapcc-bot Date: Wed, 11 Oct 2023 14:23:58 +0000 Subject: [PATCH] Run go-makefile-maker --- .github/workflows/goreleaser.yaml | 38 +++++++++++++++++++++++++++++++ .goreleaser.yaml | 38 +++++++++++++++++++++++++++++++ Makefile | 14 ++++++------ 3 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/goreleaser.yaml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/goreleaser.yaml b/.github/workflows/goreleaser.yaml new file mode 100644 index 00000000..8fd39d39 --- /dev/null +++ b/.github/workflows/goreleaser.yaml @@ -0,0 +1,38 @@ +################################################################################ +# This file is AUTOGENERATED with # +# Edit Makefile.maker.yaml instead. # +################################################################################ + +name: goreleaser +"on": + push: + tags: + - v[0-9]+.[0-9]+.[0-9]+ +permissions: + contents: read + packages: write +jobs: + release: + name: goreleaser + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v4 + with: + check-latest: true + go-version: "1.21" + - name: Generate release info + run: | + go install github.com/sapcc/go-bits/tools/release-info@latest + release-info CHANGELOG.md $(shell git describe --tags --abbrev=0) > build/release-info + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + args: release --clean --release-notes=./build/release-info + version: latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 00000000..6987df5c --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,38 @@ +before: + hooks: + - go mod tidy + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + ldflags: + - -s -w + - -X github.com/sapcc/go-api-declarations/bininfo.binName=absent-metrics-operator + - -X github.com/sapcc/go-api-declarations/bininfo.version={{ .Version }} + - -X github.com/sapcc/go-api-declarations/bininfo.commit={{ .FullCommit }} + - -X github.com/sapcc/go-api-declarations/bininfo.buildDate={{ .CommitDate }} # use CommitDate instead of Date for reproducibility + # Set the modified timestamp on the output binary to ensure that builds are reproducible. + mod_timestamp: "{{ .CommitTimestamp }}" + +snapshot: + name_template: "{{ .Tag }}-next" + +checksum: + name_template: "checksums.txt" + +archives: + - name_template: '{{ .ProjectName }}-{{ replace .Version "v" "" }}-{{ .Os }}-{{ .Arch }}' + format_overrides: + - goos: windows + format: zip + files: + - CHANGELOG.md + - LICENSE + - README.md diff --git a/Makefile b/Makefile index ba80aab4..00b4fef1 100644 --- a/Makefile +++ b/Makefile @@ -14,15 +14,15 @@ endif default: build-all -ENVTEST_VERSION := "1.23.x!" -prepare-envtest-binaries: +# Attach `make prepare-envtest-binaries` as a dependency to the autogenerated `make build/cover.out`. +build/cover.out: prepare-envtest-binaries + +ENVTEST_VERSION := "1.26.x!" +prepare-envtest-binaries: FORCE + printf "\e[1;36m>> Preparing envtest binaries...\e[0m\n" @if ! hash setup-envtest 2>/dev/null; then printf "\e[1;36m>> Installing setup-envtest...\e[0m\n"; go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest; fi @mkdir -p test/bin - setup-envtest --arch=amd64 --bin-dir test/bin use $(ENVTEST_VERSION) - -build/release-info: CHANGELOG.md | build - @if ! hash release-info 2>/dev/null; then printf "\e[1;36m>> Installing release-info...\e[0m\n"; go install github.com/sapcc/go-bits/tools/release-info@latest; fi - release-info $< $(shell git describe --tags --abbrev=0) > $@ + setup-envtest --bin-dir test/bin use $(ENVTEST_VERSION) GO_BUILDFLAGS = GO_LDFLAGS =