Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce release process #9

Merged
merged 22 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:

build-and-push-docker:
runs-on: ubuntu-latest
name: Docker images
strategy:
fail-fast: true
matrix:
from: [init, server]

steps:
- name: Extract version from tag
id: extract_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV

- name: Debug version
run: echo ${{ env.VERSION }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Docker Cache
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Checkout Repository
uses: actions/checkout@v2

- name: Build image and push to Docker Hub
uses: docker/build-push-action@v4
with:
context: ./admission-controller/${{ matrix.from }}/
file: ./admission-controller/${{ matrix.from }}/Dockerfile
tags: |
kubeshop/monokle-admission-controller-${{ matrix.from }}:latest
kubeshop/monokle-admission-controller-${{ matrix.from }}:${{ env.VERSION }}
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

build-and-push-helm:
runs-on: ubuntu-latest
name: Helm chart

steps:
- name: Extract version from tag
id: extract_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV

- name: Debug version
run: echo ${{ env.VERSION }}

- name: Login Helm to DockerHub registry
run: |
helm registry login registry-1.docker.io -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin <<< "${{ secrets.DOCKERHUB_TOKEN }}"

- name: Checkout Repository
uses: actions/checkout@v2

# See https://docs.docker.com/docker-hub/oci-artifacts/#push-a-helm-chart
- name: Build and publish Helm chart
env:
VERSION: ${{ env.VERSION }}
run: |
echo "Building Helm chart with version: ${VERSION}"
helm package ./helm --version ${VERSION}
helm push monokle-admission-controller-${VERSION}.tgz oci://registry-1.docker.io/kubeshop

create-release:
runs-on: ubuntu-latest
name: GitHub release
needs: [build-and-push-docker, build-and-push-helm]

steps:
- name: Extract version from tag
id: extract_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV

- name: Debug version
run: echo ${{ env.VERSION }}

- name: Checkout Repository
uses: actions/checkout@v2

- name: Build release artifacts
env:
VERSION: ${{ env.VERSION }}
run: |
helm package ./helm --version ${VERSION}
helm template ./helm --version ${VERSION} > install.yaml
mv monokle-admission-controller-${VERSION}.tgz helm.tgz

- name: Create release and upload artifacts
uses: ncipollo/release-action@v1
with:
name: "Release ${{ env.VERSION }}"
allowUpdates: true
artifacts: 'install.yaml,helm.tgz'
omitBody: true
token: ${{ secrets.CI_BOT_TOKEN }}
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,23 @@ kubectl apply -f examples/pod-warning.yaml
kubectl apply -f examples/pod-errors.yaml
```

## Releasing

Releasing is mostly done automatically with `Release` CI job. To trigger the release, bump project version:

```bash
./script/bump.sh A.B.C
```

This will bump init and server node packages version and helm chart versions. Commit it and create `vA.B.C` tag. Then it needs to be pushed to remote:

```bash
git push origin main
git push origin vA.B.C
```

Release job is triggered when new tag is pushed. It will build everything, push to dockerhub and create GitHub release.

## Refs

* https://kubernetes.io/blog/2019/03/21/a-guide-to-kubernetes-admission-controllers/
Expand Down
Loading