From 548920828e8dec210026309864730c1c3ecfcdeb Mon Sep 17 00:00:00 2001 From: Serge Logvinov Date: Sat, 17 Feb 2024 22:43:37 +0200 Subject: [PATCH] refactor: rename cli tool Rename tool and brew release support. Signed-off-by: Serge Logvinov --- .github/workflows/build-test.yaml | 2 +- .github/workflows/release.yaml | 35 +++++++++ .gitignore | 1 + .goreleaser.yml | 80 +++++++++++++-------- Dockerfile | 12 ++-- Makefile | 12 ++-- cmd/{pvecsi-mutate => pvecsictl}/main.go | 2 +- cmd/{pvecsi-mutate => pvecsictl}/migrate.go | 0 cmd/{pvecsi-mutate => pvecsictl}/rename.go | 0 cmd/{pvecsi-mutate => pvecsictl}/utils.go | 0 10 files changed, 102 insertions(+), 42 deletions(-) rename cmd/{pvecsi-mutate => pvecsictl}/main.go (98%) rename cmd/{pvecsi-mutate => pvecsictl}/migrate.go (100%) rename cmd/{pvecsi-mutate => pvecsictl}/rename.go (100%) rename cmd/{pvecsi-mutate => pvecsictl}/utils.go (100%) diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index 9a3c2fa..b90cb8d 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -30,7 +30,7 @@ jobs: go-version-file: 'go.mod' - name: Lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v4 with: version: v1.55.2 args: --config=.golangci.yml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c51a580..eeb3b64 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -40,3 +40,38 @@ jobs: - name: Sign images timeout-minutes: 4 run: make images-cosign + + build-publish-cli: + name: "Publish cli tool" + timeout-minutes: 15 + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Unshallow + run: git fetch --prune --unshallow + + - name: Set up go + timeout-minutes: 5 + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: Generate token + uses: actions/create-github-app-token@f4c6bf6752984b3a29fcc135a5e70eb792c40c6b # v1.8.0 + id: token + with: + app-id: "${{ secrets.BOT_APP_ID }}" + private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" + owner: "${{ github.repository_owner }}" + repositories: homebrew-pvecsictl + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HOMEBREW_PAT: ${{ steps.token.outputs.token }} diff --git a/.gitignore b/.gitignore index c9e5fdd..f27f7b4 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ go.work /charts/proxmox-csi-plugin/values.*.yaml /hack/cloud-config.yaml /hack/kubeconfig +/hack/kubeconfig* kubeconfig .cache/ /log diff --git a/.goreleaser.yml b/.goreleaser.yml index 2534b64..86a0188 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,14 +1,13 @@ -project_name: pvecsi-mutate +project_name: pvecsictl before: hooks: - go mod download - - make release-update dist: bin builds: - - dir: cmd/pvecsi-mutate - binary: pvecsi-mutate-{{ .Os }}-{{ .Arch }} + - dir: cmd/pvecsictl + binary: pvecsictl-{{ .Os }}-{{ .Arch }} no_unique_dist_dir: true env: - CGO_ENABLED=0 @@ -19,33 +18,58 @@ builds: - amd64 - arm64 +archives: + - format: binary + name_template: "{{ .Binary }}" + checksum: name_template: "checksums.txt" snapshot: name_template: edge -dockers: - - use: buildx - image_templates: - - ghcr.io/sergelogvinov/pvecsi-mutate:{{ .Version }}-amd64 - goos: linux - goarch: amd64 - build_flag_templates: - - "--label=org.opencontainers.image.version={{.Version}}" - - "--target=pvecsi-mutate-goreleaser" - - "--platform=linux/amd64" - - use: buildx - image_templates: - - ghcr.io/sergelogvinov/pvecsi-mutate:{{ .Version }}-arm64 - goos: linux - goarch: arm64 - build_flag_templates: - - "--label=org.opencontainers.image.version={{.Version}}" - - "--target=pvecsi-mutate-goreleaser" - - "--platform=linux/arm64" -docker_manifests: - - name_template: ghcr.io/sergelogvinov/{{ .ProjectName }}:{{ .Version }} - image_templates: - - ghcr.io/sergelogvinov/{{ .ProjectName }}:{{ .Version }}-amd64 - - ghcr.io/sergelogvinov/{{ .ProjectName }}:{{ .Version }}-arm64 +# dockers: +# - use: buildx +# image_templates: +# - ghcr.io/sergelogvinov/pvecsictl:{{ .Version }}-amd64 +# goos: linux +# goarch: amd64 +# build_flag_templates: +# - "--label=org.opencontainers.image.version={{.Version}}" +# - "--target=pvecsictl-goreleaser" +# - "--platform=linux/amd64" +# - use: buildx +# image_templates: +# - ghcr.io/sergelogvinov/pvecsictl:{{ .Version }}-arm64 +# goos: linux +# goarch: arm64 +# build_flag_templates: +# - "--label=org.opencontainers.image.version={{.Version}}" +# - "--target=pvecsictl-goreleaser" +# - "--platform=linux/arm64" +# docker_manifests: +# - name_template: ghcr.io/sergelogvinov/{{ .ProjectName }}:{{ .Version }} +# image_templates: +# - ghcr.io/sergelogvinov/{{ .ProjectName }}:{{ .Version }}-amd64 +# - ghcr.io/sergelogvinov/{{ .ProjectName }}:{{ .Version }}-arm64 + +brews: + - name: pvecsictl + folder: Formula + homepage: https://github.com/sergelogvinov/proxmox-csi-plugin + description: "Proxmox VE CSI Mutate tool" + license: Apache-2.0 + + commit_author: + name: sergelogvinov + email: 5407715+sergelogvinov@users.noreply.github.com + repository: + owner: sergelogvinov + name: homebrew-pvecsictl + branch: main + token: "{{ .Env.HOMEBREW_PAT }}" + + test: | + system "#{bin}/pvecsictl -v" + install: | + bin.install "{{ .Binary }}" => "pvecsictl" diff --git a/Dockerfile b/Dockerfile index 7ae51ac..dc61e9c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -80,24 +80,24 @@ ENTRYPOINT ["/bin/proxmox-csi-node"] ######################################## -FROM alpine:3.18 AS pvecsi-mutate +FROM alpine:3.19 AS pvecsictl LABEL org.opencontainers.image.source="https://github.com/sergelogvinov/proxmox-csi-plugin" \ org.opencontainers.image.licenses="Apache-2.0" \ org.opencontainers.image.description="Proxmox VE CSI tools" ARG TARGETARCH -COPY --from=builder /src/bin/pvecsi-mutate-${TARGETARCH} /bin/pvecsi-mutate +COPY --from=builder /src/bin/pvecsictl-${TARGETARCH} /bin/pvecsictl -ENTRYPOINT ["/bin/pvecsi-mutate"] +ENTRYPOINT ["/bin/pvecsictl"] ######################################## -FROM alpine:3.18 AS pvecsi-mutate-goreleaser +FROM alpine:3.19 AS pvecsictl-goreleaser LABEL org.opencontainers.image.source="https://github.com/sergelogvinov/proxmox-csi-plugin" \ org.opencontainers.image.licenses="Apache-2.0" \ org.opencontainers.image.description="Proxmox VE CSI tools" ARG TARGETARCH -COPY pvecsi-mutate-linux-${TARGETARCH} /bin/pvecsi-mutate +COPY pvecsictl-linux-${TARGETARCH} /bin/pvecsictl -ENTRYPOINT ["/bin/pvecsi-mutate"] +ENTRYPOINT ["/bin/pvecsictl"] diff --git a/Makefile b/Makefile index 63e12a4..44ae28d 100644 --- a/Makefile +++ b/Makefile @@ -56,16 +56,16 @@ build-all-archs: clean: ## Clean rm -rf bin .cache -build-pvecsi-mutate: +build-pvecsictl: CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build $(GO_LDFLAGS) \ - -o bin/pvecsi-mutate-$(ARCH) ./cmd/pvecsi-mutate + -o bin/pvecsictl-$(ARCH) ./cmd/pvecsictl build-%: CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build $(GO_LDFLAGS) \ -o bin/proxmox-csi-$*-$(ARCH) ./cmd/$* .PHONY: build -build: build-controller build-node build-pvecsi-mutate ## Build +build: build-controller build-node build-pvecsictl ## Build .PHONY: run run: build-controller ## Run @@ -144,13 +144,13 @@ image-%: images-checks: images image-tools-check trivy image --exit-code 1 --ignore-unfixed --severity HIGH,CRITICAL --no-progress $(OCIREPO)/proxmox-csi-controller:$(TAG) trivy image --exit-code 1 --ignore-unfixed --severity HIGH,CRITICAL --no-progress $(OCIREPO)/proxmox-csi-node:$(TAG) - trivy image --exit-code 1 --ignore-unfixed --severity HIGH,CRITICAL --no-progress $(OCIREPO)/pvecsi-mutate:$(TAG) + trivy image --exit-code 1 --ignore-unfixed --severity HIGH,CRITICAL --no-progress $(OCIREPO)/pvecsictl:$(TAG) .PHONY: images-cosign images-cosign: @cosign sign --yes $(COSING_ARGS) --recursive $(OCIREPO)/proxmox-csi-controller:$(TAG) @cosign sign --yes $(COSING_ARGS) --recursive $(OCIREPO)/proxmox-csi-node:$(TAG) - @cosign sign --yes $(COSING_ARGS) --recursive $(OCIREPO)/pvecsi-mutate:$(TAG) + @cosign sign --yes $(COSING_ARGS) --recursive $(OCIREPO)/pvecsictl:$(TAG) .PHONY: images -images: image-proxmox-csi-controller image-proxmox-csi-node image-pvecsi-mutate ## Build images +images: image-proxmox-csi-controller image-proxmox-csi-node image-pvecsictl ## Build images diff --git a/cmd/pvecsi-mutate/main.go b/cmd/pvecsictl/main.go similarity index 98% rename from cmd/pvecsi-mutate/main.go rename to cmd/pvecsictl/main.go index 5fd8376..764bdac 100644 --- a/cmd/pvecsi-mutate/main.go +++ b/cmd/pvecsictl/main.go @@ -30,7 +30,7 @@ import ( ) var ( - command = "pvecsi-mutate" + command = "pvecsictl" version = "v0.0.0" commit = "none" diff --git a/cmd/pvecsi-mutate/migrate.go b/cmd/pvecsictl/migrate.go similarity index 100% rename from cmd/pvecsi-mutate/migrate.go rename to cmd/pvecsictl/migrate.go diff --git a/cmd/pvecsi-mutate/rename.go b/cmd/pvecsictl/rename.go similarity index 100% rename from cmd/pvecsi-mutate/rename.go rename to cmd/pvecsictl/rename.go diff --git a/cmd/pvecsi-mutate/utils.go b/cmd/pvecsictl/utils.go similarity index 100% rename from cmd/pvecsi-mutate/utils.go rename to cmd/pvecsictl/utils.go