Skip to content

Commit

Permalink
workflow: Add a release workflow (openclarity#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrimIdan authored Sep 19, 2021
1 parent b8b8a68 commit 964d3a8
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 21 deletions.
18 changes: 1 addition & 17 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ on:
push:
branches:
- master
tags:
- "v[0-9]+.[0-9]+.[0-9]+"

jobs:
docker:
Expand All @@ -27,20 +25,6 @@ jobs:
restore-keys: |
${{ runner.os }}-buildx-
- name: Determine tag or commit
uses: haya14busa/action-cond@v1
id: refortag
with:
cond: ${{ startsWith(github.ref, 'refs/tags/') }}
if_true: ${{ github.ref }}
if_false: latest

- name: Determine image tag
id: imagetag
run: echo "::set-output name=value::${TAG_OR_BRANCH##*/}"
env:
TAG_OR_BRANCH: ${{ steps.refortag.outputs.value }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
Expand All @@ -52,7 +36,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
tags: ghcr.io/apiclarity/apiclarity:${{ steps.imagetag.outputs.value }}
tags: ghcr.io/apiclarity/apiclarity:latest
file: Dockerfile
push: true
cache-from: type=local,src=/tmp/.buildx-cache
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: Version
required: true

env:
GO_VERSION: 1.16

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: Check licenses
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make license-check

- name: Run verification
run: make check

- name: Tag validation
run: |
tag='${{ github.event.inputs.version }}'
[[ $tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit 1
- name: Tag
run: |
tag='${{ github.event.inputs.version }}'
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
sed -i 's/image: ghcr.io\/apiclarity\/apiclarity:latest/image: ghcr.io\/apiclarity\/apiclarity:'"$tag"'/g' deployment/apiclarity.yaml
git commit deployment/apiclarity.yaml -m "update tag in deployment yaml"
git tag --annotate --message "Tag for release $tag" "$tag"
git push origin "refs/tags/$tag"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.ref }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push APIClarity
uses: docker/build-push-action@v2
with:
context: .
tags: ghcr.io/apiclarity/apiclarity:${{ github.event.inputs.version }}
file: Dockerfile
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: v0.178.0
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ db.db
backend/bin/*
/bin/*
*.gob
goreleaser_artifacts/
46 changes: 46 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
before:
hooks:
- git submodule init wasm-filters
- git submodule update wasm-filters

builds:
-
dir: backend
main: ./cmd/backend
binary: backend
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64

archives:
-
name_template: "{{ .ProjectName }}_{{ .Version }}"

# Additional files/template/globs we want to add to the archive.
files:
- LICENSE
- README.md
- wasm-filters/deploy.sh
- wasm-filters/envoyFilter.yaml
- wasm-filters/bin/release/http-trace-filter.wasm
- deployment/apiclarity.yaml

checksum:
name_template: 'checksums.txt'

# Change the default artifacts folder
dist: goreleaser_artifacts

snapshot:
name_template: "{{ incpatch .Version }}-next"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- '^workflow:'
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ make backend
```

# Installation in a K8s cluster
1. Make sure that Istio is installed and running in your cluster: ([Official installation instructions](https://istio.io/latest/docs/setup/getting-started/#install)).
1. Make sure Istio is installed and running in your cluster: ([Official installation instructions](https://istio.io/latest/docs/setup/getting-started/#install)).


2. Deploy APIClarity in K8s (will be deployed in a new namespace named apiclarity):
2. Deploy APIClarity in K8s (will be deployed in a new namespace named `apiclarity`):
```
kubectl apply -f deployment/apiclarity.yaml
```
3. Check that APIClarity is running:
3. Check APIClarity is running:
```
kubectl get pods -n apiclarity
NAME READY STATUS RESTARTS AGE
Expand Down
2 changes: 1 addition & 1 deletion deployment/apiclarity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ spec:
serviceAccountName: apiclarity
containers:
- name: apiclarity
image: ghcr.io/apiclarity/apiclarity
image: ghcr.io/apiclarity/apiclarity:latest
args:
- run
env:
Expand Down

0 comments on commit 964d3a8

Please sign in to comment.