forked from nodefect/DG
-
Notifications
You must be signed in to change notification settings - Fork 1
278 lines (235 loc) · 9.5 KB
/
CI.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
name: CI
on: [push, pull_request]
jobs:
conventions:
name: Check style & commit msg conventions
runs-on: ubuntu-22.04
container:
image: "ubuntu:22.04"
steps:
- uses: actions/checkout@v1
with:
submodules: false
- name: Install prettier&commitlint dependencies
run: |
apt update
apt install --yes sudo
sudo apt install --yes --no-install-recommends git npm
# workaround for https://github.com/actions/runner/issues/2033
- name: ownership workaround
run: git config --global --add safe.directory '*'
- name: Check XAML style with prettier
run: |
sudo npm install --save-dev prettier @prettier/plugin-xml
./node_modules/.bin/prettier --xml-whitespace-sensitivity ignore --tab-width 4 --prose-wrap preserve --write '**/*.xaml'
git diff --exit-code
- name: Install .NET6
run: |
apt update && apt install --yes sudo
sudo apt install --yes --no-install-recommends curl dotnet6
- name: Check F# style with fantomless
run: |
dotnet new tool-manifest
dotnet tool install fantomless-tool --version 4.7.996
dotnet fantomless --recurse .
git diff --exit-code
- name: Check C# style with dotnet format
run: |
dotnet format whitespace ./src --folder
git diff --exit-code
- name: Check if gitPush1by1 was used
if: github.event_name == 'pull_request'
run: |
git clone https://github.com/nblockchain/conventions.git
rm -rf ./conventions/.git/
dotnet fsi ./conventions/scripts/detectNotUsingGitPush1by1.fsx
build-windows:
name: (Windows) Build Windows&Android Frontends
needs: conventions
runs-on: windows-2022
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 7.0.x
- name: Install Maui workload
run: dotnet workload install maui
- name: Build Frontend (Android)
run: dotnet build src\Frontend\Frontend.csproj --framework net7.0-android
build-macOS:
name: (macOS) Build+Test Android+iOS Frontends & Backend
needs: conventions
runs-on: macos-latest
steps:
# beware about using v2 because https://github.com/actions/checkout/issues/100
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 7.0.x
- name: Create DB
run: |
brew install postgresql@14
# NOTE: if the below command doesn't seem to launch pg service on your MacBook, try this instead: pg_ctl -D /usr/local/var/postgres start
brew services restart postgresql@14
brew link postgresql@14 --force
/usr/local/opt/postgresql@14/bin/createuser -s postgres
/usr/local/opt/postgresql@14/bin/createdb runintomedb
/usr/local/opt/postgresql@14/bin/psql -d runintomedb -a -q -f db/createDBCommands.sql
/usr/local/opt/postgresql@14/bin/psql -d postgres -c "ALTER USER postgres WITH PASSWORD 'localDevPassword';"
- name: Build backend
run: |
mkdir packages
dotnet restore backend.slnf
dotnet build backend.slnf
- name: Run tests
run: dotnet test tests/Backend.Tests
- name: Install Maui workload
run: dotnet workload install maui
- name: Build Frontend (Android)
run: dotnet build src/Frontend/Frontend.csproj --framework net7.0-android
- name: Build Frontend (iOS)
run: dotnet build src/Frontend/Frontend.csproj --framework net7.0-ios
build-linux-frontend-android:
name: (Linux) Build Android Frontend
needs: conventions
runs-on: ubuntu-22.04
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check for Secret availability
id: secret-check
# perform secret check & put boolean result as an output
shell: bash
run: |
if [ "${{ secrets.KEYSTORE_PASSWORD }}" != '' ]; then
echo "available=true" >> $GITHUB_OUTPUT;
else
echo "available=false" >> $GITHUB_OUTPUT;
fi
# beware about using v2 because https://github.com/actions/checkout/issues/100
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 7.0.x
# commented out because bump.fsx is based on stable(even) vs unstable(odd) numbers
# while this sanity check requires version numbers in sequence (for upcoming blue+green
# deployments based on blue=even,green=odd):
#- name: Version Sanity Check
# if: startsWith(github.ref, 'refs/tags/')
# run: dotnet fsi scripts/versionSanityCheck.fsx
- name: Install Maui workloads
run: sudo dotnet workload install maui-android
- name: Build Frontend (Android)
run: |
sudo dotnet build src/Frontend/Frontend.csproj \
--framework net7.0-android \
--configuration Debug \
-p:AndroidSdkDirectory=/usr/local/lib/android/sdk \
-p:AndroidOnly=true
- name: Publish Frontend (Android)
if: ${{ steps.secret-check.outputs.available == 'true' }}
run: |
sudo dotnet publish src/Frontend/Frontend.csproj \
--framework net7.0-android \
--configuration Release \
-p:AndroidSdkDirectory=/usr/local/lib/android/sdk \
-p:AndroidSigningKeyPass="${{ secrets.KEYSTORE_PASSWORD }}" \
-p:AndroidSigningStorePass="${{ secrets.KEYSTORE_PASSWORD }}" \
-p:AndroidOnly=true
# Upload artifact fails with "permission denied" error without this
- name: Fix permissions
if: ${{ steps.secret-check.outputs.available == 'true' }}
run: sudo chmod -R 755 src/Frontend/bin/Release/net7.0-android/publish
- uses: actions/upload-artifact@v3
if: ${{ steps.secret-check.outputs.available == 'true' }}
with:
name: publishedPackages
path: src/Frontend/bin/Release/net7.0-android/publish
# NOTE: if this step fails with "Resource not accessible by integration" then adjust permissions
# according to https://stackoverflow.com/a/75250838/1623521
- name: Create Release
id: create_release
if: startsWith(github.ref, 'refs/tags/')
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: Frontend
draft: false
prerelease: false
- name: Upload APK to Release
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: src/Frontend/bin/Release/net7.0-android/publish/com.nodeffect.dg-Signed.apk
asset_name: com.nodeffect.dg-Signed.apk
asset_content_type: application/vnd.android.package-archive
build-linux-backend:
name: (Linux) Build+Test Backend & Publish
needs: conventions
runs-on: ubuntu-22.04
container:
image: "ubuntu:22.04"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
# beware about using v2 because https://github.com/actions/checkout/issues/100
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Install .NET 6 and dependencies
run: |
apt update && apt install --yes sudo
sudo apt install --yes curl dotnet6 git ca-certificates
# workaround for https://github.com/actions/runner/issues/2033
- name: ownership workaround
run: git config --global --add safe.directory '*'
- name: Create DB
run: |
sudo DEBIAN_FRONTEND=noninteractive apt install postgresql --yes
sudo service postgresql start
sudo -u postgres createdb runintomedb
sudo -u postgres psql -d runintomedb -a -q -f db/createDBCommands.sql
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'localDevPassword';"
- name: Build backend
run: |
mkdir packages
dotnet restore backend.slnf
dotnet build backend.slnf
- name: Run tests
run: dotnet test tests/Backend.Tests
- name: Publish for linux
run: |
mkdir publish
# Create a platform-specific self-contained executable (no need to install .NET runtime on the target machine)
# More info: https://docs.microsoft.com/en-us/dotnet/core/deploying/
dotnet publish src/GrpcService/GrpcService.csproj -p:PublishSingleFile=true -r linux-x64 -c Release -o publish --self-contained true
# NOTE: if this step doesn't work, see https://stackoverflow.com/a/75250838/1623521
delete-old-artifacts-and-release-assets:
name: Delete artifacts from the previous commit old and release assets
needs:
- build-linux-backend
- build-linux-frontend-android
- build-windows
- build-macOS
runs-on: ubuntu-22.04
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Delete artifacts
run: ./scripts/delete_artifacts_from_previous_commit.fsx
- name: Delete release assets from tags older than the 2 newest ones
run: ./scripts/delete_assets_from_old_releases.fsx