Skip to content

Commit fcfad64

Browse files
ci: add branch preparation and release CI changes (#567)
Signed-off-by: Abhinandan Purkait <[email protected]>
1 parent dddfa93 commit fcfad64

File tree

4 files changed

+601
-55
lines changed

4 files changed

+601
-55
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Branch Preparation
2+
3+
on:
4+
push:
5+
branches:
6+
- 'release/**'
7+
tags:
8+
- 'v[0-9]+.[0-9]+.[0-9]+**'
9+
10+
jobs:
11+
update_release_branch_after_release:
12+
runs-on: ubuntu-latest
13+
if: ${{ github.ref_type == 'tag' }}
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: cachix/install-nix-action@v22
18+
- name: Pre-populate nix-shell
19+
run: |
20+
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
21+
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
22+
nix-shell --pure --run "echo" ./shell.nix
23+
24+
- name: Test the chart version updater script
25+
run: |
26+
nix-shell --pure --run "./scripts/test-update-chart-version.sh" ./shell.nix
27+
28+
- name: Modify the chart version based on the tag
29+
run: |
30+
tag=${{ github.ref_name }}
31+
echo "BASE=$(nix-shell --pure --run "./scripts/update-chart-version.sh --tag $tag" ./shell.nix)" >> $GITHUB_ENV
32+
33+
- name: Create Pull Request to release
34+
if: ${{ env.BASE }}
35+
id: cpr
36+
uses: peter-evans/create-pull-request@v5
37+
with:
38+
base: ${{ env.BASE }}
39+
commit-message: "chore(ci): update helm chart versions and/or git submodules"
40+
committer: GitHub <[email protected]>
41+
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
42+
title: "Prepare release branch after release ${{ github.ref_name }}"
43+
labels: |
44+
update-release-branch
45+
automated-pr
46+
draft: false
47+
signoff: true
48+
branch: "create-pull-request/patch-${{ env.BASE }}"
49+
token: ${{ secrets.GITHUB_TOKEN }}
50+
51+
update_develop_branch_on_release_branch_creation:
52+
runs-on: ubuntu-latest
53+
if: ${{ github.ref_type == 'branch' }}
54+
steps:
55+
- uses: actions/checkout@v4
56+
with:
57+
fetch-depth: 0
58+
- run: |
59+
git checkout develop
60+
61+
- uses: cachix/install-nix-action@v22
62+
- name: Pre-populate nix-shell
63+
run: |
64+
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
65+
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
66+
nix-shell --pure --run "echo" ./shell.nix
67+
68+
- name: Test the chart version updater script
69+
run: |
70+
nix-shell --pure --run "./scripts/test-update-chart-version.sh" ./shell.nix
71+
72+
- name: Modify the chart version based on the branch name for develop
73+
run: |
74+
branch_name=${{ github.ref_name }}
75+
nix-shell --pure --run "./scripts/update-chart-version.sh --branch $branch_name --type develop" ./shell.nix
76+
77+
- name: Create Pull Request to develop
78+
id: cpr
79+
uses: peter-evans/create-pull-request@v5
80+
with:
81+
base: develop
82+
commit-message: "chore(ci): update helm chart versions and/or git submodules"
83+
committer: GitHub <[email protected]>
84+
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
85+
title: "Prepare develop branch on ${{ github.ref_name }} creation"
86+
labels: |
87+
update-develop-branch
88+
automated-pr
89+
draft: false
90+
signoff: true
91+
branch: "create-pull-request/patch-develop"
92+
token: ${{ secrets.GITHUB_TOKEN }}
93+
94+
prepare_release_branch_on_creation:
95+
runs-on: ubuntu-latest
96+
if: ${{ github.ref_type == 'branch' }}
97+
steps:
98+
- uses: actions/checkout@v4
99+
100+
- uses: cachix/install-nix-action@v22
101+
- name: Pre-populate nix-shell
102+
run: |
103+
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
104+
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
105+
nix-shell --pure --run "echo" ./shell.nix
106+
107+
- name: Test the chart version updater script
108+
run: |
109+
nix-shell --pure --run "./scripts/test-update-chart-version.sh" ./shell.nix
110+
111+
- name: Modify the chart version based on the branch name for release
112+
run: |
113+
branch_name=${{ github.ref_name }}
114+
nix-shell --pure --run "./scripts/update-chart-version.sh --branch $branch_name --type release" ./shell.nix
115+
116+
- name: Create Pull Request to release
117+
id: cpr
118+
uses: peter-evans/create-pull-request@v5
119+
with:
120+
base: ${{ github.ref_name }}
121+
commit-message: "chore(ci): update helm chart versions and/or git submodules"
122+
committer: GitHub <[email protected]>
123+
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
124+
title: "Prepare ${{ github.ref_name }} branch"
125+
labels: |
126+
prepare-release-branch
127+
automated-pr
128+
draft: false
129+
signoff: true
130+
branch: "create-pull-request/patch-${{ github.ref_name }}"
131+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 147 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,142 @@
1-
# Copyright 2020 The OpenEBS Authors. All rights reserved.
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
name: release
1+
name: Release Images and Charts
152

163
on:
174
release:
185
types:
196
- "created"
207

218
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- uses: cachix/install-nix-action@v22
18+
- uses: rrbutani/[email protected]
19+
with:
20+
file: shell.nix
21+
22+
- name: Check if the chart is publishable
23+
run: |
24+
TAG=${{ github.event.release.tag_name }}
25+
./scripts/update-chart-version.sh --tag $TAG --publish-release
26+
27+
- name: Run chart-testing lint
28+
run: |
29+
ct lint --config ct.yaml
30+
31+
unit-tests:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
37+
- name: Unit test
38+
run: make test
39+
40+
- name: Upload Coverage Report
41+
uses: codecov/codecov-action@v4
42+
with:
43+
token: ${{ secrets.CODECOV_TOKEN }}
44+
file: ./coverage.txt
45+
name: coverage-$(date +%s)
46+
flags: unittests
47+
48+
bdd-tests:
49+
runs-on: ubuntu-latest
50+
needs: ["unit-tests"]
51+
strategy:
52+
fail-fast: true
53+
matrix:
54+
kubernetes: [v1.27.3]
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v4
58+
59+
- name: Set up Go 1.19
60+
uses: actions/setup-go@v4
61+
with:
62+
go-version: 1.19.9
63+
cache: false
64+
65+
- name: Build images locally
66+
run: make zfs-driver-image || exit 1;
67+
68+
- name: Setup zfs pools
69+
run: |
70+
sudo apt-get install zfsutils-linux -y
71+
truncate -s 100G /tmp/disk.img
72+
sudo zpool create zfspv-pool $(sudo losetup -f /tmp/disk.img --show)
73+
74+
- name: Setup Minikube-Kubernetes
75+
uses: medyagh/setup-minikube@latest
76+
with:
77+
cache: false
78+
minikube-version: 1.31.1
79+
driver: none
80+
kubernetes-version: ${{ matrix.kubernetes }}
81+
cni: calico
82+
start-args: "--install-addons=false"
83+
84+
- name: Setting environment variables
85+
run: |
86+
echo "KUBECONFIG=$HOME/.kube/config" >> $GITHUB_ENV
87+
echo "OPENEBS_NAMESPACE=openebs" >> $GITHUB_ENV
88+
89+
- name: bootstrap
90+
run: make bootstrap
91+
92+
- name: Running tests
93+
run: |
94+
make ci
95+
make sanity
96+
97+
- name: Upload CI Test Coverage Report
98+
uses: codecov/codecov-action@v4
99+
with:
100+
token: ${{ secrets.CODECOV_TOKEN }}
101+
file: ./tests/bdd_coverage.txt
102+
name: coverage-bdd_coverage-$(date +%s)
103+
flags: bddtests
104+
22105
csi-driver:
23-
if: contains(github.ref, 'tags/v')
24106
runs-on: ubuntu-latest
107+
needs: ["lint", "bdd-tests"]
25108
steps:
26109
- name: Checkout
27110
uses: actions/checkout@v4
28-
111+
112+
- uses: cachix/install-nix-action@v22
113+
- name: Pre-populate nix-shell
114+
run: |
115+
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
116+
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
117+
nix-shell --pure --run "echo" ./shell.nix
118+
119+
- name: Check if the chart is publishable
120+
run: |
121+
TAG=${{ github.event.release.tag_name }}
122+
nix-shell --pure --run "./scripts/update-chart-version.sh --tag $TAG --publish-release" ./shell.nix
123+
29124
- name: Set Image Org
30-
# sets the default IMAGE_ORG to openebs
31125
run: |
32126
[ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}}
33127
echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV
34128
35-
- name: Set Tag and Branch
129+
- name: Set IMAGE_TAG and BRANCH
36130
run: |
37-
TAG="${GITHUB_REF#refs/*/v}"
38-
echo "TAG=${TAG}" >> $GITHUB_ENV
39-
echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV
40-
BRANCH="v${TAG%.*}.x"
41-
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
131+
BRANCH=${{ github.ref_name }}
132+
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
133+
echo "IMAGE_TAG=$(awk -F': ' '/^version:/ {print $$2}' deploy/helm/charts/Chart.yaml)" >> $GITHUB_ENV
42134
43135
- name: Set Build Date
44136
id: date
45137
run: |
46138
echo "DATE=$(date -u +'%Y-%m-%dT%H:%M:%S%Z')" >> $GITHUB_OUTPUT
47-
139+
48140
- name: Docker meta
49141
id: docker_meta
50142
uses: docker/metadata-action@v4
@@ -56,36 +148,12 @@ jobs:
56148
ghcr.io/${{ env.IMAGE_ORG }}/zfs-driver
57149
tags: |
58150
type=raw,value=latest,enable=false
59-
type=raw,value=${{ env.TAG }}
60-
61-
- name: Print Build info
62-
run: |
63-
echo "${{ steps.docker_meta.outputs.tags }}"
64-
echo "RELEASE TAG: ${RELEASE_TAG}"
65-
echo "RELEASE BRANCH: ${BRANCH}"
66-
67-
- name: Configure Git
68-
run: |
69-
git config user.name "GitHub Actions"
70-
git config user.email "[email protected]"
151+
type=raw,value=${{ env.IMAGE_TAG }}
71152
72-
- name: Update Operator YAML
73-
if: "!github.event.release.prerelease"
153+
- name: Print Tag info
74154
run: |
75-
echo "update the operator yaml with the image tag"
76-
sed -i "s/zfs-driver:.*/zfs-driver:${RELEASE_TAG}/" deploy/yamls/zfs-driver.yaml
77-
sed -i "s/openebs.io\/version:.*/openebs.io\/version: ${RELEASE_TAG}/" deploy/yamls/zfs-driver.yaml
78-
sed -i "s/zfs-driver:.*/zfs-driver:${RELEASE_TAG}/" deploy/zfs-operator.yaml
79-
sed -i "s/openebs.io\/version:.*/openebs.io\/version: ${RELEASE_TAG}/" deploy/zfs-operator.yaml
80-
sed -i "s/newTag:.*/newTag: ${RELEASE_TAG}/" deploy/yamls/kustomization.yaml
81-
82-
git diff --quiet deploy/ || CHANGED=$?
83-
if [[ $CHANGED -ne 0 ]]; then
84-
echo "Commiting operator yaml changes"
85-
git add deploy/
86-
git commit -s -m 'chore(yaml): updating operator yaml with the image tag'
87-
git push origin HEAD:"${BRANCH}"
88-
fi
155+
echo "BRANCH: ${{ env.BRANCH }}"
156+
echo "${{ steps.docker_meta.outputs.tags }}"
89157
90158
- name: Set up QEMU
91159
uses: docker/setup-qemu-action@v3
@@ -99,11 +167,11 @@ jobs:
99167
version: v0.13.1
100168

101169
- name: Login to Docker Hub
102-
uses: docker/login-action@v3
170+
uses: docker/login-action@v3
103171
with:
104172
username: ${{ secrets.DOCKERHUB_USERNAME }}
105173
password: ${{ secrets.DOCKERHUB_TOKEN }}
106-
174+
107175
- name: Login to Quay
108176
uses: docker/login-action@v3
109177
with:
@@ -131,4 +199,28 @@ jobs:
131199
DBUILD_DATE=${{ steps.date.outputs.DATE }}
132200
DBUILD_REPO_URL=https://github.com/openebs/zfs-localpv
133201
DBUILD_SITE_URL=https://openebs.io
134-
RELEASE_TAG=${{ env.RELEASE_TAG }}
202+
BRANCH=${{ env.BRANCH }}
203+
204+
release-chart:
205+
runs-on: ubuntu-latest
206+
needs: ["csi-driver"]
207+
steps:
208+
- uses: actions/checkout@v4
209+
210+
- uses: cachix/install-nix-action@v22
211+
- name: Pre-populate nix-shell
212+
run: |
213+
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
214+
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
215+
nix-shell --pure --run "echo" ./shell.nix
216+
217+
- name: Check if the chart is publishable
218+
run: |
219+
TAG=${{ github.event.release.tag_name }}
220+
nix-shell --pure --run "./scripts/update-chart-version.sh --tag $TAG --publish-release" ./shell.nix
221+
222+
- name: Publish zfs localpv develop or prerelease helm chart
223+
uses: stefanprodan/helm-gh-pages@master
224+
with:
225+
token: ${{ secrets.GITHUB_TOKEN }}
226+
charts_dir: ./deploy/helm

0 commit comments

Comments
 (0)