-
Notifications
You must be signed in to change notification settings - Fork 13
269 lines (239 loc) · 11.1 KB
/
deploy.synnax.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
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
name: Deploy - Synnax
on:
push:
branches:
- rc
- main
pull_request:
branches:
- rc
- main
workflow_dispatch:
permissions:
contents: write
packages: write
jobs:
setup:
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.version.outputs.VERSION }}
changed: ${{ steps.filter.outputs.changed }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Get Version
id: version
working-directory: ./synnax
run: |
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then
echo "VERSION=$(cat pkg/version/VERSION)" >> $GITHUB_OUTPUT
else
echo "VERSION=$(cat pkg/version/VERSION)-rc" >> $GITHUB_OUTPUT
fi
- name: Diff Changes
uses: dorny/paths-filter@v3
id: filter
with:
base: ${{ github.ref }}
filters: |
changed:
- 'synnax/**'
- 'cesium/**'
- 'x/**'
- 'aspen/**'
- 'freighter/go/**'
- 'driver/**'
- '.github/workflows/deploy.synnax.yaml'
create-release:
runs-on: ubuntu-latest
needs: setup
if: github.event_name == 'push' && needs.setup.outputs.changed == 'true'
steps:
- name: Create Release
uses: actions/github-script@v6
with:
script: |
const { data: releases } = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo
})
const release = releases.find(r => r.tag_name === 'synnax-v${{ needs.setup.outputs.VERSION }}')
if (release != null) return release.id
const { data: { id } } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: 'synnax-v${{ needs.setup.outputs.VERSION }}',
name: 'Synnax v${{ needs.setup.outputs.VERSION }}',
draft: false,
prerelease: false
});
build:
needs: setup
strategy:
fail-fast: false
matrix:
platform: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout Repository
if: needs.setup.outputs.changed == 'true'
uses: actions/checkout@v3
- uses: GuillaumeFalourd/setup-windows10-sdk-action@v2
if: matrix.platform == 'windows-latest' && needs.setup.outputs.changed == 'true'
with:
sdk-version: 22000
- name: Build MbedTLS On Windows
if: matrix.platform == 'windows-latest' && needs.setup.outputs.changed == 'true'
shell: bash
run: |
curl -LO https://github.com/Mbed-TLS/mbedtls/releases/download/v3.6.0/mbedtls-3.6.0.tar.bz2
tar -xjf mbedtls-3.6.0.tar.bz2
mv mbedtls-3.6.0 mbedtls
cmake -G "Visual Studio 17 2022" -S mbedtls -B mbedtls-build
cmake --build mbedtls-build --config Release
cmake --install mbedtls-build --config Release
cmake --install mbedtls-build --config Release --prefix mbedtls-install
working-directory: driver/vendor/mbedtls
- name: Install MbedTLS On Mac
if: matrix.platform == 'macos-latest' && needs.setup.outputs.changed == 'true'
run: brew install mbedtls
- name: Install MbedTLS On Ubuntu
if: matrix.platform == 'ubuntu-latest' && needs.setup.outputs.changed == 'true'
run: |
sudo apt-get install -y libmbedtls-dev
- name: Update Submodules
if: needs.setup.outputs.changed == 'true'
run: git submodule update --init --recursive
- name: Setup Bazel
if: needs.setup.outputs.changed == 'true'
uses: bazel-contrib/setup-bazel@0.8.1
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
- name: Build Open65421 on Windows
if: matrix.platform == 'windows-latest' && needs.setup.outputs.changed == 'true'
shell: bash
run: |
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUA_NAMESPACE_ZERO=FULL -DCMAKE_INSTALL_PREFIX=../out -DUA_ENABLE_ENCRYPTION=MBEDTLS -DMBEDTLS_LIBRARY="C:\Program Files (x86)\Mbed TLS\lib\mbedtls.lib" -DMBEDX509_LIBRARY="C:\Program Files (x86)\Mbed TLS\lib\mbedx509.lib" -DMBEDCRYPTO_LIBRARY="C:\Program Files (x86)\Mbed TLS\lib\mbedcrypto.lib" -DMBEDTLS_INCLUDE_DIRS="C:\Program Files (x86)\Mbed TLS\include" -DCMAKE_OSX_ARCHITECTURES=x86_64 ..
cmake --build . --config RelWithDebInfo --target install
working-directory: driver/vendor/open62541/open62541
- name: Build Open62541 on Mac and Ubuntu
if: (matrix.platform == 'macos-latest' || matrix.platform == 'ubuntu-latest') && needs.setup.outputs.changed == 'true'
shell: bash
run: |
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUA_NAMESPACE_ZERO=FULL -DCMAKE_INSTALL_PREFIX=../out -DUA_ENABLE_ENCRYPTION=MBEDTLS ..
cmake --build . --config RelWithDebInfo --target install
working-directory: driver/vendor/open62541/open62541
- name: Build Driver on Windows
if: matrix.platform == 'windows-latest' && needs.setup.outputs.changed == 'true'
run: bazel --output_user_root=C:/tmp build --enable_platform_specific_config //driver:driver_main --define use_ni=true
- name: Build Driver on on Mac and Ubuntu
if: matrix.platform != 'windows-latest' && needs.setup.outputs.changed == 'true'
run: bazel build --enable_platform_specific_config //driver:driver_main --define use_ni=false
- name: Upload Release Asset for Driver Symbols
if: matrix.platform == 'windows-latest' && github.event_name == 'push' && needs.setup.outputs.changed == 'true'
env:
GITHUB_TOKEN: ${{ github.token }}
run: gh release upload --clobber synnax-v${{ needs.setup.outputs.VERSION }} bazel-bin/driver/driver_main.pdb
- name: Determine Executable Name
id: executable
if: needs.setup.outputs.changed == 'true'
shell: bash
run: |
if [ "${{ matrix.platform }}" = "macos-latest" ]; then
echo "EXECUTABLE=" >> $GITHUB_OUTPUT
elif [ "${{ matrix.platform }}" = "ubuntu-latest" ]; then
echo "EXECUTABLE=" >> $GITHUB_OUTPUT
elif [ "${{ matrix.platform }}" = "windows-latest" ]; then
echo "EXECUTABLE=.exe" >> $GITHUB_OUTPUT
fi
- name: Move Driver
if: needs.setup.outputs.changed == 'true'
run: mv bazel-bin/driver/driver_main${{ steps.executable.outputs.EXECUTABLE }} synnax/pkg/hardware/embedded/assets/
- name: Rename Driver
if: needs.setup.outputs.changed == 'true'
run: mv synnax/pkg/hardware/embedded/assets/driver_main${{ steps.executable.outputs.EXECUTABLE }} synnax/pkg/hardware/embedded/assets/driver${{ steps.executable.outputs.EXECUTABLE }}
- name: Set up Go
if: needs.setup.outputs.changed == 'true'
uses: actions/setup-go@v5
with:
go-version-file: "go.work"
cache-dependency-path: |
"alamos/go/go.sum"
"aspen/go.sum"
"cesium/go.sum"
"freighter/go/go.sum"
"synnax/go.sum"
"x/go/go.sum"
- name: Download Dependencies
if: needs.setup.outputs.changed == 'true'
working-directory: ./synnax
run: |
go mod download
- name: Determine OS
id: os
shell: bash
run: |
if [ "${{ matrix.platform }}" = "macos-latest" ]; then
echo "OS=macos" >> $GITHUB_OUTPUT
elif [ "${{ matrix.platform }}" = "ubuntu-latest" ]; then
echo "OS=linux" >> $GITHUB_OUTPUT
elif [ "${{ matrix.platform }}" = "windows-latest" ]; then
echo "OS=windows" >> $GITHUB_OUTPUT
fi
- name: Build
if: needs.setup.outputs.changed == 'true'
working-directory: ./synnax
run: |
go build -tags driver -o synnax-v${{ needs.setup.outputs.VERSION }}-${{ steps.os.outputs.OS }}
- name: Upload Release Asset
if: github.event_name == 'push' && needs.setup.outputs.changed == 'true'
env:
GITHUB_TOKEN: ${{ github.token }}
run: gh release upload --clobber synnax-v${{ needs.setup.outputs.VERSION }} ./synnax/synnax-v${{ needs.setup.outputs.VERSION }}-${{ steps.os.outputs.OS }}
- name: Download Latest Earthly
if: (matrix.platform == 'ubuntu-latest') && (needs.setup.outputs.changed == 'true') && github.event_name == 'push'
uses: earthly/actions-setup@v1
- name: Login to Docker Hub
if: (matrix.platform == 'ubuntu-latest') && (needs.setup.outputs.changed == 'true') && github.event_name == 'push'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Github Container Registry
if: (matrix.platform == 'ubuntu-latest') && (needs.setup.outputs.changed == 'true') && github.event_name == 'push'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Image
if: (matrix.platform == 'ubuntu-latest') && (needs.setup.outputs.changed == 'true') && github.event_name == 'push'
run: earthly --push +docker -tag=${{ needs.setup.outputs.VERSION }}
working-directory: ./synnax
- name: Push to Github Container Registry
if: (matrix.platform == 'ubuntu-latest') && (needs.setup.outputs.changed == 'true') && github.event_name == 'push'
run: |
docker push ghcr.io/synnaxlabs/synnax:${{ needs.setup.outputs.VERSION }}
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
docker tag ghcr.io/synnaxlabs/synnax:${{ needs.setup.outputs.VERSION }} ghcr.io/synnaxlabs/synnax:latest
docker push ghcr.io/synnaxlabs/synnax:latest
elif [ "${{ github.ref }}" = "refs/heads/rc" ]; then
docker tag ghcr.io/synnaxlabs/synnax:${{ needs.setup.outputs.VERSION }} ghcr.io/synnaxlabs/synnax:rc
docker push ghcr.io/synnaxlabs/synnax:rc
fi
- name: Push to Docker Hub
if: (matrix.platform == 'ubuntu-latest') && (needs.setup.outputs.changed == 'true') && github.event_name == 'push'
run: |
docker tag ghcr.io/synnaxlabs/synnax:${{ needs.setup.outputs.VERSION }} synnaxlabs/synnax:${{ needs.setup.outputs.VERSION }}
docker push synnaxlabs/synnax:${{ needs.setup.outputs.VERSION }}
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
docker tag ghcr.io/synnaxlabs/synnax:${{ needs.setup.outputs.VERSION }} synnaxlabs/synnax:latest
docker push synnaxlabs/synnax:latest
elif [ "${{ github.ref }}" = "refs/heads/rc" ]; then
docker tag ghcr.io/synnaxlabs/synnax:${{ needs.setup.outputs.VERSION }} synnaxlabs/synnax:rc
docker push synnaxlabs/synnax:rc
fi