-
Notifications
You must be signed in to change notification settings - Fork 123
156 lines (133 loc) · 4.95 KB
/
integration-tests-release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
---
name: Release
on:
pull_request:
paths:
- 'pkg/**'
- 'cmd/**'
- 'charts/**'
- 'tests/integration/**'
- '.github/workflows/**'
push:
branches:
- main
paths:
- 'pkg/**'
- 'cmd/**'
- 'charts/**'
- 'tests/integration/**'
- '.github/workflows/**'
release:
types:
- published
jobs:
release:
# Release job should never run on forks and should only trigger on main pushes and published releases
if: |
( github.event_name == 'release' && github.event.action == 'published' )
|| ( github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'k8ssandra' )
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Update PATH
run: |
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
- name: Create env variables
run: ./.github/scripts/env_variables.sh
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: ${{ env.HELM_VERSION }}
- name: Install and validate tool versions
run: |
scripts/install-yq.sh ${{ env.YQ_VERSION }}
helm version
yq -V
- name: Update chart dependencies
run: |
scripts/update-helm-deps.sh
- name: Compute release chart version
id: compute_next_version
run: |
DATE_TIME=$(date '+%Y%m%d%H%M%S')
RELEASE_VERSION=$(echo $(yq e '.version' charts/k8ssandra/Chart.yaml) | sed "s/-.*/-${DATE_TIME}-${GITHUB_SHA::8}/")
echo "Release version is: $RELEASE_VERSION"
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_OUTPUT
- name: Update Helm chart version
run: |
yq eval ".version |= \"${RELEASE_VERSION}\"" charts/k8ssandra/Chart.yaml -i
cat charts/k8ssandra/Chart.yaml
- name: Create working directory and copy charts
run: |
mkdir -p build/$RELEASE_VERSION
cp -rv charts/* build/$RELEASE_VERSION/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-integ-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-integ-
- name: Update k8ssandra-tools cleaner tag
run: |
yq eval ".cleaner.image.tag |= \"${RELEASE_VERSION}\"" charts/k8ssandra/values.yaml -i
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
context: .
file: cmd/k8ssandra-client/Dockerfile
push: true
tags: k8ssandra/k8ssandra-tools:latest, k8ssandra/k8ssandra-tools:${{ steps.compute_next_version.outputs.RELEASE_VERSION }}
platforms: linux/amd64,linux/arm64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Generate package archives
run: |
ls | while read c; do
if [[ -d $c ]]; then
helm package $c
fi
done
working-directory: build/${{ steps.compute_next_version.outputs.RELEASE_VERSION }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
# Helm Release
- id: 'auth'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: 'Set up Cloud SDK'
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Download current index from Google Cloud
env:
GCP_HELM_BUCKET_NAME: ${{ secrets.GCP_HELM_BUCKET_NAME }}
run: gsutil cp gs://$GCP_HELM_BUCKET_NAME/stable/index.yaml ./
working-directory: build/${{ steps.compute_next_version.outputs.RELEASE_VERSION }}
- name: Regenerate Helm index
env:
GCP_HELM_BUCKET_NAME: ${{ secrets.GCP_HELM_BUCKET_NAME }}
run: helm repo index . --merge index.yaml --url "https://$GCP_HELM_BUCKET_NAME/stable/"
working-directory: build/${{ steps.compute_next_version.outputs.RELEASE_VERSION }}
- name: Upload packages and index
env:
GCP_HELM_BUCKET_NAME: ${{ secrets.GCP_HELM_BUCKET_NAME }}
run: |
gsutil cp ./*.tgz gs://$GCP_HELM_BUCKET_NAME/stable/
gsutil cp ./index.yaml gs://$GCP_HELM_BUCKET_NAME/stable/
working-directory: build/${{ steps.compute_next_version.outputs.RELEASE_VERSION }}