forked from nuclio/nuclio
-
Notifications
You must be signed in to change notification settings - Fork 0
235 lines (195 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
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
# Copyright 2023 The Nuclio Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Release
on:
release:
types:
- created
# Run Release on push to development for unstable
push:
branches:
- development
workflow_dispatch:
inputs:
docker_image_rule:
description: 'Docker image rule to build and release (space separated)'
required: false
default: ''
env:
REPO: quay.io
REPO_NAME: nuclio
CACHE_REPO: ghcr.io
CACHE_REPO_NAME: ${{ github.repository_owner }}
DOCKER_BUILDKIT: 1
permissions:
# Allow the action to upload artifact to releases
contents: write
# Allow the action to upload cache images
packages: write
jobs:
image_matrix_prep:
name: Prepare image list
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: define targets
id: set-matrix
run: |
# if custom image is given, use it
if [[ -n "${{ github.event.inputs.docker_image_rule }}" ]]; then \
export DOCKER_IMAGES_RULES="${{ github.event.inputs.docker_image_rule }}"; \
fi;
docker_image_rules_json=$(make print-docker-image-rules-json)
# if "handler-builder-golang-onbuild" is in the matrix
# then ensure "handler-builder-golang-onbuild-alpine" is there too.
docker_image_rules_json=$(echo $docker_image_rules_json | \
jq -c 'select(.[].image_rule=="handler-builder-golang-onbuild") += [{"image_rule":"handler-builder-golang-onbuild-alpine"}]')
echo $docker_image_rules_json
echo "matrix=$(echo $docker_image_rules_json | jq -c '[.[].image_rule]')" >> $GITHUB_OUTPUT
release:
if: github.repository == 'nuclio/nuclio' || github.event_name == 'workflow_dispatch'
name: Release image (${{ matrix.docker_image_rule }}-${{ matrix.arch }})
runs-on: ubuntu-latest
needs: image_matrix_prep
strategy:
fail-fast: false
matrix:
arch:
- arm64
- amd64
docker_image_rule: ${{ fromJson(needs.image_matrix_prep.outputs.matrix) }}
exclude:
# issues with building on qemu
- arch: arm64
docker_image_rule: handler-builder-dotnetcore-onbuild
steps:
- name: Prepare envs
run: |
echo "NUCLIO_DOCKER_REPO=${{ env.REPO }}/${{ env.REPO_NAME }}" >> $GITHUB_ENV
echo "NUCLIO_CACHE_REPO=${{ env.CACHE_REPO }}/${{ env.CACHE_REPO_NAME }}" >> $GITHUB_ENV
echo "NUCLIO_ARCH=${{ matrix.arch }}" >> $GITHUB_ENV
- name: Prepare outputs
id: release_info
run: |
echo "REF_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
echo "REF_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Set NUCLIO_LABEL to unstable
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: echo "NUCLIO_LABEL=unstable" >> $GITHUB_ENV
- name: Set NUCLIO_LABEL to release tag
if: github.event_name == 'release'
run: echo "NUCLIO_LABEL=${{ steps.release_info.outputs.REF_TAG }}" >> $GITHUB_ENV
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
cache: true
go-version-file: go.mod
- name: Install QEMU
if: matrix.arch != 'amd64'
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ matrix.arch }}
- name: Login to registry
uses: docker/login-action@v2
with:
registry: ${{ env.REPO }}
username: ${{ secrets.QUAYIO_DOCKER_USERNAME }}
password: ${{ secrets.QUAYIO_DOCKER_PASSWORD }}
- name: Login to cache registry
uses: docker/login-action@v2
with:
registry: ${{ env.CACHE_REPO }}
username: ${{ env.CACHE_REPO_NAME }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build ${{ matrix.docker_image_rule }} image
run: |
make pull-docker-images-cache || true
make docker-images
env:
DOCKER_DEFAULT_PLATFORM: linux/${{ matrix.arch }}
DOCKER_IMAGES_RULES: ${{ matrix.docker_image_rule }}
# this only applies when target is `handler-builder-golang-onbuild`
# not applied when target is `handler-builder-golang-onbuild-alpine`
SKIP_BUILD_GOLANG_ONBUILD_ALPINE: true
- name: Push cache images
if: env.NUCLIO_LABEL == 'unstable'
run: make push-docker-images-cache
env:
DOCKER_IMAGES_RULES: ${{ matrix.docker_image_rule }}
SKIP_BUILD_GOLANG_ONBUILD_ALPINE: true
- name: Push images
run: make push-docker-images
env:
DOCKER_IMAGES_RULES: ${{ matrix.docker_image_rule }}
SKIP_BUILD_GOLANG_ONBUILD_ALPINE: true
- name: Tag and push stable images
if: env.NUCLIO_LABEL != 'unstable' && github.event.release.target_commitish == 'master' && contains(matrix.docker_image_rule, 'dashboard')
run: |
docker tag "$NUCLIO_DOCKER_REPO/dashboard:$NUCLIO_LABEL-$NUCLIO_ARCH" "$NUCLIO_DOCKER_REPO/dashboard:stable-$NUCLIO_ARCH"
docker push "$NUCLIO_DOCKER_REPO/dashboard:stable-$NUCLIO_ARCH"
env:
DOCKER_IMAGES_RULES: ${{ matrix.docker_image_rule }}
release_binary:
if: github.event_name == 'release'
name: Release Binary ${{ matrix.arch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch:
- arm64
- amd64
steps:
- name: Prepare envs
run: |
echo "NUCLIO_ARCH=${{ matrix.arch }}" >> $GITHUB_ENV
- name: Prepare outputs
id: release_info
run: |
echo "REF_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
echo "REF_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Set NUCLIO_LABEL to unstable
if: github.event_name == 'push'
run: echo "NUCLIO_LABEL=unstable" >> $GITHUB_ENV
- name: Set NUCLIO_LABEL to release tag
if: github.event_name == 'release'
run: echo "NUCLIO_LABEL=${{ steps.release_info.outputs.REF_TAG }}" >> $GITHUB_ENV
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
cache: true
- name: Install QEMU
if: matrix.arch != 'amd64'
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ matrix.arch }}
- name: Build binaries
run: |
NUCLIO_OS=linux make tools
NUCLIO_OS=darwin make tools
if [ $NUCLIO_ARCH == "amd64" ]; then \
NUCLIO_OS=windows make tools; \
fi;
env:
NUCLIO_NUCTL_CREATE_SYMLINK: false
GOPATH: /home/runner/go
DOCKER_DEFAULT_PLATFORM: linux/${{ matrix.arch }}
- name: Upload binaries
uses: AButler/[email protected]
with:
files: '/home/runner/go/bin/nuctl-*'
repo-token: ${{ secrets.GITHUB_TOKEN }}