-
Notifications
You must be signed in to change notification settings - Fork 202
219 lines (216 loc) · 8.68 KB
/
dapr_cli.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
# ------------------------------------------------------------
# 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: dapr_cli
on:
push:
branches:
- master
- release-*
tags:
- v*
pull_request:
branches:
- master
- release-*
jobs:
build:
name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries
runs-on: ${{ matrix.os }}
env:
GOLANG_CI_LINT_VER: v1.55.2
GOOS: ${{ matrix.target_os }}
GOARCH: ${{ matrix.target_arch }}
GOPROXY: https://proxy.golang.org
ARCHIVE_OUTDIR: dist/archives
DaprEXEDirectory: dist/windows_amd64/release
DaprLicenseDirectory: .github/wix
WIX_BIN_PATH: 'C:/Program Files (x86)/WiX Toolset v3.11/bin'
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest, macOS-latest-large]
target_arch: [arm, arm64, amd64]
include:
- os: ubuntu-latest
target_os: linux
- os: windows-latest
target_os: windows
- os: macOS-latest
target_os: darwin
- os: macOS-latest-large
target_os: darwin
exclude:
- os: windows-latest
target_arch: arm
- os: windows-latest
target_arch: arm64
- os: macOS-latest
target_arch: arm
- os: macOS-latest
target_arch: amd64
- os: macOS-latest-large
target_arch: arm
- os: macOS-latest-large
target_arch: arm64
steps:
- name: Prepare Go's bin location - MacOS
if: matrix.target_os == 'darwin'
run: |
export PATH=$HOME/bin:$PATH
echo "$HOME/bin" >> $GITHUB_PATH
echo "GOBIN=$HOME/bin" >> $GITHUB_ENV
mkdir -p $HOME/bin
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
id: setup-go
with:
go-version-file: 'go.mod'
- name: Cache Go modules (Linux)
if: matrix.target_os == 'linux'
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ steps.setup-go.outputs.go-version }}-
- name: Cache Go modules (Windows)
if: matrix.target_os == 'windows'
uses: actions/cache@v3
with:
path: |
~\AppData\Local\go-build
~\go\pkg\mod
key: ${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ steps.setup-go.outputs.go-version }}-
- name: Cache Go modules (macOS)
if: matrix.target_os == 'darwin'
uses: actions/cache@v3
with:
path: |
~/Library/Caches/go-build
~/go/pkg/mod
key: ${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ steps.setup-go.outputs.go-version }}-
- name: Run golangci-lint
if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux'
uses: golangci/[email protected]
with:
version: ${{ env.GOLANG_CI_LINT_VER }}
skip-cache: true
- name: Run make modtidy check-diff
if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux'
run: make modtidy check-diff
- name: Parse release version and set REL_VERSION
run: python ./.github/scripts/get_release_version.py
- name: Setup test output
shell: bash
run: |
export TEST_OUTPUT_FILE=$GITHUB_WORKSPACE/test-unit.json
echo "TEST_OUTPUT_FILE=$TEST_OUTPUT_FILE" >> $GITHUB_ENV
- 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@v3
- name: Run make release to build and archive binaries
run: |
mkdir -p ${{ env.ARCHIVE_OUTDIR }}
make release GOOS=${{ matrix.target_os }} GOARCH=${{ matrix.target_arch }} ARCHIVE_OUT_DIR=${{ env.ARCHIVE_OUTDIR }}
- name: Build msi installer
if: matrix.target_arch == 'amd64' && matrix.target_os == 'windows'
shell: pwsh
run: |
$env:Path += ";${{ env.WIX_BIN_PATH }}"
candle.exe -dVersion="${{ env.MSI_VERSION }}" -dDaprEXEDirectory="${{ env.DaprEXEDirectory }}" -dDaprLicenseDirectory="${{ env.DaprLicenseDirectory }}" .github/wix/dapr.wxs -o dapr.wixobj
light.exe -ext WixUIExtension ./dapr.wixobj -o "${{ env.ARCHIVE_OUTDIR }}/dapr.msi"
- name: Create release_version.txt
if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux'
run: |
[ ! -z "${{ env.REL_VERSION }}" ] && echo "${{ env.REL_VERSION }}" > "${{ env.ARCHIVE_OUTDIR }}/release_version.txt"
- name: upload artifacts ## Following migration guide in https://github.com/actions/upload-artifact/blob/main/docs/MIGRATION.md
uses: actions/upload-artifact@v4
with:
name: cli_drop-${{ matrix.target_os }}_${{ matrix.target_arch }}
path: ${{ env.ARCHIVE_OUTDIR }}
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target_os }}_${{ matrix.target_arch }}_test_unit.json
path: ${{ env.TEST_OUTPUT_FILE }}
publish:
name: Publish binaries
needs: build
if: startswith(github.ref, 'refs/tags/v')
env:
ARTIFACT_DIR: ./release
runs-on: ubuntu-latest
steps:
- name: download artifacts
uses: actions/download-artifact@v4
with:
pattern: cli_drop-*
merge-multiple: true
path: ${{ env.ARTIFACT_DIR }}
- name: Set Release Version
run: |
REL_VERSION_FILE="${{ env.ARTIFACT_DIR }}/release_version.txt"
REL_VER=`cat ${REL_VERSION_FILE}`
echo "REL_VERSION=${REL_VER}" >> $GITHUB_ENV
rm -f ${REL_VERSION_FILE}
- name: generate checksum files
run: cd ${ARTIFACT_DIR} && for i in *; do sha256sum -b $i > "$i.sha256"; done && cd -
- name: lists artifacts
run: ls -l ${{ env.ARTIFACT_DIR }}
- name: publish binaries to github
if: startswith(github.ref, 'refs/tags/v')
run: |
# Get the list of files
RELEASE_ARTIFACT=(${ARTIFACT_DIR}/*)
export GITHUB_TOKEN=${{ secrets.DAPR_BOT_TOKEN }}
echo "Uploading Dapr CLI Binaries to GitHub Release"
gh release create \
"v${REL_VERSION}" \
--title "Dapr CLI v${REL_VERSION}" \
--repo $GITHUB_REPOSITORY \
--prerelease \
${RELEASE_ARTIFACT[*]}
publish-winget:
name: Publish to winget-pkgs
needs: publish
if: startswith(github.ref, 'refs/tags/v')
runs-on: windows-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Parse release version and set REL_VERSION
run: python ./.github/scripts/get_release_version.py
- name: Update winget manifests
shell: pwsh
run: |
$url = "https://github.com/dapr/cli/releases/download/v${{ env.REL_VERSION }}/dapr.msi"
iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
if("${{ env.REL_VERSION }}".Contains("-rc.")){
$PackageIdentifier="Dapr.CLI.Preview"
} else{
$PackageIdentifier="Dapr.CLI"
}
.\wingetcreate.exe update "$PackageIdentifier" --submit --urls "$url|x64" --version "${{ env.REL_VERSION }}" --token "${{ secrets.DAPR_BOT_TOKEN }}"