-
-
Notifications
You must be signed in to change notification settings - Fork 464
239 lines (230 loc) · 7.95 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
name: Test & Release
on:
- push
- workflow_dispatch
env:
IMAGE_REGISTRY: ghcr.io
IMAGE_BASE_REPO: k3d-io
IMAGE_PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
GO_VERSION: "1.22.x"
DOCKER_VERSION: "27.0"
jobs:
test-suite:
timeout-minutes: 30
name: Full Test Suite
runs-on: ubuntu-22.04
steps:
# Setup
- uses: actions/checkout@v3
- name: Setup Go environment
uses: actions/setup-go@v3
with:
go-version: "${{ env.GO_VERSION }}"
- name: Setup Docker
uses: docker-practice/actions-setup-docker@master
with:
docker_version: "${{ env.DOCKER_VERSION }}"
- name: Setup CI Tools
run: make ci-setup
# Code Check
- name: Run Static Analysis
run: make ci-lint
# Tests
- name: Run Go Tests
run: make test
- name: Run E2E Tests
timeout-minutes: 30
# Quite often, tests were failing due to "too many open files" errors, so we're fixing this here
# Also, we want to see trace level logs if tests fail and the pipeline should exit on first error
run: |
echo "[$(date '+%F %H:%M:%S')] Setting up environment for E2E tests..."
sudo prlimit --pid $$ --nofile=1048576:1048576
sudo sysctl fs.inotify.max_user_instances=1280
sudo sysctl fs.inotify.max_user_watches=655360
echo "[$(date '+%F %H:%M:%S')] Running E2E tests..."
make e2e -e E2E_LOG_LEVEL=trace -e E2E_FAIL_FAST=true
# Builds
- name: Test Platform Builds
run: make build-cross
- name: Test Helper Image Builds
run: make build-helper-images
release-images:
name: Build & Release Images
# Only run on tags
runs-on: ubuntu-22.04
steps:
# Setup
- uses: actions/checkout@v3
# Container Image Setup
- name: Setup Docker
uses: docker-practice/actions-setup-docker@master
with:
docker_version: "${{ env.DOCKER_VERSION }}"
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# Gather Docker Metadata
- name: Docker Metadata k3d-binary
id: meta-k3d-binary
env:
IMAGE_ID: k3d
uses: docker/metadata-action@v3
with:
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_BASE_REPO }}/${{ env.IMAGE_ID }}
github-token: ${{ secrets.GITHUB_TOKEN }}
bake-target: docker-metadata-${{ env.IMAGE_ID }}
tags: |
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}}
type=ref,event=branch
type=ref,event=pr
type=sha
- name: Docker Metadata k3d-dind
id: meta-k3d-dind
env:
IMAGE_ID: k3d
IMAGE_SUFFIX: "-dind"
uses: docker/metadata-action@v3
with:
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_BASE_REPO }}/${{ env.IMAGE_ID }}
github-token: ${{ secrets.GITHUB_TOKEN }}
bake-target: docker-metadata-${{ env.IMAGE_ID }}${{ env.IMAGE_SUFFIX }}
tags: |
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}}
type=ref,event=branch
type=ref,event=pr
type=sha
flavor: |
suffix=${{ env.IMAGE_SUFFIX }}
- name: Docker Metadata k3d-proxy
id: meta-k3d-proxy
env:
IMAGE_ID: k3d-proxy
uses: docker/metadata-action@v3
with:
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_BASE_REPO }}/${{ env.IMAGE_ID }}
github-token: ${{ secrets.GITHUB_TOKEN }}
bake-target: docker-metadata-${{ env.IMAGE_ID }}
tags: |
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}}
type=ref,event=branch
type=ref,event=pr
type=sha
- name: Docker Metadata k3d-tools
id: meta-k3d-tools
env:
IMAGE_ID: k3d-tools
uses: docker/metadata-action@v3
with:
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_BASE_REPO }}/${{ env.IMAGE_ID }}
github-token: ${{ secrets.GITHUB_TOKEN }}
bake-target: docker-metadata-${{ env.IMAGE_ID }}
tags: |
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}}
type=ref,event=branch
type=ref,event=pr
type=sha
- name: Merge Metadata Bake Definitions
run: |
INPUT=(${{ steps.meta-k3d-binary.outputs.bake-file }} ${{ steps.meta-k3d-dind.outputs.bake-file }} ${{ steps.meta-k3d-proxy.outputs.bake-file }} ${{ steps.meta-k3d-tools.outputs.bake-file }})
OUT_FILE=./bake-metadata.json
OUT_FILE_TMP=./bake-metadata-tmp.json
cat << EOF > $OUT_FILE
{
"target": {}
}
EOF
for file in "${INPUT[@]}"; do
cat $OUT_FILE > $OUT_FILE_TMP
jq -s '.[0] * .[1]' $OUT_FILE_TMP $file > $OUT_FILE
done
rm "$OUT_FILE_TMP"
# Build and Push container images
- name: Build Images
uses: docker/bake-action@v2.3.0
with:
files: |
./docker-bake.hcl
./bake-metadata.json
targets: release
push: false
# Wait for tests to pass and push images (ONLY ON TAG)
- name: Wait for tests to succeed
if: startsWith(github.ref, 'refs/tags/')
uses: lewagon/wait-on-check-action@v1.3.4
with:
ref: ${{ github.ref }}
check-name: "Full Test Suite"
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 20
- name: Push Images
if: startsWith(github.ref, 'refs/tags/')
uses: docker/bake-action@v2.3.0
with:
files: |
./docker-bake.hcl
./bake-metadata.json
targets: release
push: true
release-github:
name: Build & Release Binaries
# Only run on tags
runs-on: ubuntu-22.04
steps:
# Setup
- uses: actions/checkout@v3
- name: Setup Go environment
uses: actions/setup-go@v3
with:
go-version: "${{ env.GO_VERSION }}"
- name: Setup CI Tools
run: make ci-setup
# Go Build
- name: Build k3d Binary
run: make gen-checksum build-cross
# Wait for tests to pass and create release (ONLY ON TAG)
- name: Wait for tests to succeed
if: startsWith(github.ref, 'refs/tags/')
uses: lewagon/wait-on-check-action@v1.3.4
with:
ref: ${{ github.ref }}
check-name: "Full Test Suite"
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 20
# Create Git Release
- name: Extract Tag from Ref
if: startsWith(github.ref, 'refs/tags/')
id: tag
run: echo VERSION=${GITHUB_REF/refs\/tags\//} >> $GITHUB_OUTPUT
shell: bash
- uses: apexskier/github-semver-parse@v1
if: startsWith(github.ref, 'refs/tags/')
id: semver
with:
version: ${{ steps.tag.outputs.VERSION }}
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: _dist/*
discussionCategory: releases
generateReleaseNotes: true
prerelease: ${{ steps.semver.outputs.prerelease != '' }}
replacesArtifacts: true
token: ${{ secrets.GITHUB_TOKEN }}