diff --git a/.github/workflows/prepare-new-version.yml b/.github/workflows/prepare-new-version.yml new file mode 100644 index 0000000..16f82a0 --- /dev/null +++ b/.github/workflows/prepare-new-version.yml @@ -0,0 +1,43 @@ +name: Prepare new Release +run-name: ${{ github.actor }} is preparing a new Release 🚀 +on: + workflow_dispatch: + inputs: + version: + description: Define Harbor Version + +jobs: + prepare_new_release: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + - name: Prepare Repository + run: | + git fetch + git switch release-version-${{ github.event.inputs.version }} || git switch -c release-version-${{ github.event.inputs.version }} + git config user.name ${{ github.actor }} + git config user.email '${{ github.actor }}@users.noreply.github.com' + - name: Update Version + run: | + sed -E "s/v[0-9]+\.[0-9]+\.[0-9]+/v${{ github.event.inputs.version }}/g" -i README.md + sed -E "s/(VERSION := )v[0-9]+\.[0-9]+\.[0-9]+/\1v${{ github.event.inputs.version }}/g" -i Makefile + make gen-harbor-api + - name: Commit and Push Changes + run: | + git add -A + git commit -m "Release Version ${{ github.event.inputs.version }}" || echo "Nothing to commit" + git push origin release-version-${{ github.event.inputs.version }} + - name: Create Pull Request + run: | + if gh pr view release-version-${{ github.event.inputs.version }}; then + echo "Pull request release-version-${{ github.event.inputs.version }} already exists" + exit 0 + else + echo "Creating Pull request release-version-${{ github.event.inputs.version }}" + gh pr create -B main -H release-version-${{ github.event.inputs.version }} --title 'Release Version ${{ github.event.inputs.version }}' --body 'Created by Github action' + fi + env: + GITHUB_TOKEN: ${{ github.token }} diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml new file mode 100644 index 0000000..71d4121 --- /dev/null +++ b/.github/workflows/tag-release.yml @@ -0,0 +1,26 @@ +name: Release new Version Tag +run-name: ${{ github.actor }} is tagging a new Release 🚀 +on: + push: + branches: + - main + +jobs: + release_version: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - name: create tag + run: | + version=$(make get-go-version) + if gh release view ${version} &> /dev/null; then + echo "Release ${version} already exists" + exit 0 + else + echo "Creating Release ${version}" + gh release create "${version}" + fi + env: + GITHUB_TOKEN: ${{ github.token }} diff --git a/Makefile b/Makefile index cee17fa..a2e1953 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ SHELL := /usr/bin/env bash DOCKERCMD=$(shell which docker) SWAGGER_VERSION=v0.30.3 -SWAGGER := $(DOCKERCMD) run --rm -it -v $(HOME):$(HOME) -w $(shell pwd) quay.io/goswagger/swagger:$(SWAGGER_VERSION) +SWAGGER := $(DOCKERCMD) run --rm -t -u "$(shell id -u):$(shell id -g)" -v $(shell pwd):/src -w /src quay.io/goswagger/swagger:$(SWAGGER_VERSION) ifeq ($(VERSION),) VERSION := v2.8.2 @@ -34,8 +34,15 @@ update-spec: ## update all swagger spec files gen-harbor-api: update-spec ## generate goswagger client for harbor @$(SWAGGER) generate client -f ${HARBOR_2.0_SPEC} --target=$(HARBOR_CLIENT_2.0_DIR) --template=stratoscale --additional-initialism=CVE --additional-initialism=GC --additional-initialism=OIDC +.PHONY: cleanup +cleanup: + rm --recursive --force pkg/sdk/v2.0/models pkg/sdk/v2.0/client + .PHONY: test test: ## run the test go test ./... -all: gen-harbor-api +get-go-version: + @echo "$(VERSION)" | sed -E "s/v([0-9]+)\.([0-9]+)\.([0-9]+)/v0.\1\2.\3/g" - + +all: cleanup gen-harbor-api diff --git a/README.md b/README.md index 25ae0aa..7b9a272 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,6 @@ # go-client Client library with golang for accessing Harbor API. -## Client Types - -There are 3 swagger files in this repo. - -```sh -api/ - v2.0/ - legacy_swagger.yaml # legacy client - swagger.yaml # v2 client - swagger.yaml # assist client contains version and chart healthcheck - -``` - ## Download swagger spec by version Currently, the default Harbor version is `v2.8.2`. @@ -62,6 +49,4 @@ c := Config{ cs := NewClientSet(c) cs.V2() // v2 client -cs.Legacy() // legacy client -cs.Assist() // assist client ```