-
Notifications
You must be signed in to change notification settings - Fork 592
193 lines (183 loc) · 7.23 KB
/
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
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
name: release
on:
workflow_dispatch:
inputs:
tag:
description: |
The version to release.
Depending on the value, a production release will be published to GitHub or not.
- In case of prerelease tags (e.g. v1.2.3-alpha.1) it will build-push the images (only standard tags,
i.e., v1.2.3-alpha.1), test them and publish a GitHub prerelease (labeled as non-production ready).
- In other cases (e.g. v1.2.3) it will build-push the images (standard and supplemental tags,
i.e., v1.2.3 and v1.2), test them and publish a production Github release.
required: true
latest:
description: 'Whether to tag this release latest'
required: true
type: boolean
default: false
jobs:
verify-manifest-tag:
runs-on: ubuntu-latest
outputs:
fullversion_tag: ${{ steps.semver_parser.outputs.fullversion }}
steps:
- uses: mukunku/[email protected]
id: check-tag
name: check if tag already exists
with:
tag: ${{ github.event.inputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: fail if tag already exists
if: ${{ steps.check-tag.outputs.exists == 'true' }}
run: exit 1
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Parse semver string
id: semver_parser
uses: booxmedialtd/[email protected]
with:
input_string: ${{ github.event.inputs.tag }}
version_extractor_regex: 'v(.*)$'
- name: Verify manifests have requested KIC tag
if: ${{ steps.semver_parser.outputs.prerelease == '' }}
env:
# We expect the tag used in manifests to be {major}.{minor} part of the version, e.g.
# for v2.10.3 we expect manifests to use 2.10 tag.
TAG: ${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}
run: make verify.versions
build-push-images:
environment: 'Docker Push'
needs: verify-manifest-tag
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Parse semver string
id: semver_parser
uses: booxmedialtd/[email protected]
with:
input_string: ${{ github.event.inputs.tag }}
version_extractor_regex: 'v(.*)$'
- name: Add standard tags
run: |
echo 'TAGS_STANDARD<<EOF' >> $GITHUB_ENV
echo 'type=raw,value=${{ steps.semver_parser.outputs.fullversion }}' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Add major.minor tag
if: ${{ steps.semver_parser.outputs.prerelease == '' }}
run: |
echo 'TAGS_SUPPLEMENTAL<<EOF' >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo 'type=raw,value=${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
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@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Docker meta
id: meta
uses: docker/[email protected]
with:
images: kong/kubernetes-ingress-controller
flavor: |
latest=${{ github.event.inputs.latest == 'true' }}
tags: ${{ env.TAGS_STANDARD }}${{ env.TAGS_SUPPLEMENTAL }}
- name: Build binary
id: docker_build_binary
uses: docker/build-push-action@v5
with:
push: false
file: Dockerfile
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
target: builder
platforms: linux/amd64, linux/arm64
build-args: |
TAG=${{ steps.meta.outputs.version }}
COMMIT=${{ github.sha }}
REPO_INFO=https://github.com/${{ github.repository }}.git
- name: Build and push distroless image to DockerHub
id: docker_build
uses: docker/build-push-action@v5
with:
push: true
file: Dockerfile
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
target: distroless
platforms: linux/amd64, linux/arm64
build-args: |
TAG=${{ steps.meta.outputs.version }}
COMMIT=${{ github.sha }}
REPO_INFO=https://github.com/${{ github.repository }}.git
test-e2e:
needs: [verify-manifest-tag, build-push-images]
uses: ./.github/workflows/_e2e_tests.yaml
secrets: inherit
with:
kic-image: kong/kubernetes-ingress-controller:${{ needs.verify-manifest-tag.outputs.fullversion_tag }}
all-supported-k8s-versions: true
publish-release:
runs-on: ubuntu-latest
needs: [build-push-images, test-e2e]
steps:
- name: Parse semver string
id: semver_parser
uses: booxmedialtd/[email protected]
with:
input_string: ${{ github.event.inputs.tag }}
version_extractor_regex: 'v(.*)$'
- uses: ncipollo/release-action@v1
with:
body: |
#### Download Kong Ingress Controller ${{ steps.semver_parser.outputs.fullversion }}:
- [Docker Image](https://hub.docker.com/repository/docker/kong/kubernetes-ingress-controller)
- [Get started](https://github.com/Kong/kubernetes-ingress-controller#get-started)
#### Links:
- [Changelog](https://github.com/Kong/kubernetes-ingress-controller/blob/main/CHANGELOG.md#${{ steps.semver_parser.outputs.major }}${{ steps.semver_parser.outputs.minor }}${{ steps.semver_parser.outputs.patch }})
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.event.inputs.tag }}
commit: ${{ github.sha }}
# When prerelease part of the input tag is not empty, make it a prerelease.
# The release will be labeled as non-production ready in GitHub.
prerelease: ${{ steps.semver_parser.outputs.prerelease != '' }}
makeLatest: ${{ github.event.inputs.latest == 'true' }}
update-latest-branch:
runs-on: ubuntu-latest
if: github.event.inputs.latest == 'true'
needs:
- publish-release
steps:
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Parse semver string
id: semver_parser
uses: booxmedialtd/[email protected]
with:
input_string: ${{ github.event.inputs.tag }}
version_extractor_regex: 'v(.*)$'
- name: update 'latest' branch
run: |
git checkout latest
git reset --hard v${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}.${{ steps.semver_parser.outputs.patch }}
git push -f origin latest