From adb01700015c1a1c573badd941956d45ccb46e3a Mon Sep 17 00:00:00 2001 From: Vyankatesh Kudtarkar Date: Tue, 10 Aug 2021 21:37:46 +0530 Subject: [PATCH] Automate CLI binaries releases (#2236) * fix issue * fix comment * fix comment * fix comment * add md file * ignore /release * fix issue --- .github/workflows/release.yaml | 51 ++++++++++++++++++++++++++++++++++ .gitignore | 3 +- .goreleaser.yml | 3 +- Makefile | 5 ++++ 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 31392679b0..c5e4767705 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -123,6 +123,57 @@ jobs: - name : docker images publish run: | make docker-publish-cli + + create-release: + runs-on: ubuntu-latest + needs: + - release-init-kyverno + - release-kyverno + - release-kyverno-cli + steps: + - name: Set version + id: version + run: echo ::set-output name=version::${GITHUB_REF#refs/*/} + + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 + + - name: Cache Go modules + uses: actions/cache@v1 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 + - uses: creekorful/goreportcard-action@v1.0 + + - name: Make Release + env: + VERSION: ${{ steps.version.outputs.version }} + run: | + rm -rf release + mkdir release + make release-notes > release/release-notes.out + cat release/release-notes.out + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist --debug --release-notes=release/release-notes.out + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} release-cli-via-krew: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 03d0c8249e..2bbdfb6a51 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ coverage.txt cmd/initContainer/kyvernopre cmd/kyverno/kyverno cmd/cli/kubectl-kyverno/kyverno -kubectl-kyverno \ No newline at end of file +kubectl-kyverno +/release diff --git a/.goreleaser.yml b/.goreleaser.yml index 463a384a5c..61e59fb9eb 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -42,9 +42,8 @@ release: changelog: sort: asc filters: - # commit messages matching the regexp listed here will be removed from - # the changelog exclude: - '^docs:' - typo + - '^test:' diff --git a/Makefile b/Makefile index cd3c17c7b5..9974f0ba25 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ GIT_HASH := $(GIT_BRANCH)/$(shell git log -1 --pretty=format:"%H") TIMESTAMP := $(shell date '+%Y-%m-%d_%I:%M:%S%p') CONTROLLER_GEN=controller-gen CONTROLLER_GEN_REQ_VERSION := v0.4.0 +VERSION ?= $(shell git describe --always --tags) REGISTRY?=ghcr.io REPO=$(REGISTRY)/kyverno @@ -220,6 +221,10 @@ release: kustomize build ./definitions > ./definitions/install.yaml kustomize build ./definitions > ./definitions/release/install.yaml +release-notes: + @bash -c 'while IFS= read -r line ; do if [[ "$$line" == "## "* && "$$line" != "## $(VERSION) "* ]]; then break ; fi; echo "$$line"; done < "CHANGELOG.md"' \ + true + kyverno-crd: controller-gen $(CONTROLLER_GEN) crd paths=./pkg/api/kyverno/v1alpha1 output:dir=./definitions/crds $(CONTROLLER_GEN) crd paths=./pkg/api/kyverno/v1 output:dir=./definitions/crds