-
Notifications
You must be signed in to change notification settings - Fork 2
305 lines (292 loc) · 12.5 KB
/
publish.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
name: Publish CLI & Engine
on:
push:
branches: ["main"]
tags: ["v**"]
# Run tests in a PR when an SDK has a default CLI version bump
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
paths:
- sdk/go/internal/engineconn/version.gen.go
- sdk/python/src/dagger/_engine/_version.py
- sdk/typescript/provisioning/default.ts
jobs:
publish:
if: ${{ github.repository == 'dagger/dagger' && github.event_name == 'push' }}
# Use our own Dagger runner when running in the dagger/dagger repo (including PRs)
runs-on: dagger-v0-11-6-16c-nvme
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"
cache-dependency-path: "ci/go.sum"
- name: "Publish Engine & CLI"
run: |
cd ci/mage
if [ $GITHUB_REF_NAME == 'main' ]; then
# this is a push to the main branch, publish to the commit we're at
go run main.go -w ../.. dagger:publish ${{ github.sha }}
else
# this is a tag push, publish to that tag
go run main.go -w ../.. dagger:publish ${{ github.ref_name }}
fi
env:
GH_ORG_NAME: ${{ vars.GH_ORG_NAME }}
GITHUB_TOKEN: ${{ secrets.RELEASE_DAGGER_CI_TOKEN }}
DAGGER_ENGINE_IMAGE: ${{ secrets.RELEASE_DAGGER_ENGINE_IMAGE }}
AWS_ACCESS_KEY_ID: ${{ secrets.RELEASE_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.RELEASE_AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.RELEASE_AWS_REGION }}
AWS_BUCKET: ${{ secrets.RELEASE_AWS_BUCKET }}
ARTEFACTS_FQDN: ${{ secrets.RELEASE_FQDN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_PRO_LICENSE_KEY }}
DAGGER_ENGINE_IMAGE_REGISTRY: ghcr.io
DAGGER_ENGINE_IMAGE_USERNAME: ${{ github.actor }}
DAGGER_ENGINE_IMAGE_PASSWORD: ${{ secrets.RELEASE_DAGGER_CI_TOKEN }}
_EXPERIMENTAL_DAGGER_RUNNER_HOST: "unix:///var/run/buildkit/buildkitd.sock"
- name: "Bump SDK Engine Dependencies"
uses: peter-evans/create-pull-request@v3
if: github.ref_name != 'main'
with:
add-paths: ./sdk/
committer: Dagger CI <[email protected]>
author: Dagger CI <[email protected]>
commit-message: "sdk: Bump engine dependency to ${{ github.ref_name }}"
signoff: true
base: main
title: "sdk: Bump engine dependency to ${{ github.ref_name }}"
body: |
This PR was auto-generated.
delete-branch: true
branch: bump-engine
draft: true
notify:
if: github.ref_type == 'tag'
needs: publish
uses: ./.github/workflows/_new_release_notification.yml
secrets: inherit
with:
message: "🚙 Engine + 🚗 CLI: https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }}"
scan-engine:
name: "Scan Engine Image for Vulnerabilities"
needs: publish
# only run this on push events, not in PRs (since we only publish images during pushes)
if: github.event_name == 'push' && github.repository == 'dagger/dagger'
uses: ./.github/workflows/_dagger_call.yml
secrets: inherit
with:
function: engine scan
test-provision-macos:
name: "Test SDK Provision / macos"
# We want to test the SDKs in a CLI dependency bump PR, in which case publish
# has to be skipped, AND after every push to main/tags, in which case publish
# must run first. This is unfortunately quite annoying to express in yaml...
# https://github.com/actions/runner/issues/491#issuecomment-850884422
needs: publish
if: |
always() &&
github.repository == 'dagger/dagger' &&
(needs.publish.result == 'success' || needs.publish.result == 'skipped')
runs-on: macos-12
steps:
- name: "Set CLI Test URL"
run: |
if [ ${{ github.event_name }} == 'push' ]; then
BASE_URL="https://${{ secrets.RELEASE_FQDN }}/dagger"
if [ $GITHUB_REF_NAME == 'main' ]; then
# this is a push to the main branch
ARCHIVE_URL="${BASE_URL}/main/${GITHUB_SHA}/dagger_${GITHUB_SHA}_darwin_amd64.tar.gz"
CHECKSUMS_URL="${BASE_URL}/main/${GITHUB_SHA}/checksums.txt"
RUNNER_HOST="docker-image://${{ secrets.RELEASE_DAGGER_ENGINE_IMAGE }}:${GITHUB_SHA}"
else
# this is a tag push
ARCHIVE_URL="${BASE_URL}/releases/${GITHUB_REF_NAME:1}/dagger_${GITHUB_REF_NAME}_darwin_amd64.tar.gz"
CHECKSUMS_URL="${BASE_URL}/releases/${GITHUB_REF_NAME:1}/checksums.txt"
RUNNER_HOST="docker-image://${{ secrets.RELEASE_DAGGER_ENGINE_IMAGE }}:${GITHUB_REF_NAME}"
fi
echo "_INTERNAL_DAGGER_TEST_CLI_URL=${ARCHIVE_URL}" >> $GITHUB_ENV
echo "_INTERNAL_DAGGER_TEST_CLI_CHECKSUMS_URL=${CHECKSUMS_URL}" >> $GITHUB_ENV
echo "_EXPERIMENTAL_DAGGER_RUNNER_HOST=${RUNNER_HOST}" >> $GITHUB_ENV
fi
shell: bash
- name: "Install Docker"
run: |
echo "Install docker CLI..."
brew install docker
echo "Start Docker daemon via Colima..."
echo "⚠️ Use mount-type 9p so that launched containers can chown: https://github.com/abiosoft/colima/issues/54#issuecomment-1250217077"
colima start --mount-type 9p
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: "Test Go SDK"
run: |
cd sdk/go
go test -v -run TestProvision ./...
- uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: "sdk/python/requirements.txt"
- name: "Test Python SDK"
run: |
cd sdk/python
pip install -r requirements.txt .
pytest -xm provision
- uses: actions/setup-node@v2
with:
node-version: 18
- uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.x
- name: "Test TypeScript SDK (Node)"
run: |
cd sdk/typescript
yarn install
yarn test:node -g 'Automatic Provisioned CLI Binary'
- name: "Test TypeScript SDK (Bun)"
run: |
cd sdk/typescript
yarn install
yarn test:bun -g 'Automatic Provisioned CLI Binary'
- name: "ALWAYS print engine logs - especially useful on failure"
if: always()
run: docker logs $(docker ps -q --filter name=dagger-engine)
test-provision-go-linux:
name: "Test SDK Provision / go / linux"
needs: publish
if: |
always() &&
github.repository == 'dagger/dagger' &&
(needs.publish.result == 'success' || needs.publish.result == 'skipped')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Set CLI Test URL"
run: |
if [ ${{ github.event_name }} == 'push' ]; then
BASE_URL="https://${{ secrets.RELEASE_FQDN }}/dagger"
if [ $GITHUB_REF_NAME == 'main' ]; then
# this is a push to the main branch
ARCHIVE_URL="${BASE_URL}/main/${GITHUB_SHA}/dagger_${GITHUB_SHA}_linux_amd64.tar.gz"
CHECKSUMS_URL="${BASE_URL}/main/${GITHUB_SHA}/checksums.txt"
RUNNER_HOST="docker-image://${{ secrets.RELEASE_DAGGER_ENGINE_IMAGE }}:${GITHUB_SHA}"
else
# this is a tag push
ARCHIVE_URL="${BASE_URL}/releases/${GITHUB_REF_NAME:1}/dagger_${GITHUB_REF_NAME}_linux_amd64.tar.gz"
CHECKSUMS_URL="${BASE_URL}/releases/${GITHUB_REF_NAME:1}/checksums.txt"
RUNNER_HOST="docker-image://${{ secrets.RELEASE_DAGGER_ENGINE_IMAGE }}:${GITHUB_REF_NAME}"
fi
echo "_INTERNAL_DAGGER_TEST_CLI_URL=${ARCHIVE_URL}" >> $GITHUB_ENV
echo "_INTERNAL_DAGGER_TEST_CLI_CHECKSUMS_URL=${CHECKSUMS_URL}" >> $GITHUB_ENV
echo "_EXPERIMENTAL_DAGGER_RUNNER_HOST=${RUNNER_HOST}" >> $GITHUB_ENV
fi
shell: bash
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: "Test Go SDK"
run: |
cd sdk/go
go test -v -run TestProvision ./...
- name: "ALWAYS print engine logs - especially useful on failure"
if: always()
run: docker logs $(docker ps -q --filter name=dagger-engine)
test-provision-python-linux:
name: "Test SDK Provision / python / linux"
needs: publish
if: |
always() &&
github.repository == 'dagger/dagger' &&
(needs.publish.result == 'success' || needs.publish.result == 'skipped')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Set CLI Test URL"
run: |
if [ ${{ github.event_name }} == 'push' ]; then
BASE_URL="https://${{ secrets.RELEASE_FQDN }}/dagger"
if [ $GITHUB_REF_NAME == 'main' ]; then
# this is a push to the main branch
ARCHIVE_URL="${BASE_URL}/main/${GITHUB_SHA}/dagger_${GITHUB_SHA}_linux_amd64.tar.gz"
CHECKSUMS_URL="${BASE_URL}/main/${GITHUB_SHA}/checksums.txt"
RUNNER_HOST="docker-image://${{ secrets.RELEASE_DAGGER_ENGINE_IMAGE }}:${GITHUB_SHA}"
else
# this is a tag push
ARCHIVE_URL="${BASE_URL}/releases/${GITHUB_REF_NAME:1}/dagger_${GITHUB_REF_NAME}_linux_amd64.tar.gz"
CHECKSUMS_URL="${BASE_URL}/releases/${GITHUB_REF_NAME:1}/checksums.txt"
RUNNER_HOST="docker-image://${{ secrets.RELEASE_DAGGER_ENGINE_IMAGE }}:${GITHUB_REF_NAME}"
fi
echo "_INTERNAL_DAGGER_TEST_CLI_URL=${ARCHIVE_URL}" >> $GITHUB_ENV
echo "_INTERNAL_DAGGER_TEST_CLI_CHECKSUMS_URL=${CHECKSUMS_URL}" >> $GITHUB_ENV
echo "_EXPERIMENTAL_DAGGER_RUNNER_HOST=${RUNNER_HOST}" >> $GITHUB_ENV
fi
shell: bash
- uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: "sdk/python/requirements.txt"
- name: "Test Python SDK"
run: |
cd sdk/python
pip install -r requirements.txt .
pytest -xm provision
- name: "ALWAYS print engine logs - especially useful on failure"
if: always()
run: docker logs $(docker ps -q --filter name=dagger-engine)
test-provision-typescript-linux:
name: "Test SDK Provision / TypeScript / linux"
needs: publish
if: |
always() &&
github.repository == 'dagger/dagger' &&
(needs.publish.result == 'success' || needs.publish.result == 'skipped')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Set CLI Test URL"
run: |
if [ ${{ github.event_name }} == 'push' ]; then
BASE_URL="https://${{ secrets.RELEASE_FQDN }}/dagger"
if [ $GITHUB_REF_NAME == 'main' ]; then
# this is a push to the main branch
ARCHIVE_URL="${BASE_URL}/main/${GITHUB_SHA}/dagger_${GITHUB_SHA}_linux_amd64.tar.gz"
CHECKSUMS_URL="${BASE_URL}/main/${GITHUB_SHA}/checksums.txt"
RUNNER_HOST="docker-image://${{ secrets.RELEASE_DAGGER_ENGINE_IMAGE }}:${GITHUB_SHA}"
else
# this is a tag push
ARCHIVE_URL="${BASE_URL}/releases/${GITHUB_REF_NAME:1}/dagger_${GITHUB_REF_NAME}_linux_amd64.tar.gz"
CHECKSUMS_URL="${BASE_URL}/releases/${GITHUB_REF_NAME:1}/checksums.txt"
RUNNER_HOST="docker-image://${{ secrets.RELEASE_DAGGER_ENGINE_IMAGE }}:${GITHUB_REF_NAME}"
fi
echo "_INTERNAL_DAGGER_TEST_CLI_URL=${ARCHIVE_URL}" >> $GITHUB_ENV
echo "_INTERNAL_DAGGER_TEST_CLI_CHECKSUMS_URL=${CHECKSUMS_URL}" >> $GITHUB_ENV
echo "_EXPERIMENTAL_DAGGER_RUNNER_HOST=${RUNNER_HOST}" >> $GITHUB_ENV
fi
shell: bash
- uses: actions/setup-node@v2
with:
node-version: 18
- uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.x
- name: "Test TypeScript SDK (Node)"
run: |
cd sdk/typescript
yarn install
yarn test:node -g 'Automatic Provisioned CLI Binary'
- name: "Test TypeScript SDK (Bun)"
run: |
cd sdk/typescript
yarn install
yarn test:bun -g 'Automatic Provisioned CLI Binary'
- name: "ALWAYS print engine logs - especially useful on failure"
if: always()
run: docker logs $(docker ps -q --filter name=dagger-engine)