-
Notifications
You must be signed in to change notification settings - Fork 11
205 lines (173 loc) · 6.6 KB
/
release.yml
File metadata and controls
205 lines (173 loc) · 6.6 KB
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: Release
on:
push:
branches:
- main
tags:
- 'v*.*.*'
paths-ignore:
- 'docs/**'
- '**/*.md'
pull_request:
paths-ignore:
- 'docs/**'
- '**/*.md'
types: [labeled, unlabeled, opened, synchronize, reopened]
jobs:
docker:
name: Build and Push Docker Images
runs-on: ubuntu-latest
if: |
github.event_name == 'push' ||
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ok-to-image'))
permissions:
contents: read
packages: write
strategy:
matrix:
image:
- gardener-extension-provider-ironcore
- gardener-extension-admission-ironcore
env:
platforms: linux/amd64,linux/arm64
steps:
- uses: actions/checkout@v6
- uses: docker/metadata-action@v6
id: meta
with:
images: |
ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}
tags: |
type=semver,pattern={{version}}
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha
flavor: |
latest=${{ github.ref == 'refs/heads/main' }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
with:
image: tonistiigi/binfmt:latest
platforms: ${{ env.platforms }}
# workaround for self-hosted runner
# https://github.com/mumoshu/actions-runner-controller-ci/commit/e91c8c0f6ca82aa7618010c6d2f417aa46c4a4bf
- name: Set up Docker Context for Buildx
id: buildx-context
run: |
docker context create builders
- name: Set up Docker Buildx
timeout-minutes: 5
uses: docker/setup-buildx-action@v4
with:
version: latest
endpoint: builders # self-hosted
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
timeout-minutes: 40
uses: docker/build-push-action@v7
with:
context: .
platforms: ${{ env.platforms }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: ${{ matrix.image }}
helm:
name: Release Helm Charts
runs-on: ubuntu-latest
if: |
github.event_name == 'push' ||
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ok-to-charts'))
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- uses: azure/setup-helm@v5
with:
version: v3.16.2
- name: Determine chart version
id: chart_version
run: |
# Use SHA for main branch and PRs
CHART_VERSION="v0.0.0+$(echo ${{ github.sha }} | cut -c1-7)"
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# Use tag version
CHART_VERSION="${GITHUB_REF_NAME}"
fi
echo "version=$CHART_VERSION" >> $GITHUB_OUTPUT
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Package Helm charts
run: |
helm package charts/gardener-extension-provider-ironcore --version ${CHART_VERSION}
helm package charts/gardener-extension-admission-ironcore/charts/application --version ${CHART_VERSION}
helm package charts/gardener-extension-admission-ironcore/charts/runtime --version ${CHART_VERSION}
env:
CHART_VERSION: ${{ steps.chart_version.outputs.version }}
- name: Push Helm charts to GHCR
if: github.event_name != 'pull_request'
run: |
helm push gardener-extension-provider-ironcore-${CHART_VERSION}.tgz oci://ghcr.io/${REPO_OWNER}/charts
helm push gardener-extension-admission-ironcore-runtime-${CHART_VERSION}.tgz oci://ghcr.io/${REPO_OWNER}/charts
helm push gardener-extension-admission-ironcore-application-${CHART_VERSION}.tgz oci://ghcr.io/${REPO_OWNER}/charts
env:
CHART_VERSION: ${{ steps.chart_version.outputs.version }}
REPO_OWNER: ${{ github.repository_owner }}
ocm:
name: Release OCM Component
runs-on: ubuntu-latest
if: |
github.event_name == 'push'
needs:
- docker
- helm
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: open-component-model/ocm-setup-action@8c71929f38d3486e352e5d7aaf813f36accaaf43
- name: Retrieve image versions from imagevector
run: yq '.images[] | ((.name | sub("-"; "_") | upcase) + "_VERSION=" + .tag)' imagevector/images.yaml >> $GITHUB_ENV
- name: Determine OCM component version and destination repository
run: |
# Use dev version and repo by default
gitsha=$(echo ${{ github.sha }} | cut -c1-7)
OCM_VERSION="v0.0.0+${gitsha}"
CHART_VERSION="v0.0.0_${gitsha}"
IMAGE_VERSION="sha-${gitsha}"
OCM_REPO="ghcr.io/${{ github.repository_owner}}/ocm-dev"
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# Use tag version and production repo
OCM_VERSION="${GITHUB_REF_NAME}"
CHART_VERSION="${GITHUB_REF_NAME}"
IMAGE_VERSION="${GITHUB_REF_NAME}"
OCM_REPO="ghcr.io/${{ github.repository_owner}}/ocm"
fi
echo "VERSION=$OCM_VERSION" >> $GITHUB_ENV
echo "CHART_VERSION=$CHART_VERSION" >> $GITHUB_ENV
echo "IMAGE_VERSION=$IMAGE_VERSION" >> $GITHUB_ENV
echo "OCM_REPO=$OCM_REPO" >> $GITHUB_ENV
- name: Add OCM component version to transport archive
run: ocm add components --create --file ocm/ctf ocm/component-constructor.yaml --addenv
env:
SOURCE_REF: ${{ github.ref }}
SOURCE_COMMIT_SHA: ${{ github.sha }}
- name: Transfer OCM component transport archive to GitHub Container Registry
run: ocm transfer ctf ocm/ctf ${OCM_REPO}