-
-
Notifications
You must be signed in to change notification settings - Fork 157
318 lines (299 loc) · 9.97 KB
/
release.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
name: Release
env:
APP_NAME: moon
on:
# Manually release cli/core packages
workflow_dispatch:
# Test on master to ensure PRs are good
push:
branches:
- master
- develop-*
- release-*
# Every day at midnight (nightly)
schedule:
- cron: '0 0 * * *'
# Uncomment to test in PRs (its safe)
# pull_request:
# Required for depot!
permissions:
contents: write
id-token: write
jobs:
plan:
name: Plan release
runs-on: ubuntu-latest
outputs:
publish:
${{ github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ||
github.event_name == 'push' && contains(github.ref, 'develop-') }}
npm-channel: ${{ steps.plan-step.outputs.npm-channel }}
cli-version: ${{ steps.plan-step.outputs.cli-version }}
cli-version-base: ${{ steps.plan-step.outputs.cli-version-base }}
cli-version-build: ${{ steps.plan-step.outputs.cli-version-build }}
steps:
- uses: actions/checkout@v4
- id: plan-step
run: bash ./scripts/release/planRelease.sh
env:
CANARY: ${{ github.event_name == 'push' && contains(github.ref, 'develop-') }}
NIGHTLY: ${{ github.event_name == 'schedule' }}
# CANARY: true
build:
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
host: ubuntu-20.04
binary: moon
docker-target: bin-gnu
docker-platform: linux/amd64
- target: x86_64-unknown-linux-musl
host: ubuntu-20.04
binary: moon
docker-target: bin-musl
docker-platform: linux/amd64
- target: aarch64-unknown-linux-gnu
host: ubuntu-20.04
binary: moon
docker-target: bin-gnu
docker-platform: linux/arm64
- target: aarch64-unknown-linux-musl
host: ubuntu-20.04
binary: moon
docker-target: bin-musl
docker-platform: linux/arm64
- target: x86_64-apple-darwin
host: macos-12
binary: moon
# setup: |
# export MACOSX_DEPLOYMENT_TARGET="10.13";
- target: aarch64-apple-darwin
host: macos-12
binary: moon
# setup: |
# export CC=$(xcrun -f clang);
# export CXX=$(xcrun -f clang++);
# export SDKROOT=$(xcrun -sdk macosx --show-sdk-path);
# export CFLAGS="-isysroot $SDKROOT -isystem $SDKROOT";
# export MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version);
- target: x86_64-pc-windows-msvc
host: windows-2022
binary: moon.exe
needs:
- plan
name: Stable - ${{ matrix.target }}
runs-on: ${{ matrix.host }}
steps:
- uses: actions/checkout@v4
- uses: moonrepo/setup-rust@v1
if: ${{ !matrix.docker-target }}
with:
cache: false
targets: ${{ matrix.target }}
- name: Setup toolchain
if: ${{ matrix.setup }}
run: ${{ matrix.setup }}
- name: Build binary
if: ${{ !matrix.docker-target }}
run: bash ./scripts/release/buildBinary.sh
env:
BINARY: ${{ matrix.binary }}
TARGET: ${{ matrix.target }}
CLI_VERSION: ${{ needs.plan.outputs.cli-version }}
CLI_VERSION_BASE: ${{ needs.plan.outputs.cli-version-base }}
- name: Install Depot CLI
if: ${{ matrix.docker-target }}
uses: depot/setup-action@v1
- name: Build binary with Docker / Depot
if: ${{ matrix.docker-target }}
uses: depot/build-push-action@v1
with:
context: .
file: ./scripts/Dockerfile
target: ${{ matrix.docker-target }}
platforms: ${{ matrix.docker-platform }}
outputs: |
type=local,dest=.
- name: Prepare artifacts
run: bash ./scripts/release/prepareArtifacts.sh
env:
BINARY: ${{ matrix.binary }}
TARGET: ${{ matrix.target }}
- uses: actions/upload-artifact@v4
name: Upload artifact
with:
name: binary-${{ matrix.target }}
path: artifacts/${{ matrix.binary }}
if-no-files-found: error
schemas:
name: Generate JSON schemas
runs-on: ubuntu-20.04
needs:
- plan
steps:
- uses: actions/checkout@v4
- uses: moonrepo/setup-rust@v1
with:
bins: just
cache: false
- name: Generate schemas
run: just schemas
- name: Rename schemas
run: bash ./scripts/release/renameJsonSchemas.sh
- uses: actions/upload-artifact@v4
name: Upload schemas
with:
name: json-schemas
path: artifacts
if-no-files-found: error
test:
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
host: ubuntu-20.04
- target: x86_64-unknown-linux-musl
host: ubuntu-20.04
image: clux/muslrust:stable
setup: yarn config set supportedArchitectures.libc "musl"
- target: x86_64-apple-darwin
host: macos-12
- target: aarch64-apple-darwin
host: macos-14
- target: x86_64-pc-windows-msvc
host: windows-2022
needs:
- build
name: Test - ${{ matrix.target }}
runs-on: ${{ matrix.host }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Setup toolchain
if: ${{ matrix.setup }}
run: ${{ matrix.setup }}
- uses: actions/download-artifact@v4
name: Download artifacts
with:
path: artifacts
- name: Sync artifact binaries
run: node ./scripts/release/syncArtifacts.mjs
- name: List packages
run: ls -lR ./packages/cli ./packages/core-*
shell: bash
- name: Test binary
if: ${{ !matrix.image }}
run: bash ./scripts/release/testBinary.sh
env:
TARGET: ${{ matrix.target }}
- name: Test binary with Docker
if: ${{ matrix.image }}
uses: mosteo-actions/docker-run@v1
with:
image: ${{ matrix.image }}
params: -e TARGET=${{ matrix.target }}
command: bash ./scripts/release/testBinary.sh
publish:
if: ${{ needs.plan.outputs.publish == 'true' }}
name: Publish cli/core packages
runs-on: ubuntu-20.04
needs:
- plan
- schemas
- test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: yarn
check-latest: true
- name: Install dependencies
run: yarn install --immutable
- uses: actions/download-artifact@v4
name: Download artifacts
with:
path: artifacts
- name: Sync artifact binaries
run: node ./scripts/release/syncArtifacts.mjs
- name: List binaries
run: ls -lR ./artifacts/release ./packages/cli ./packages/core-*
shell: bash
- id: publish-step
name: Publish npm packages
run: bash ./scripts/release/publishBinaryPackages.sh
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CHANNEL: ${{ needs.plan.outputs.npm-channel }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
CLI_VERSION: ${{ needs.plan.outputs.cli-version }}
CLI_VERSION_BASE: ${{ needs.plan.outputs.cli-version-base }}
CLI_VERSION_BUILD: ${{ needs.plan.outputs.cli-version-build }}
- if:
${{ needs.plan.outputs.npm-channel == 'latest' || needs.plan.outputs.npm-channel == 'next'
}}
uses: ncipollo/release-action@v1
name: Create GitHub release
with:
artifactErrorsFailBuild: true
artifacts: artifacts/release/*
tag: ${{ steps.publish-step.outputs.npm-tag-name }}
prerelease: ${{ needs.plan.outputs.npm-channel == 'next' }}
skipIfReleaseExists: true
- if: ${{ needs.plan.outputs.npm-channel == 'canary' }}
uses: ncipollo/release-action@v1
name: Create GitHub release
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: artifacts/release/*
body: 'This canary release corresponds to the commit [${{ github.sha }}].'
name: 'Canary'
tag: 'canary'
prerelease: true
replacesArtifacts: true
skipIfReleaseExists: false
- if: ${{ needs.plan.outputs.npm-channel == 'nightly' }}
uses: ncipollo/release-action@v1
name: Create GitHub release
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: artifacts/release/*
body: 'This nightly release corresponds to the commit [${{ github.sha }}].'
name: 'Nightly'
tag: 'nightly'
prerelease: true
replacesArtifacts: true
skipIfReleaseExists: false
publish-npm:
if:
${{ needs.plan.outputs.publish == 'true' && (needs.plan.outputs.npm-channel == 'latest' ||
needs.plan.outputs.npm-channel == 'next') }}
needs:
- plan
name: Publish npm packages
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: yarn
check-latest: true
- name: Install dependencies
run: yarn install --immutable
- name: Build packages
run: bash ./scripts/release/buildPackages.sh
- name: Publish npm packages
run: bash ./scripts/release/publishPackages.sh
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CHANNEL: ${{ needs.plan.outputs.npm-channel }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
CLI_VERSION: ${{ needs.plan.outputs.cli-version }}
CLI_VERSION_BASE: ${{ needs.plan.outputs.cli-version-base }}
CLI_VERSION_BUILD: ${{ needs.plan.outputs.cli-version-build }}