Skip to content

Commit ed84837

Browse files
ci: add staging ci for release prep
Signed-off-by: Abhinandan Purkait <[email protected]>
1 parent b690e9a commit ed84837

File tree

7 files changed

+402
-237
lines changed

7 files changed

+402
-237
lines changed

.github/workflows/release.yml

Lines changed: 49 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,12 @@
1-
# Copyright 2018-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-
151
name: Release Images and Charts
162

173
on:
184
release:
195
types:
20-
- 'created'
6+
- "created"
217

228
jobs:
23-
lint:
24-
runs-on: ubuntu-latest
25-
steps:
26-
- name: Checkout
27-
uses: actions/checkout@v4
28-
with:
29-
fetch-depth: 0
30-
31-
- name: Shellcheck
32-
uses: reviewdog/action-shellcheck@v1
33-
with:
34-
github_token: ${{ secrets.github_token }}
35-
reporter: github-pr-review
36-
path: "."
37-
pattern: "*.sh"
38-
39-
- uses: cachix/install-nix-action@v22
40-
- uses: rrbutani/[email protected]
41-
with:
42-
file: shell.nix
43-
44-
- name: Set up Go 1.19
45-
uses: actions/setup-go@v5
46-
with:
47-
go-version: 1.19.13
48-
cache: false
49-
50-
- name: Check if the chart is publishable
51-
run: |
52-
TAG=${{ github.event.release.tag_name }}
53-
./scripts/update-chart-version.sh --tag $TAG --publish-release
54-
55-
- name: Run chart-testing lint
56-
run: |
57-
ct lint --config ct.yaml
58-
59-
unit-test:
60-
runs-on: ubuntu-latest
61-
needs: ['lint']
62-
steps:
63-
- name: Set up Go 1.19
64-
uses: actions/setup-go@v5
65-
with:
66-
go-version: 1.19.13
67-
68-
- name: Checkout
69-
uses: actions/checkout@v4
70-
71-
- name: Unit test
72-
run: make test
73-
74-
- name: Verify corrections
75-
run: make verify-src
76-
77-
- name: Upload Coverage Report
78-
uses: codecov/codecov-action@v4
79-
with:
80-
token: ${{ secrets.CODECOV_TOKEN }}
81-
file: ./coverage.txt
82-
name: coverage-$(date +%s)
83-
flags: unittests
84-
85-
integration-test:
86-
runs-on: ubuntu-22.04
87-
needs: ['lint', 'unit-test']
88-
strategy:
89-
matrix:
90-
kubernetes: [v1.27.2]
91-
steps:
92-
- name: Set up Go 1.19
93-
uses: actions/setup-go@v5
94-
with:
95-
go-version: 1.19.13
96-
97-
- name: Checkout
98-
uses: actions/checkout@v4
99-
100-
- name: Build images locally
101-
run: make provisioner-localpv-image || exit 1;
102-
103-
- name: Setup Minikube-Kubernetes
104-
uses: medyagh/setup-minikube@latest
105-
with:
106-
cache: false
107-
minikube-version: 1.31.1
108-
driver: none
109-
kubernetes-version: ${{ matrix.kubernetes }}
110-
cni: calico
111-
start-args: '--install-addons=false'
112-
113-
- name: Set up infra for integration test
114-
run: |
115-
sudo apt-get update && sudo apt-get install -y xfsprogs quota linux-modules-extra-`uname -r`
116-
go install -mod=mod github.com/onsi/ginkgo/v2/[email protected]
117-
helm install localpv-provisioner ./deploy/helm/charts -n openebs --create-namespace --set localpv.image.pullPolicy=Never --set analytics.enabled=false
118-
kubectl get pods -A
119-
120-
- name: Integration test
121-
run: |
122-
make integration-test
123-
124-
- name: Upload Integration Test Coverage Report
125-
uses: codecov/codecov-action@v4
126-
with:
127-
token: ${{ secrets.CODECOV_TOKEN }}
128-
file: ./tests/integration_coverage.txt
129-
name: coverage-integration-test-$(date +%s)
130-
flags: integrationtests
131-
132-
provisioner-localpv:
133-
needs: ['integration-test']
9+
release-images-and-chart:
13410
runs-on: ubuntu-latest
13511
steps:
13612
- name: Checkout
@@ -143,111 +19,84 @@ jobs:
14319
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
14420
nix-shell --pure --run "echo" ./shell.nix
14521
146-
- name: Check if the chart is publishable
147-
run: |
148-
TAG=${{ github.event.release.tag_name }}
149-
nix-shell --pure --run "./scripts/update-chart-version.sh --tag $TAG --publish-release" ./shell.nix
150-
15122
- name: Set Image Org
152-
# sets the default IMAGE_ORG to openebs
15323
run: |
154-
[ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}}
24+
[ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG }}
15525
echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV
15626
157-
- name: Set IMAGE_TAG and BRANCH
158-
run: |
159-
BRANCH=${{ github.ref_name }}
160-
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
161-
echo "IMAGE_TAG=$(awk -F': ' '/^version:/ {print $2}' deploy/helm/charts/Chart.yaml)" >> $GITHUB_ENV
27+
- name: Log in to GHCR for Helm
28+
run: nix-shell --pure --run "echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin" ./shell.nix
16229

163-
- name: Set Build Date
164-
id: date
30+
- name: Pull OCI chart from GHCR
31+
env:
32+
IMAGE_ORG: ${{ env.IMAGE_ORG }}
33+
RAW_TAG: ${{ github.ref_name }}
16534
run: |
166-
echo "DATE=$(date -u +'%Y-%m-%dT%H:%M:%S%Z')" >> $GITHUB_OUTPUT
35+
TAG="${RAW_TAG#v}"
36+
echo "Using chart version: $TAG"
16737
168-
- name: Docker meta
169-
id: docker_meta
170-
uses: docker/metadata-action@v4
171-
with:
172-
# add each registry to which the image needs to be pushed here
173-
images: |
174-
${{ env.IMAGE_ORG }}/provisioner-localpv
175-
quay.io/${{ env.IMAGE_ORG }}/provisioner-localpv
176-
ghcr.io/${{ env.IMAGE_ORG }}/provisioner-localpv
177-
tags: |
178-
type=raw,value=latest,enable=false
179-
type=raw,value=${{ env.IMAGE_TAG }}
180-
181-
- name: Print Tag info
182-
run: |
183-
echo "BRANCH: ${{ env.BRANCH }}"
184-
echo "RELEASE_TAG: ${{ steps.docker_meta.outputs.tags }}"
38+
rm -rf deploy/helm/charts
39+
mkdir -p charts-staged charts-final deploy/helm/charts
18540
186-
- name: Setup QEMU
187-
uses: docker/setup-qemu-action@v2
188-
with:
189-
platforms: all
41+
CHART_REF=oci://ghcr.io/${IMAGE_ORG}/helm/localpv-provisioner
42+
helm pull "$CHART_REF" \
43+
--version "$TAG" \
44+
--destination charts-staged
19045
191-
- name: Setup Docker Buildx
192-
id: buildx
193-
uses: docker/setup-buildx-action@v2
194-
with:
195-
version: v0.5.1
46+
tar -xzf charts-staged/localpv-provisioner-"$TAG".tgz -C charts-final
47+
48+
mv charts-final/localpv-provisioner/* deploy/helm/charts
49+
50+
- name: Set Chart Version
51+
run: |
52+
echo "VERSION=$(awk -F': ' '/^version:/ {print $2}' deploy/helm/charts/Chart.yaml)" >> $GITHUB_ENV
19653
197-
- name: Login to DockerHub
198-
uses: docker/login-action@v2
54+
- name: Login to Docker Hub
55+
uses: docker/login-action@v3
19956
with:
20057
username: ${{ secrets.DOCKERHUB_USERNAME }}
20158
password: ${{ secrets.DOCKERHUB_TOKEN }}
20259

20360
- name: Login to Quay
204-
uses: docker/login-action@v2
61+
uses: docker/login-action@v3
20562
with:
20663
registry: quay.io
20764
username: ${{ secrets.QUAY_USERNAME }}
20865
password: ${{ secrets.QUAY_TOKEN }}
20966

21067
- name: Login to GHCR
211-
uses: docker/login-action@v2
68+
uses: docker/login-action@v3
21269
with:
21370
registry: ghcr.io
21471
username: ${{ github.actor }}
21572
password: ${{ secrets.GITHUB_TOKEN }}
21673

217-
- name: Build and Push Image
218-
uses: docker/build-push-action@v4
219-
with:
220-
context: .
221-
file: ./buildscripts/provisioner-localpv/provisioner-localpv.Dockerfile
222-
push: true
223-
platforms: linux/amd64, linux/arm64, linux/arm/v7, linux/ppc64le
224-
tags: |
225-
${{ steps.docker_meta.outputs.tags }}
226-
build-args: |
227-
DBUILD_DATE=${{ steps.date.outputs.DATE }}
228-
DBUILD_REPO_URL=https://github.com/openebs/dynamic-localpv-provisioner
229-
DBUILD_SITE_URL=https://openebs.io
230-
BRANCH=${{ env.BRANCH }}
231-
232-
release-chart:
233-
runs-on: ubuntu-latest
234-
needs: ["provisioner-localpv"]
235-
steps:
236-
- uses: actions/checkout@v4
74+
- name: Mirror multi-arch image with crane to Dockerhub
75+
env:
76+
SRC: ghcr.io/${{ env.IMAGE_ORG }}/dev/provisioner-localpv:${{ env.VERSION }}
77+
DH: docker.io/${{ env.IMAGE_ORG }}/provisioner-localpv:${{ env.VERSION }}
78+
run: |
79+
nix-shell --pure --run "crane copy --platform all ${{ env.SRC }} ${{ env.DH }}" ./shell.nix
23780
238-
- uses: cachix/install-nix-action@v22
239-
- name: Pre-populate nix-shell
81+
- name: Mirror multi-arch image with crane to Github
82+
env:
83+
SRC: ghcr.io/${{ env.IMAGE_ORG }}/dev/provisioner-localpv:${{ env.VERSION }}
84+
GH: ghcr.io/${{ env.IMAGE_ORG }}/provisioner-localpv:${{ env.VERSION }}
24085
run: |
241-
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
242-
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
243-
nix-shell --pure --run "echo" ./shell.nix
86+
nix-shell --pure --run "crane copy --platform all ${{ env.SRC }} ${{ env.GH }}" ./shell.nix
87+
88+
- name: Mirror multi-arch image with crane to Quay
89+
env:
90+
SRC: ghcr.io/${{ env.IMAGE_ORG }}/dev/provisioner-localpv:${{ env.VERSION }}
91+
QY: quay.io/${{ env.IMAGE_ORG }}/provisioner-localpv:${{ env.VERSION }}
92+
run: |
93+
nix-shell --pure --run "crane copy --platform all ${{ env.SRC }} ${{ env.QY }}"
24494
245-
- name: Check if the chart is publishable
95+
- name: Update the registry and the repository
24696
run: |
247-
TAG=${{ github.event.release.tag_name }}
248-
nix-shell --pure --run "./scripts/update-chart-version.sh --tag $TAG --publish-release" ./shell.nix
97+
nix-shell --pure --run "./scripts/update-reg-repo.sh --registry docker.io/ --repository ${{ env.IMAGE_ORG }}/provisioner-localpv" ./shell.nix
24998
250-
- name: Publish dynamic localpv develop or prerelease helm chart
99+
- name: Publish chart via helm-gh-pages
251100
uses: stefanprodan/helm-gh-pages@master
252101
with:
253102
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)