-
Notifications
You must be signed in to change notification settings - Fork 48
328 lines (326 loc) · 13.9 KB
/
build.yml
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# ------------------------------------------------------------
# Copyright 2021 The Dapr 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: Build
on:
push:
branches:
- master
- release-*
tags:
- v*
paths-ignore:
- '**.md'
pull_request:
branches:
- master
- release-*
paths-ignore:
- '**.md'
jobs:
build:
name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries
runs-on: ${{ matrix.os }}
env:
GOVER: 1.19
GOLANGCILINT_VER: 1.50.1
GOOS: ${{ matrix.target_os }}
GOARCH: ${{ matrix.target_arch }}
GOPROXY: https://proxy.golang.org
NODE_VERSION: 16.x
ARTIFACTS_DIR: release/artifacts
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
target_arch: [arm, arm64, amd64]
include:
- os: ubuntu-latest
target_os: linux
- os: windows-latest
target_os: windows
- os: macOS-latest
target_os: darwin
exclude:
- os: windows-latest
target_arch: arm
- os: macOS-latest
target_arch: arm
- os: windows-latest
target_arch: arm64
steps:
- name: Setup node ${{ env.NODE_VERSION }} and npm
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install angular cli
run: npm install -g @angular/cli
- name: Set up Go ${{ env.GOVER }}
uses: actions/setup-go@v2
with:
go-version: ${{ env.GOVER }}
- name: Install golangci-lint
if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux'
run: |
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${{ env.GOROOT }}/bin" v${{ env.GOLANGCILINT_VER }}
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Parse release version and set REL_VERSION
run: python ./.github/scripts/get_release_version.py
- name: Run make lint
if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux'
run: make lint
- name: Run make test
env:
COVERAGE_OPTS: "-coverprofile=coverage.txt -covermode=atomic"
if: matrix.target_arch == 'amd64'
run: make test
- name: Codecov
if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux'
uses: codecov/codecov-action@v1
- name: Run make release to build and archive binaries
run: |
mkdir -p ${{ env.ARTIFACTS_DIR }}
make release GOOS=${{ matrix.target_os }} GOARCH=${{ matrix.target_arch }} ARCHIVE_OUT_DIR=${{ env.ARTIFACTS_DIR }}
- name: upload artifacts
uses: actions/upload-artifact@master
with:
name: dashboard_${{ matrix.target_os }}_${{ matrix.target_arch }}
path: ${{ env.ARTIFACTS_DIR }}
- name: docker login
if: matrix.target_os != 'darwin' && github.event_name != 'pull_request'
run: |
docker login -u ${{ secrets.DOCKER_REGISTRY_ID }} -p ${{ secrets.DOCKER_REGISTRY_PASS }}
- name: Build and push docker images to Docker Hub
if: matrix.target_os != 'darwin' && github.event_name != 'pull_request'
run: |
echo "Build docker image and push image..."
make docker-push TARGET_OS=${{ matrix.target_os }} TARGET_ARCH=${{ matrix.target_arch }} DAPR_REGISTRY=${{ secrets.DOCKER_DAPRIO_REGISTRY }} DAPR_TAG=${{ env.REL_VERSION }}
- name: GitHub container registry login
if: matrix.target_os != 'darwin' && github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker images to ghcr
if: matrix.target_os != 'darwin' && github.event_name != 'pull_request'
run: |
echo echo "Build docker image and push image..."
make docker-push TARGET_OS=${{ matrix.target_os }} TARGET_ARCH=${{ matrix.target_arch }} DAPR_REGISTRY=ghcr.io/${{ github.repository_owner }} DAPR_TAG=${{ env.REL_VERSION }}
publish:
name: Publish docker image and binaries
needs: build
if: github.event_name != 'pull_request'
env:
ARTIFACTS_DIR: ./release
DAPR_VERSION_ARTIFACT: dapr_version
DOCKER_REGISTRY: ${{ secrets.DOCKER_DAPRIO_REGISTRY }}
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Install Docker CE for buildx
run: |
sudo apt update
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install docker-ce
docker -v
- name: Parse release version and set REL_VERSION
run: python ./.github/scripts/get_release_version.py
- name: download artifacts - dapr_linux_amd64
uses: actions/download-artifact@master
with:
name: dashboard_linux_amd64
path: ${{ env.ARTIFACTS_DIR }}
- name: download artifacts - dapr_linux_arm
uses: actions/download-artifact@master
with:
name: dashboard_linux_arm
path: ${{ env.ARTIFACTS_DIR }}
- name: download artifacts - dapr_linux_arm64
uses: actions/download-artifact@master
with:
name: dashboard_linux_arm64
path: ${{ env.ARTIFACTS_DIR }}
- name: download artifacts - dapr_windows_amd64
uses: actions/download-artifact@master
with:
name: dashboard_windows_amd64
path: ${{ env.ARTIFACTS_DIR }}
- name: download artifacts - dapr_darwin_amd64
uses: actions/download-artifact@master
with:
name: dashboard_darwin_amd64
path: ${{ env.ARTIFACTS_DIR }}
- name: download artifacts - dapr_darwin_arm64
uses: actions/download-artifact@master
with:
name: dashboard_darwin_arm64
path: ${{ env.ARTIFACTS_DIR }}
- name: generate checksum files
run: cd ${ARTIFACTS_DIR} && for i in *; do sha256sum -b $i > "$i.sha256"; done && cd -
- name: lists artifacts
run: |
ls -l ${{ env.ARTIFACTS_DIR }}
- name: publish binaries to github
if: startswith(github.ref, 'refs/tags/v')
run: |
sudo npm install --silent --no-progress -g [email protected]
# Parse repository to get owner and repo names
OWNER_NAME="${GITHUB_REPOSITORY%%/*}"
REPO_NAME="${GITHUB_REPOSITORY#*/}"
# Get the list of files
RELEASE_ARTIFACT=(${{ env.ARTIFACTS_DIR }}/*)
export GITHUB_TOKEN=${{ secrets.DAPR_BOT_TOKEN }}
echo "Uploading release packages to GitHub Release"
github-release upload \
--owner $OWNER_NAME \
--repo $REPO_NAME \
--body "Release dapr dashboard v${REL_VERSION}" \
--tag "v${REL_VERSION}" \
--name "Dapr dashboard v${REL_VERSION}" \
--prerelease true \
${RELEASE_ARTIFACT[*]}
- name: docker login
run: |
docker login -u ${{ secrets.DOCKER_REGISTRY_ID }} -p ${{ secrets.DOCKER_REGISTRY_PASS }}
- name: Build and push docker multiarch manifest to Docker Hub
if: matrix.target_os != 'darwin'
run: |
echo "Build docker multiarch image manifest and push it"
make docker-publish DAPR_REGISTRY=${{ secrets.DOCKER_DAPRIO_REGISTRY }} DAPR_TAG=${{ env.REL_VERSION }}
- name: GitHub container registry login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker multiarch manifest to ghcr
if: matrix.target_os != 'darwin'
run: |
echo "Build docker multiarch image manifest and push it"
make docker-publish DAPR_REGISTRY=ghcr.io/${{ github.repository_owner }} DAPR_TAG=${{ env.REL_VERSION }}
helm-build:
name: Builds Helm chart
env:
HELM_PACKAGE_DIR: helm
HELMVER: v3.7.2
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
ARTIFACT_DIR: ./helm_release
DAPR_VERSION_ARTIFACT: dapr_version
runs-on: ubuntu-latest
steps:
- name: Set up Helm ${{ env.HELMVER }}
uses: azure/setup-helm@v1
with:
version: ${{ env.HELMVER }}
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Parse release version and set REL_VERSION and LATEST_RELEASE
run: python ./.github/scripts/get_release_version.py ${{ github.event_name }}
- name: Set REPO_OWNER
shell: bash
run: |
REPO_OWNER=${{ github.repository_owner }}
# Lowercase the value
echo "REPO_OWNER=${REPO_OWNER,,}" >>${GITHUB_ENV}
- name: Update Helm chart files for release version ${{ env.REL_VERSION }}
run: ./.github/scripts/set_helm_dapr_version.sh
- name: Generate Helm chart manifest
if: env.DOCKER_REGISTRY != ''
env:
DAPR_REGISTRY: ${{ env.DOCKER_REGISTRY }}
DAPR_TAG: ${{ env.REL_VERSION }}
run: |
make manifest-gen
shell: bash
- name: Move Helm chart manifest to artifact
if: env.DOCKER_REGISTRY != ''
run: |
mkdir -p ${{ env.ARTIFACT_DIR }}
mv ./release/install/dapr-dashboard.yaml ${{ env.ARTIFACT_DIR }}/dapr-dashboard.yaml
- name: Save release version
run: |
mkdir -p ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
echo ${REL_VERSION} > ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}/${{ env.DAPR_VERSION_ARTIFACT }}
- name: Package Helm chart
if: ${{ env.LATEST_RELEASE }} == "true" && env.DOCKER_REGISTRY != ''
env:
HELM_CHARTS_DIR: chart/dapr-dashboard
run: |
mkdir -p ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
helm package ${{ env.HELM_CHARTS_DIR }} --destination ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
- name: Upload Helm charts package to artifacts
if: ${{ env.LATEST_RELEASE }} == "true" && env.DOCKER_REGISTRY != ''
uses: actions/upload-artifact@master
with:
name: dapr_helm_charts_package
path: ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
# This job downloads the helm charts package artifact uploaded by the publish job,
# checks out the helm charts git hub pages repo and commits the latest version of
# helm charts package.
# This does not run on forks
helm-publish:
name: Publish Helm charts to Helm github pages repo
needs: helm-build
if: startswith(github.ref, 'refs/tags/v') && github.repository_owner == 'dapr'
env:
ARTIFACT_DIR: ./helm_release
DAPR_VERSION_ARTIFACT: dapr_version
HELM_PACKAGE_DIR: helm
runs-on: ubuntu-latest
steps:
- name: Create Helm charts directory
run: |
mkdir -p ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
- name: download artifacts - dapr_helm_charts_package
uses: actions/download-artifact@master
with:
name: dapr_helm_charts_package
path: ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
- name: Checkout Helm Charts Repo
uses: actions/checkout@v3
env:
DAPR_HELM_REPO: dapr/helm-charts
DAPR_HELM_REPO_CODE_PATH: helm-charts
with:
repository: ${{ env.DAPR_HELM_REPO }}
ref: refs/heads/master
token: ${{ secrets.DAPR_BOT_TOKEN }}
path: ${{ env.DAPR_HELM_REPO_CODE_PATH }}
- name: Upload helm charts to Helm Repo
env:
DAPR_HELM_REPO_CODE_PATH: helm-charts
DAPR_HELM_REPO: https://dapr.github.io/helm-charts/
run: |
daprVersion=`cat ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}/${{ env.DAPR_VERSION_ARTIFACT }}`
cd ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
cp -r `ls -A | grep -v ${{ env.DAPR_VERSION_ARTIFACT }}` $GITHUB_WORKSPACE/${{ env.DAPR_HELM_REPO_CODE_PATH }}
cd $GITHUB_WORKSPACE/${{ env.DAPR_HELM_REPO_CODE_PATH }}
helm repo index --url ${{ env.DAPR_HELM_REPO }} --merge index.yaml .
git config --global user.email "[email protected]"
git config --global user.name "dapr-bot"
git add --all
# Check if the dapr-dashboard-${daprVersion}.tgz file is modified.
if git diff --name-only --staged | grep -q ${daprVersion}; then
# If it is, we update the Helm chart, since this is an intentional update.
git commit -m "Release - $daprVersion"
git push
else
# This check is here because the automation can fail, but the manual step is no longer required.
# If not, this update was accidentally triggered by tagging a release before updating the Helm chart.
echo "::error::There is no change for ${daprVersion} Helm chart. Did you forget to update the chart version before tagging?"
exit -1
fi