-
-
Notifications
You must be signed in to change notification settings - Fork 589
292 lines (265 loc) · 11.1 KB
/
master-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
# Signs windows and macOS binaries and installers
name: Master branch build/release (signed)
defaults:
run:
shell: bash
on:
push:
branches: [ master, main ]
release:
types: [ created ]
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate set "debug_enabled"'
type: boolean
required: false
default: false
env:
BUILDKIT_PROGRESS: plain
DOCKER_CLI_EXPERIMENTAL: enabled
DDEV_DEBUG: true
GITHUB_REPOSITORY_OWNER: ${{ secrets.GITHUB_REPOSITORY_OWNER }}
DDEV_WINDOWS_SIGN: ${{ secrets.DDEV_WINDOWS_SIGN }}
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
jobs:
build-most:
name: Build DDEV executables except Windows
runs-on: ubuntu-22.04
env:
AmplitudeAPIKey: ${{ secrets.AMPLITUDE_API_KEY }}
steps:
- uses: actions/checkout@v4
with:
# We need to get all branches and tags for git describe to work properly
fetch-depth: 0
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Install Docker and deps
run: ./.github/workflows/linux-setup.sh
- name: Install build tools
run: ./.github/workflows/linux-build-setup.sh
- uses: actions/setup-go@v5
with:
go-version: '>=1.21'
- name: Build DDEV executables
run: make linux_amd64 linux_arm64 darwin_amd64 darwin_arm64 completions mkcert
- name: "Verify that instrumentation is working (Linux amd64)"
run: |
export PATH=".gotmp/bin/linux_amd64:$PATH"
echo "DDEV_NO_INSTRUMENTATION=${DDEV_NO_INSTRUMENTATION}"
if [ -z "${AmplitudeAPIKey}" ]; then echo "AmplitudeAPIKey is not set"; exit 1; fi
ddev config global --instrumentation-opt-in=true
ddev config global | grep instrumentation-opt-in=true
ddev version | grep -v "AmplitudeAPIKey is not available."
ddev config global --instrumentation-opt-in=false
- name: save build results to cache
uses: actions/cache@v4
with:
path: .gotmp/bin
key: ${{ github.sha }}-${{ github.ref }}-build-most
# This Windows self-hosted runner has to be set up with gnu tar and zstd.exe, or
# this step will fail to properly create the cache.
# Make sure gnu tar is the tar used here. System PATH should have C:\program files\gnu\usr\bin near top
# Get zstd.exe from https://github.com/facebook/zstd/releases - I put it into C:\program files\gnu\usr\bin
# so it would be in PATH
# See https://github.com/actions/cache/issues/580
# Run the Windows action with debug enabled to be able to see which tar is in use, etc.
sign-windows:
name: Build and Sign Windows binaries
runs-on: [ self-hosted, windows-signer ]
env:
AmplitudeAPIKey: ${{ secrets.AMPLITUDE_API_KEY }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build and sign windows binaries and installer
shell: bash
run: |
if [ "${DDEV_WINDOWS_SIGN}" != "true" ]; then echo "Warning: DDEV_WINDOWS_SIGN is not true"; fi
make windows_install
- name: Show github.ref
run: echo ${{ github.ref }}
- name: Build chocolatey on release
if: startsWith( github.ref, 'refs/tags/v1')
run: make chocolatey
- name: "Verify that intrumentation is working (Windows)"
run: |
export PATH=".gotmp/bin/windows_amd64:$PATH"
echo "DDEV_NO_INSTRUMENTATION=${DDEV_NO_INSTRUMENTATION}"
if [ -z "${AmplitudeAPIKey}" ]; then echo "AmplitudeAPIKey is not set"; exit 1; fi
ddev config global --instrumentation-opt-in=true
ddev config global | grep instrumentation-opt-in=true
ddev version | grep -v "AmplitudeAPIKey is not available."
ddev config global --instrumentation-opt-in=false
- name: Cache signed binaries
# After 3.0.5 they were using zstdmt which is not available on Windows
# See https://github.com/actions/cache/issues/891
# But trying again with @v3, 2023-02-18
uses: actions/cache@v4
with:
path: .gotmp/bin/windows_amd64
key: ${{ github.sha }}-${{ github.ref }}-signed-windows-binaries
enableCrossOsArchive: true
notarize-macos:
name: Sign and Notarize ddev on macOS
runs-on: macos-latest
needs: build-most
steps:
- name: "setup macOS"
run: |
brew install coreutils gnu-getopt jq
- uses: actions/checkout@v4
with:
# We need to get all branches and tags for git describe to work properly
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '>=1.21'
- name: restore build-most results from cache
uses: actions/cache@v4
id: buildmost
with:
path: .gotmp/bin
key: ${{ github.sha }}-${{ github.ref }}-build-most
fail-on-cache-miss: true
- name: test that buildmost cache was loaded
if: steps.buildmost.outputs.cache-hit != 'true'
run: exit 1
- name: Sign and notarize binaries (amd64 and arm64)
env:
DDEV_MACOS_SIGNING_PASSWORD: ${{ secrets.DDEV_MACOS_SIGNING_PASSWORD }}
DDEV_MACOS_APP_PASSWORD: ${{ secrets.DDEV_MACOS_APP_PASSWORD }}
TEAM_ID: "9HQ298V2BW"
run: |
set -o errexit -o pipefail
if [ -z "${DDEV_MACOS_SIGNING_PASSWORD}" ] ; then echo "DDEV_MACOS_SIGNING_PASSWORD is empty"; exit 1; fi
if [ -z "${DDEV_MACOS_APP_PASSWORD}" ] ; then echo "DDEV_MACOS_APP_PASSWORD is empty"; exit 1; fi
for item in .gotmp/bin/darwin*/ddev; do
echo "Signing and notarizing ${item} ..."
codesign --remove-signature "${item}" || true
curl -s https://raw.githubusercontent.com/ddev/signing_tools/master/macos_sign.sh | bash -s - --signing-password="${DDEV_MACOS_SIGNING_PASSWORD}" --cert-file=certfiles/ddev_developer_id_cert.p12 --cert-name="Developer ID Application: Localdev Foundation (9HQ298V2BW)" --target-binary="${item}"
curl -sSL -f https://raw.githubusercontent.com/ddev/signing_tools/master/macos_notarize.sh | bash -s - --app-specific-password=${DDEV_MACOS_APP_PASSWORD} --apple-id=notarizer@localdev.foundation --primary-bundle-id=com.ddev.ddev --target-binary="${item}"
done
- name: Save notarized binaries to cache
uses: actions/cache@v4
with:
path: .gotmp/bin/darwin*
key: ${{ github.sha }}-${{ github.ref }}-notarize-macos
artifacts:
name: Upload artifacts
runs-on: ubuntu-22.04
needs: [build-most, sign-windows, notarize-macos]
env:
DDEV_GITHUB_TOKEN: ${{ secrets.DDEV_GITHUB_TOKEN }}
CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}
steps:
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Restore build-most builds
uses: actions/cache@v4
id: buildmost
with:
path: .gotmp/bin
key: ${{ github.sha }}-${{ github.ref }}-build-most
enableCrossOsArchive: true
fail-on-cache-miss: true
- name: test that build-most was loaded
if: steps.buildmost.outputs.cache-hit != 'true'
run: exit 1
- name: Restore Signed Windows artifacts
uses: actions/cache@v4
id: signedwindows
with:
path: .gotmp/bin/windows_amd64
key: ${{ github.sha }}-${{ github.ref }}-signed-windows-binaries
enableCrossOsArchive: true
fail-on-cache-miss: true
- name: test that signed-windows was loaded
if: steps.signedwindows.outputs.cache-hit != 'true'
run: exit 1
- name: Restore Signed Mac artifacts
uses: actions/cache@v4
id: notarizedmac
with:
path: .gotmp/bin/darwin*
key: ${{ github.sha }}-${{ github.ref }}-notarize-macos
enableCrossOsArchive: true
fail-on-cache-miss: true
- name: test that notarizedmac was loaded
if: steps.notarizedmac.outputs.cache-hit != 'true'
run: exit 1
- name: "Verify that cgo_enabled is 0 in Linux binary"
run: |
.gotmp/bin/$(go env GOOS)_$(go env GOARCH)/ddev version
cgo=$(".gotmp/bin/$(go env GOOS)_$(go env GOARCH)/ddev" version 2>/dev/null | awk '/cgo_enabled/ {print $2}')
if [ "${cgo}" != "0" ]; then echo "CGO_ENABLED=${cgo} but it must be 0 in released binary" && exit 10; fi
# Goreleaser does GitHub release artifacts, homebrew, AUR, deb/rpm
- name: goreleaser
uses: goreleaser/goreleaser-action@v5
if: startsWith( github.ref, 'refs/tags/v1')
with:
distribution: goreleaser-pro
version: latest
args: release --clean
env:
CGO_ENABLED: 0
DOCKER_ORG: ddev
GITHUB_TOKEN: ${{ secrets.DDEV_GITHUB_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
FURY_ACCOUNT: ${{ secrets.FURY_ACCOUNT }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
AUR_STABLE_GIT_URL: ${{ secrets.AUR_STABLE_GIT_URL }}
AUR_EDGE_GIT_URL: ${{ secrets.AUR_EDGE_GIT_URL }}
# Do artifacts for upload to workflow URL
- name: Generate artifacts
run: ./.ci-scripts/generate_artifacts.sh ${{ github.workspace }}/artifacts
- name: Upload all artifacts
uses: actions/upload-artifact@v3
with:
name: all-ddev-executables
path: ${{ github.workspace }}/artifacts/*
- name: Upload macos-amd64 binary
uses: actions/upload-artifact@v3
with:
name: ddev-macos-amd64
path: .gotmp/bin/darwin_amd64/ddev
- name: Upload macos-arm64 binary
uses: actions/upload-artifact@v3
with:
name: ddev-macos-arm64
path: .gotmp/bin/darwin_arm64/ddev
- name: Upload linux-arm64 binary
uses: actions/upload-artifact@v3
with:
name: ddev-linux-arm64
path: .gotmp/bin/linux_arm64/ddev
- name: Upload linux-amd64 binary
uses: actions/upload-artifact@v3
with:
name: ddev-linux-amd64
path: .gotmp/bin/linux_amd64/ddev
- name: Upload windows_amd64 installer
uses: actions/upload-artifact@v3
with:
name: ddev-windows-amd64-installer
path: .gotmp/bin/windows_amd64/ddev_windows_installer*.exe
- name: Show github.ref
run: echo ${{ github.ref }}
- name: Chocolatey windows release
if: env.CHOCOLATEY_API_KEY != '' && startsWith( github.ref, 'refs/tags/v1')
run: |
pushd .gotmp/bin/windows_amd64/chocolatey
docker run --rm -v $PWD:/tmp/chocolatey -w /tmp/chocolatey linuturk/mono-choco push -s https://push.chocolatey.org/ --api-key "${CHOCOLATEY_API_KEY}"
popd