diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..c23b726 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,32 @@ +on: + release: + types: [ created ] + +permissions: + contents: write + packages: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Fetch all tags + run: git fetch --force --tags + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.22.3 + cache: true + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: ${{ env.GITHUB_REF_NAME }} + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} diff --git a/.gitignore b/.gitignore index 7a4fd86..ef66526 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,5 @@ # Go workspace file go.work go.work.sum -bin/ \ No newline at end of file +bin/ +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..cef706d --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,59 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 1 + +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + # you may remove this if you don't need go generate + - go generate ./... + +builds: + - env: + - CGO_ENABLED=0 + main: ./kubectl-duplicate/kubectl-duplicate.go + goos: + - linux + - windows + - darwin + +brews: + - name: duplik8s + description: kubectl plugin to duplicate resources in a Kubernetes cluster. + homepage: https://github.com/Telemaco019/duplik8s + tap: + owner: Telemaco019 + name: homebrew-duplik8s + commit_author: + name: Telemaco019 + email: m.zanotti019@gmail.com + folder: Formula + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/Makefile b/Makefile index d684b80..5da2a41 100644 --- a/Makefile +++ b/Makefile @@ -75,17 +75,24 @@ $(LOCALBIN): ## Tool Binaries GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint +GORELEASER ?= $(LOCALBIN)/goreleaser LICENSE_EYE ?= $(LOCALBIN)/license-eye VHS ?= $(LOCALBIN)/vhs ## Tool Versions GOLANGCI_LINT_VERSION ?= 1.50.1 +GORELEASER_VERSION ?= 1.26.1 .PHONY: golangci-lint ## Download golanci-lint if necessary golangci-lint: $(GOLANGCI_LINT) $(GOLANGCI_LINT): $(LOCALBIN) test -s $(LOCALBIN)/golanci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v${GOLANGCI_LINT_VERSION} +.PHONY: goreleaser ## Download goreleaser if necessary +goreleaser: $(GORELEASER) +$(GORELEASER): $(LOCALBIN) + test -s $(LOCALBIN)/goreleaser || GOBIN=$(LOCALBIN) go install github.com/goreleaser/goreleaser@v${GORELEASER_VERSION} + .PHONY: license-eye ## Download license-eye if necessary license-eye: $(LICENSE_EYE) $(LICENSE_EYE): $(LOCALBIN) diff --git a/README.md b/README.md index 71db26b..e656381 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # Duplik8s -🚧 Work in progress! - --- **Duplicate** 🔁 kubectl plugin to duplicate resources in a Kubernetes cluster.