Skip to content

Commit

Permalink
implement workflows for automatic releases (#22)
Browse files Browse the repository at this point in the history
* implement workflows for automatic releases

Signed-off-by: Lukas Hauser <[email protected]>

* remove outdated docs

Signed-off-by: Lukas Hauser <[email protected]>

---------

Signed-off-by: Lukas Hauser <[email protected]>
  • Loading branch information
luka5 authored Jan 12, 2024
1 parent 24ba81f commit 68866ff
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 17 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/prepare-new-version.yml
Original file line number Diff line number Diff line change
@@ -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 }}
26 changes: 26 additions & 0 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
15 changes: 0 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down Expand Up @@ -62,6 +49,4 @@ c := Config{
cs := NewClientSet(c)

cs.V2() // v2 client
cs.Legacy() // legacy client
cs.Assist() // assist client
```

0 comments on commit 68866ff

Please sign in to comment.