From 44528fed21d2af49ce3d480fdb05fb8f6931dacc Mon Sep 17 00:00:00 2001 From: Byron Seto Date: Fri, 15 Aug 2025 14:52:10 -0600 Subject: [PATCH 1/3] creates artifact delete, upload and tags --- .github/workflows/artifact-delete.yml | 15 ++++++++ .github/workflows/artifact-upload.yml | 40 +++++++++++++++++++ .github/workflows/tags.yml | 55 +++++++++++++++++++++++++++ .gitignore | 2 + Makefile | 18 +++++++-- 5 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/artifact-delete.yml create mode 100644 .github/workflows/artifact-upload.yml create mode 100644 .github/workflows/tags.yml diff --git a/.github/workflows/artifact-delete.yml b/.github/workflows/artifact-delete.yml new file mode 100644 index 00000000..94ea28d4 --- /dev/null +++ b/.github/workflows/artifact-delete.yml @@ -0,0 +1,15 @@ +name: artifact-delete +on: + pull_request: + types: [closed] + +permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout + +jobs: + artifact-delete: + uses: StackAdapt/actions/.github/workflows/stargate-delete.yml@main + with: + component: kvrocks-controller + branch: ${{ github.head_ref }} diff --git a/.github/workflows/artifact-upload.yml b/.github/workflows/artifact-upload.yml new file mode 100644 index 00000000..83c0b95b --- /dev/null +++ b/.github/workflows/artifact-upload.yml @@ -0,0 +1,40 @@ +name: artifact-upload +on: + pull_request: + types: [opened, synchronize] +permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout +jobs: + artifact-upload-server: + if: "!contains(github.event.pull_request.labels.*.name, 'skip-kvrocks-controller-upload')" + strategy: # If you only need 1 architecture, remove this matrix strategy and directly pass in the architecture + matrix: + architecture: [amd64, arm64] + uses: StackAdapt/actions/.github/workflows/stargate-upload.yml@main + with: + component: kvrocks-controller + binary-name: kvctl-server + branch: ${{ github.head_ref }} + commit: ${{ github.event.pull_request.head.sha }} + architecture: ${{ matrix.architecture }} + make-command: server + output-dir: cmd/server + secrets: + action-token: ${{ secrets.GO_PRIVATE_MODULES }} + artifact-upload-client: + if: "!contains(github.event.pull_request.labels.*.name, 'skip-kvrocks-controller-upload')" + strategy: # If you only need 1 architecture, remove this matrix strategy and directly pass in the architecture + matrix: + architecture: [amd64, arm64] + uses: StackAdapt/actions/.github/workflows/stargate-upload.yml@main + with: + component: kvrocks-controller + binary-name: kvctl + branch: ${{ github.head_ref }} + commit: ${{ github.event.pull_request.head.sha }} + architecture: ${{ matrix.architecture }} + make-command: client + output-dir: cmd/client + secrets: + action-token: ${{ secrets.GO_PRIVATE_MODULES }} diff --git a/.github/workflows/tags.yml b/.github/workflows/tags.yml new file mode 100644 index 00000000..da50f570 --- /dev/null +++ b/.github/workflows/tags.yml @@ -0,0 +1,55 @@ +name: tags +on: + push: + branches: + - main + +permissions: + contents: write + id-token: write # This is required for requesting the JWT + +jobs: + tag: + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.tag_version.outputs.new_tag }} + steps: + - uses: actions/checkout@v3 + - name: Bump version and push tag + id: tag_version + uses: StackAdapt/github-tag-action@v6.1 + with: + release_branches: main + github_token: ${{ secrets.GITHUB_TOKEN }} + + artifact-upload-server: + needs: [tag] + strategy: # If you only need 1 architecture, remove this matrix strategy and directly pass in the architecture + matrix: + architecture: [amd64, arm64] + uses: StackAdapt/actions/.github/workflows/stargate-upload.yml@main + with: + component: kvrocks-controller + binary-name: kvctl-server + tag: ${{ needs.tag.outputs.tag }} + architecture: ${{ matrix.architecture }} + output-dir: cmd/server + make-command: server + secrets: + action-token: ${{ secrets.GO_PRIVATE_MODULES }} + + artifact-upload-client: + needs: [tag] + strategy: # If you only need 1 architecture, remove this matrix strategy and directly pass in the architecture + matrix: + architecture: [amd64, arm64] + uses: StackAdapt/actions/.github/workflows/stargate-upload.yml@main + with: + component: kvrocks-controller + binary-name: kvctl + tag: ${{ needs.tag.outputs.tag }} + architecture: ${{ matrix.architecture }} + output-dir: cmd/client + make-command: client + secrets: + action-token: ${{ secrets.GO_PRIVATE_MODULES }} diff --git a/.gitignore b/.gitignore index cbdc5ea8..91d89795 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,5 @@ cmd/server/kvrocks_controller .kc_cli_history .vscode/ vendor +cmd/client/kvctl +cmd/server/kvctl-server diff --git a/Makefile b/Makefile index ac15bee7..cf1b4b09 100644 --- a/Makefile +++ b/Makefile @@ -21,11 +21,16 @@ CCCOLOR="\033[37;1m" MAKECOLOR="\033[32;1m" ENDCOLOR="\033[0m" +GOARCH ?= $(shell go env GOARCH) +GOOS ?= $(shell go env GOOS) +VERSION =`cat ../../VERSION.txt` +GO_PROJECT =github.com/stackadapt/kvrocks-controller +LDFLAGS := $(LDFLAGS) -X main.commit=$(GIT_COMMIT)${GIT_DIRTY} -X main.branch=$(GIT_BRANCH) -X main.date=$(DATE) -X $(GO_PROJECT)/version.Version=$(VERSION) + all: $(PROGRAM) .PHONY: all - $(PROGRAM): @bash scripts/build.sh @echo "" @@ -43,6 +48,13 @@ test: @scripts/run-test.sh @cd scripts && sh teardown.sh && cd .. -lint: - @printf $(CCCOLOR)"GolangCI Lint...\n"$(ENDCOLOR) +lint: @printf $(CCCOLOR)"GolangCI Lint...\n"$(ENDCOLOR) @golangci-lint run + +.PHONY: client +client: + cd cmd/client; CGO_ENABLED=0 GOARCH=$(GOARCH) GOOS=$(GOOS) go build -v -ldflags "$(LDFLAGS)" -o ./kvctl + +.PHONY: server +server: + cd cmd/server; CGO_ENABLED=0 GOARCH=$(GOARCH) GOOS=$(GOOS) go build -v -ldflags "$(LDFLAGS)" -o ./kvctl-server From f9aa40a2881352c54242cc412c3daba9a5209763 Mon Sep 17 00:00:00 2001 From: Byron Seto Date: Fri, 15 Aug 2025 14:56:32 -0600 Subject: [PATCH 2/3] adds license headers --- .github/workflows/artifact-delete.yml | 16 ++++++++++++++++ .github/workflows/artifact-upload.yml | 16 ++++++++++++++++ .github/workflows/tags.yml | 16 ++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/.github/workflows/artifact-delete.yml b/.github/workflows/artifact-delete.yml index 94ea28d4..356bac04 100644 --- a/.github/workflows/artifact-delete.yml +++ b/.github/workflows/artifact-delete.yml @@ -1,3 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. name: artifact-delete on: pull_request: diff --git a/.github/workflows/artifact-upload.yml b/.github/workflows/artifact-upload.yml index 83c0b95b..384fc079 100644 --- a/.github/workflows/artifact-upload.yml +++ b/.github/workflows/artifact-upload.yml @@ -1,3 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. name: artifact-upload on: pull_request: diff --git a/.github/workflows/tags.yml b/.github/workflows/tags.yml index da50f570..495ded9a 100644 --- a/.github/workflows/tags.yml +++ b/.github/workflows/tags.yml @@ -1,3 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. name: tags on: push: From 086cc6615ae3988bf17427fd9f17c800fead8b19 Mon Sep 17 00:00:00 2001 From: Byron Seto Date: Fri, 15 Aug 2025 15:42:58 -0600 Subject: [PATCH 3/3] moved the lint line by accident --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cf1b4b09..98bcf014 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,8 @@ test: @scripts/run-test.sh @cd scripts && sh teardown.sh && cd .. -lint: @printf $(CCCOLOR)"GolangCI Lint...\n"$(ENDCOLOR) +lint: + @printf $(CCCOLOR)"GolangCI Lint...\n"$(ENDCOLOR) @golangci-lint run .PHONY: client