-
-
Notifications
You must be signed in to change notification settings - Fork 31
709 lines (590 loc) · 31.8 KB
/
build-macos-release.yml
File metadata and controls
709 lines (590 loc) · 31.8 KB
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
name: Build macOS release
on:
workflow_dispatch:
inputs:
info:
description: "Here you can manually trigger the build. ➡️ It will automatically fetch the latest release tag. ➡️ Selecting branch 'main' will upload to the official Azure bucket. ➡️ Any other branch will upload to the beta-versions bucket."
required: false
default: "[dummy input field - no need to fill in]"
release:
types:
- published
jobs:
build-macos-release:
runs-on: macos-15
env:
BRANCH_NAME: ${{ github.event_name == 'release' && 'main' || github.ref_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get latest release tag
id: release_info
uses: pozetroninc/github-action-get-latest-release@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
- name: Set latest release tag to global
run: |
RELEASE_VERSION=${{ steps.release_info.outputs.release }}
echo RELEASE_VERSION: $RELEASE_VERSION
echo "RELEASE_VERSION=${{ steps.release_info.outputs.release }}" >> $GITHUB_ENV
- name: Set BUCKET_NAME based on chosen branch
run: |
echo "BRANCH_NAME is $BRANCH_NAME"
if [ "$BRANCH_NAME" = "main" ]; then
BUCKET_NAME="github-zips"
else
BUCKET_NAME="github-zips-beta"
fi
echo "BUCKET_NAME=$BUCKET_NAME" >> $GITHUB_ENV
echo "BUCKET_NAME is $BUCKET_NAME"
- name: Install Miniconda
run: |
mkdir "$HOME/miniforge"
curl --ipv4 -L "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh" -o miniforge.sh
bash miniforge.sh -b -u -p "$HOME/miniforge"
echo "succesfully installed at $HOME/miniforge"
- name: Build env-speciesnet
run: |
### set ipv4 settings
export PIP_NO_IPV6=1
export CONDA_SSL_VERIFY=0
export CONDA_USE_IPV4=1
### create folder structure
mkdir -p "${{ github.workspace }}/temp"
### source conda
source "$HOME/miniforge/etc/profile.d/conda.sh"
source "$HOME/miniforge/bin/activate"
conda_exe="$HOME/miniforge/bin/conda"
### set high timeout value and ip address for ipv4 fallback issues
$conda_exe config --set remote_connect_timeout_secs 120
$conda_exe config --set remote_max_retries 5
$conda_exe config --set remote_read_timeout_secs 120
$conda_exe config --set ssl_verify False
$conda_exe config --set fetch_threads 2
$conda_exe config --show
### install mamba
$conda_exe install mamba -n base -c conda-forge -y
conda_exe="$HOME/miniforge/bin/mamba"
### install env-speciesnet
$conda_exe create -p "${{ github.workspace }}/temp/env-speciesnet" python=3.11 -y
$conda_exe run -p "${{ github.workspace }}/temp/env-speciesnet" pip install --timeout=120 speciesnet --use-pep517
### clean
$conda_exe clean --all --yes --force-pkgs-dirs
$conda_exe clean --all --yes
### zip
cd "${{ github.workspace }}/temp"
tar -caf "env-speciesnet.tar.xz" "env-speciesnet"
### remove folder but keep .tar.xz
rm -r "env-speciesnet"
- name: Upload pinned version of env-speciesnet.tar.xz
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
connection_string: ${{ secrets.AZURE_CONNECTION_STRING }}
container_name: ${{ env.BUCKET_NAME }}
source_folder: ${{ github.workspace }}/temp
destination_folder: ${{ env.RELEASE_VERSION }}/macos/envs
is_recursive: false
delete_if_exists: true
- name: Upload latest version of env-speciesnet.tar.xz
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
connection_string: ${{ secrets.AZURE_CONNECTION_STRING }}
container_name: ${{ env.BUCKET_NAME }}
source_folder: ${{ github.workspace }}/temp
destination_folder: latest/macos/envs
is_recursive: false
delete_if_exists: true
- name: Remove env-speciesnet.tar.xz
run: |
rm "${{ github.workspace }}/temp/env-speciesnet.tar.xz"
rm -rf "${{ github.workspace }}/temp/"
- name: Build env-tensorflow-v1
run: |
### set ipv4 settings
export PIP_NO_IPV6=1
export CONDA_SSL_VERIFY=0
export CONDA_USE_IPV4=1
### create folder structure
mkdir -p "${{ github.workspace }}/temp"
### source conda
source "$HOME/miniforge/etc/profile.d/conda.sh"
source "$HOME/miniforge/bin/activate"
conda_exe="$HOME/miniforge/bin/conda"
### set high timeout value and ip address for ipv4 fallback issues
$conda_exe config --set remote_connect_timeout_secs 120
$conda_exe config --set remote_max_retries 5
$conda_exe config --set remote_read_timeout_secs 120
$conda_exe config --set ssl_verify False
$conda_exe config --set fetch_threads 2
$conda_exe config --show
### install mamba
$conda_exe install mamba -n base -c conda-forge -y
conda_exe="$HOME/miniforge/bin/mamba"
### get the yml file from url
curl -o tensorflow-macos-silicon.yml "https://raw.githubusercontent.com/PetervanLunteren/AddaxAI/main/classification_utils/envs/tensorflow-macos-silicon.yml"
### install env-tensorflow-v1
$conda_exe env create --file=tensorflow-macos-silicon.yml -p "${{ github.workspace }}/temp/env-tensorflow-v1"
### clean
$conda_exe clean --all --yes --force-pkgs-dirs
$conda_exe clean --all --yes
### zip
cd "${{ github.workspace }}/temp"
tar -caf "env-tensorflow-v1.tar.xz" "env-tensorflow-v1"
### remove folder but keep .tar.xz
rm -r "env-tensorflow-v1"
- name: Upload pinned version of env-tensorflow-v1.tar.xz
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
connection_string: ${{ secrets.AZURE_CONNECTION_STRING }}
container_name: ${{ env.BUCKET_NAME }}
source_folder: ${{ github.workspace }}/temp
destination_folder: ${{ env.RELEASE_VERSION }}/macos/envs
is_recursive: false
delete_if_exists: true
- name: Upload latest version of env-tensorflow-v1.tar.xz
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
connection_string: ${{ secrets.AZURE_CONNECTION_STRING }}
container_name: ${{ env.BUCKET_NAME }}
source_folder: ${{ github.workspace }}/temp
destination_folder: latest/macos/envs
is_recursive: false
delete_if_exists: true
- name: Remove env-tensorflow-v1.tar.xz
run: |
rm "${{ github.workspace }}/temp/env-tensorflow-v1.tar.xz"
rm -rf "${{ github.workspace }}/temp/"
- name: Build env-tensorflow-v2
run: |
### set ipv4 settings
export PIP_NO_IPV6=1
export CONDA_SSL_VERIFY=0
export CONDA_USE_IPV4=1
### create folder structure
mkdir -p "${{ github.workspace }}/temp"
### source conda
source "$HOME/miniforge/etc/profile.d/conda.sh"
source "$HOME/miniforge/bin/activate"
conda_exe="$HOME/miniforge/bin/conda"
### set high timeout value and ip address for ipv4 fallback issues
$conda_exe config --set remote_connect_timeout_secs 120
$conda_exe config --set remote_max_retries 5
$conda_exe config --set remote_read_timeout_secs 120
$conda_exe config --set ssl_verify False
$conda_exe config --set fetch_threads 2
$conda_exe config --show
### install mamba
$conda_exe install mamba -n base -c conda-forge -y
conda_exe="$HOME/miniforge/bin/mamba"
### install env-tensorflow-v2
$conda_exe create -p "${{ github.workspace }}/temp/env-tensorflow-v2" python=3.10 -y
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 huggingface_hub==0.23.0
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 jax==0.4.28
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 jaxlib==0.4.28
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 keras==3.3.3
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 keras_cv==0.9.0
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 kimm==0.2.5
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 matplotlib==3.9.0
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 numpy==1.26.4
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 pandas==2.2.2
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 pytest==8.3.0
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 pyyaml==6.0.1
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 scikit-learn==1.4.2
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 tqdm==4.66.4
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 jsonpickle==4.0.1
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 opencv-python==4.11.0.86
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 tensorflow-metal==1.1.0
$conda_exe run -p "${{ github.workspace }}/temp/env-tensorflow-v2" pip install --timeout=120 tensorflow-macos==2.16.2
### clean
$conda_exe clean --all --yes --force-pkgs-dirs
$conda_exe clean --all --yes
### zip
cd "${{ github.workspace }}/temp"
tar -caf "env-tensorflow-v2.tar.xz" "env-tensorflow-v2"
### remove folder but keep .tar.xz
rm -r "env-tensorflow-v2"
- name: Upload pinned version of env-tensorflow-v2.tar.xz
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
connection_string: ${{ secrets.AZURE_CONNECTION_STRING }}
container_name: ${{ env.BUCKET_NAME }}
source_folder: ${{ github.workspace }}/temp
destination_folder: ${{ env.RELEASE_VERSION }}/macos/envs
is_recursive: false
delete_if_exists: true
- name: Upload latest version of env-tensorflow-v2.tar.xz
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
connection_string: ${{ secrets.AZURE_CONNECTION_STRING }}
container_name: ${{ env.BUCKET_NAME }}
source_folder: ${{ github.workspace }}/temp
destination_folder: latest/macos/envs
is_recursive: false
delete_if_exists: true
- name: Remove env-tensorflow-v2.tar.xz
run: |
rm "${{ github.workspace }}/temp/env-tensorflow-v2.tar.xz"
rm -rf "${{ github.workspace }}/temp/"
- name: Build env-pytorch
run: |
### set ipv4 settings
export PIP_NO_IPV6=1
export CONDA_SSL_VERIFY=0
export CONDA_USE_IPV4=1
### create folder structure
mkdir -p "${{ github.workspace }}/temp"
### source conda
source "$HOME/miniforge/etc/profile.d/conda.sh"
source "$HOME/miniforge/bin/activate"
conda_exe="$HOME/miniforge/bin/conda"
### set high timeout value and ip address for ipv4 fallback issues
$conda_exe config --set remote_connect_timeout_secs 120
$conda_exe config --set remote_max_retries 5
$conda_exe config --set remote_read_timeout_secs 120
$conda_exe config --set ssl_verify False
$conda_exe config --set fetch_threads 2
$conda_exe config --show
### install mamba
$conda_exe install mamba -n base -c conda-forge -y
conda_exe="$HOME/miniforge/bin/mamba"
### install env-pytorch
$conda_exe create -p "${{ github.workspace }}/temp/env-pytorch" python=3.8 -y
$conda_exe run -p "${{ github.workspace }}/temp/env-pytorch" pip install --timeout=120 torch==2.0.1 torchvision==0.15.2
$conda_exe run -p "${{ github.workspace }}/temp/env-pytorch" pip install --timeout=120 "ultralytics==8.0.191"
$conda_exe run -p "${{ github.workspace }}/temp/env-pytorch" pip install --timeout=120 "numpy==1.24.1"
$conda_exe run -p "${{ github.workspace }}/temp/env-pytorch" pip install --timeout=120 "humanfriendly==10.0"
$conda_exe run -p "${{ github.workspace }}/temp/env-pytorch" pip install --timeout=120 "jsonpickle==3.0.2"
$conda_exe run -p "${{ github.workspace }}/temp/env-pytorch" pip install --timeout=120 timm
$conda_exe run -p "${{ github.workspace }}/temp/env-pytorch" pip install --timeout=120 dill
$conda_exe run -p "${{ github.workspace }}/temp/env-pytorch" pip install --timeout=120 omegaconf
$conda_exe run -p "${{ github.workspace }}/temp/env-pytorch" pip install --timeout=120 onnx2torch
$conda_exe run -p "${{ github.workspace }}/temp/env-pytorch" pip install --timeout=120 transformers
$conda_exe run -p "${{ github.workspace }}/temp/env-pytorch" pip install --timeout=120 "pytorch-lightning==2.0.6"
$conda_exe run -p "${{ github.workspace }}/temp/env-pytorch" pip install --timeout=120 "albumentations==1.3.1"
### clean
$conda_exe clean --all --yes --force-pkgs-dirs
$conda_exe clean --all --yes
### zip
cd "${{ github.workspace }}/temp"
tar -caf "env-pytorch.tar.xz" "env-pytorch"
### remove folder but keep .tar.xz
rm -r "env-pytorch"
- name: Upload pinned version of env-pytorch.tar.xz
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
connection_string: ${{ secrets.AZURE_CONNECTION_STRING }}
container_name: ${{ env.BUCKET_NAME }}
source_folder: ${{ github.workspace }}/temp
destination_folder: ${{ env.RELEASE_VERSION }}/macos/envs
is_recursive: false
delete_if_exists: true
- name: Upload latest version of env-pytorch.tar.xz
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
connection_string: ${{ secrets.AZURE_CONNECTION_STRING }}
container_name: ${{ env.BUCKET_NAME }}
source_folder: ${{ github.workspace }}/temp
destination_folder: latest/macos/envs
is_recursive: false
delete_if_exists: true
- name: Remove env-pytorch.tar.xz
run: |
rm "${{ github.workspace }}/temp/env-pytorch.tar.xz"
rm -rf "${{ github.workspace }}/temp/"
- name: Build env-pywildlife
run: |
### set ipv4 settings
export PIP_NO_IPV6=1
export CONDA_SSL_VERIFY=0
export CONDA_USE_IPV4=1
### create folder structure
mkdir -p "${{ github.workspace }}/temp"
### source conda
source "$HOME/miniforge/etc/profile.d/conda.sh"
source "$HOME/miniforge/bin/activate"
conda_exe="$HOME/miniforge/bin/conda"
### set high timeout value and ip address for ipv4 fallback issues
$conda_exe config --set remote_connect_timeout_secs 120
$conda_exe config --set remote_max_retries 5
$conda_exe config --set remote_read_timeout_secs 120
$conda_exe config --set ssl_verify False
$conda_exe config --set fetch_threads 2
$conda_exe config --show
### install mamba
$conda_exe install mamba -n base -c conda-forge -y
conda_exe="$HOME/miniforge/bin/mamba"
### install env-pywildlife
$conda_exe create -p "${{ github.workspace }}/temp/env-pywildlife" python=3.8 -y
$conda_exe run -p "${{ github.workspace }}/temp/env-pywildlife" pip install --timeout=180 --no-cache-dir --use-deprecated=legacy-resolver "pytorchwildlife==1.2.0"
$conda_exe run -p "${{ github.workspace }}/temp/env-pywildlife" pip install --timeout=120 "setuptools<70"
$conda_exe run -p "${{ github.workspace }}/temp/env-pywildlife" pip install --timeout=120 jsonpickle
### clean
$conda_exe clean --all --yes --force-pkgs-dirs
$conda_exe clean --all --yes
### zip
cd "${{ github.workspace }}/temp"
tar -caf "env-pywildlife.tar.xz" "env-pywildlife"
### remove folder but keep .tar.xz
rm -r "env-pywildlife"
- name: Upload pinned version of env-pywildlife.tar.xz
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
connection_string: ${{ secrets.AZURE_CONNECTION_STRING }}
container_name: ${{ env.BUCKET_NAME }}
source_folder: ${{ github.workspace }}/temp
destination_folder: ${{ env.RELEASE_VERSION }}/macos/envs
is_recursive: false
delete_if_exists: true
- name: Upload latest version of env-pywildlife.tar.xz
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
connection_string: ${{ secrets.AZURE_CONNECTION_STRING }}
container_name: ${{ env.BUCKET_NAME }}
source_folder: ${{ github.workspace }}/temp
destination_folder: latest/macos/envs
is_recursive: false
delete_if_exists: true
- name: Remove env-pywildlife.tar.xz
run: |
rm "${{ github.workspace }}/temp/env-pywildlife.tar.xz"
rm -rf "${{ github.workspace }}/temp/"
- name: Build base install
run: |
### log release version used
echo "Using tag name ${{ env.RELEASE_VERSION }}"
### refresh root
root="$HOME/base-install/AddaxAI_files"
if [ -d "${root}" ]; then
rm -rf "${root}"
echo "$root folder removed"
else
echo "$root folder does not exist"
fi
### set ipv4 settings
export PIP_NO_IPV6=1
export CONDA_SSL_VERIFY=0
export CONDA_USE_IPV4=1
### create folder structure
mkdir -p "${root}"
mkdir -p "${root}/envs"
mkdir -p "${root}/models"
mkdir -p "${root}/models/det"
mkdir -p "${root}/models/cls"
mkdir -p "${root}/models/det/MegaDetector 5a"
mkdir -p "${root}/yolov5_versions/yolov5_old"
mkdir -p "${root}/yolov5_versions/yolov5_new"
echo "Hello world!" >> "${root}/first-startup.txt"
## clone repositories
git clone --ipv4 --depth 1 --branch $BRANCH_NAME https://github.com/PetervanLunteren/AddaxAI.git "${root}/AddaxAI"
rm -rf "${root}/AddaxAI/.git"
mv "${root}/AddaxAI/main.py" "${root}/main.py"
RAW_VERSION=${{ env.RELEASE_VERSION }}
CLEAN_VERSION="${RAW_VERSION#v}"
echo "$CLEAN_VERSION" > "${root}/AddaxAI/version.txt"
echo "AddaxAI cloned"
git clone --ipv4 https://github.com/agentmorris/MegaDetector.git "${root}/MegaDetector"
git -C "${root}/MegaDetector" checkout a64a8f8c467ae6c87b5ca09f54b1abe502168b50
rm -rf "${root}/MegaDetector/.git"
mv "${root}/MegaDetector" "${root}/cameratraps"
echo "MegaDetector cloned"
git clone --ipv4 https://github.com/ultralytics/yolov5.git "${root}/yolov5_versions/yolov5_old/yolov5"
git -C "${root}/yolov5_versions/yolov5_old/yolov5" checkout 868c0e9bbb45b031e7bfd73c6d3983bcce07b9c1
rm -rf "${root}/yolov5_versions/yolov5_old/yolov5/.git"
echo "yolov5 old version cloned"
git clone --ipv4 https://github.com/ultralytics/yolov5.git "${root}/yolov5_versions/yolov5_new/yolov5"
git -C "${root}/yolov5_versions/yolov5_new/yolov5" checkout 3e55763d45f9c5f8217e4dad5ba1e6c1f42e3bf8
rm -rf "${root}/yolov5_versions/yolov5_new/yolov5/.git"
echo "yolov5 new version cloned"
git clone --ipv4 --branch pyside6 --depth 1 https://github.com/PetervanLunteren/Human-in-the-loop.git "${root}/Human-in-the-loop"
rm -rf "${root}/Human-in-the-loop/.git"
echo "Human-in-the-loop cloned"
git clone --ipv4 --depth 1 https://github.com/PetervanLunteren/visualise_detection.git "${root}/visualise_detection"
rm -rf "${root}/visualise_detection/.git"
echo "visualise_detection cloned"
### download megadetector
curl --ipv4 -L https://github.com/agentmorris/MegaDetector/releases/download/v5.0/md_v5a.0.0.pt -o "${root}/models/det/MegaDetector 5a/md_v5a.0.0.pt"
### source conda
source "$HOME/miniforge/etc/profile.d/conda.sh"
source "$HOME/miniforge/bin/activate"
conda_exe="$HOME/miniforge/bin/conda"
### set high timeout value and ip address for ipv4 fallback issues
$conda_exe config --set remote_connect_timeout_secs 120
$conda_exe config --set remote_max_retries 5
$conda_exe config --set remote_read_timeout_secs 120
$conda_exe config --set ssl_verify False
$conda_exe config --set fetch_threads 2
$conda_exe config --show
### install mamba
$conda_exe install mamba -n base -c conda-forge -y
conda_exe="$HOME/miniforge/bin/mamba"
### install env-base
$conda_exe env create --file="${root}/cameratraps/envs/environment-detector-m1.yml" -p "${root}/envs/env-base"
$conda_exe run -p "${root}/envs/env-base" conda install pytorch==1.13.1 torchvision==0.14.1 -c pytorch -y
$conda_exe run -p "${root}/envs/env-base" conda uninstall opencv -y
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 opencv-python
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 RangeSlider
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 gpsphoto
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 exifread
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 piexif
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 openpyxl
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 customtkinter
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 CTkTable
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 folium
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 plotly
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 "gitpython>=3.1.30"
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 "tensorboard>=2.4.1"
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 "thop>=0.1.1"
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 "protobuf<=3.20.1"
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 "setuptools>=65.5.1"
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 PySide6
$conda_exe run -p "${root}/envs/env-base" pip install --timeout=120 dill
$conda_exe run -p "${root}/envs/env-base" conda install lxml -y
$conda_exe run -p "${root}/envs/env-base" conda install -c conda-forge libgfortran5 -y
"${root}/envs/env-base/bin/pyside6-rcc" -o "${root}/Human-in-the-loop/libs/resources.py" "${root}/Human-in-the-loop/resources.qrc"
### run pyinstaller from fresh environment
$conda_exe create -p "$HOME/miniforge/envs/env-fresh" python=3.8 pyinstaller -y
$conda_exe run -p "$HOME/miniforge/envs/env-fresh" pyinstaller --onefile --windowed --icon="${root}/AddaxAI/imgs/logo_small_bg.icns" --distpath="${HOME}/dist" --workpath="${HOME}/build" "${root}/main.py"
### clean
$conda_exe clean --all --yes --force-pkgs-dirs
$conda_exe clean --all --yes
### move and rename executables
mv "${HOME}/dist/main" "${root}/AddaxAI debug" # debug executable
mv "${HOME}/dist/main.app" "${root}/AddaxAI.app" # main app executable
### zip folder contents
cd "$HOME/base-install"
tar -caf "base-install.tar.xz" AddaxAI_files
### remove folder contents
rm -rf "AddaxAI_files"
- name: Set env.HOME variable
run: |
echo "HOME=$HOME" >> $GITHUB_ENV
echo "HOME is $HOME"
- name: Uploading pinned version of base install
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
connection_string: ${{ secrets.AZURE_CONNECTION_STRING }}
container_name: ${{ env.BUCKET_NAME }}
source_folder: ${{ env.HOME }}/base-install
destination_folder: ${{ env.RELEASE_VERSION }}/macos
is_recursive: false
delete_if_exists: true
- name: Uploading latest version of base install
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
connection_string: ${{ secrets.AZURE_CONNECTION_STRING }}
container_name: ${{ env.BUCKET_NAME }}
source_folder: ${{ env.HOME }}/base-install
destination_folder: latest/macos
is_recursive: false
delete_if_exists: true
# - name: Get the release body
# id: get_release
# run: |
# release=$(gh release view ${{ github.ref_name }} --json body -q .body)
# echo "$release" > release_body.txt
# - name: Append link to release body
# id: append_link
# run: |
# new_body="$(cat release_body.txt)
# - Install for **macOS** (Apple Silicon - M1, M2, M3, etc.): [macos-${{ env.RELEASE_VERSION }}.tar.xz](https://storage.googleapis.com/${{ env.BUCKET_NAME }}/${{ env.RELEASE_VERSION }}/macos-${{ env.RELEASE_VERSION }}.tar.xz)"
# echo "$new_body" > new_release_body.txt
# - name: Update the release body
# run: |
# gh release edit ${{ github.ref_name }} --notes "$(cat new_release_body.txt)"
- name: Install Platypus
run: |
# copy files into the right directory
sudo mkdir -p '/usr/local/share/platypus/'
sudo cp "${{ github.workspace }}/install_files/macos/ScriptExec" '/usr/local/share/platypus/'
sudo cp "${{ github.workspace }}/install_files/macos/platypus_clt" '/usr/local/share/platypus/'
sudo cp -r "${{ github.workspace }}/install_files/macos/MainMenu.nib" '/usr/local/share/platypus/'
# make executable
sudo chmod +x '/usr/local/share/platypus/ScriptExec'
sudo chmod +x '/usr/local/share/platypus/platypus_clt'
- name: Append VERSION and URL to Platypus Installer Script
shell: bash
run: |
# Define the file path
FILE_PATH="${{ github.workspace }}/install_files/macos/platypus-install-compiler.sh"
# Create a new file with the VERSION line
echo "VERSION=\"${{ env.RELEASE_VERSION }}\"" > newFile.sh
# Append the URL line
echo "URL=\"https://addaxaipremiumstorage.blob.core.windows.net/${{ env.BUCKET_NAME }}/${{ env.RELEASE_VERSION }}/macos/base-install.tar.xz\"" >> newFile.sh
# Append the original file's content
cat "$FILE_PATH" >> newFile.sh
# Replace the original file with the new file
mv newFile.sh "$FILE_PATH"
- name: Create Installer
run: |
sudo '/usr/local/share/platypus/platypus_clt' --app-icon '${{ github.workspace }}/install_files/macos/logo.icns' --name 'AddaxAI-${{ env.RELEASE_VERSION }}-installer' --interface-type 'Progress Bar' --interpreter '/bin/bash' --app-version '${{ env.RELEASE_VERSION }}' '${{ github.workspace }}/install_files/macos/platypus-install-compiler.sh'
- name: Compress the macOS installer
run: |
cd "${{ github.workspace }}/install_files/macos"
zip -r "MacOS-installer.zip" "AddaxAI-${{ env.RELEASE_VERSION }}-installer.app"
# copy to a private dir so that it can be uploaded with Action-AzureBlobUpload@v2
mkdir -p temp
mv "MacOS-installer.zip" temp/
- name: Get Upload URL for Release
if: ${{ env.BRANCH_NAME == 'main' }}
id: get_upload_url
uses: actions/github-script@v6
with:
script: |
const release = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: '${{ env.RELEASE_VERSION }}',
});
// Write the upload URL to the environment file
const fs = require('fs');
fs.appendFileSync(process.env.GITHUB_ENV, `UPLOAD_URL=${release.data.upload_url}\n`);
- name: Authenticate GitHub CLI
if: ${{ env.BRANCH_NAME == 'main' }}
run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
- name: Remove existing asset if present
if: ${{ env.BRANCH_NAME == 'main' }}
run: |
# List all assets in the release
release_info=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.RELEASE_VERSION }}
)
# Extract asset ID by matching the name
asset_id=$(echo $release_info | jq -r '.assets[] | select(.name == "MacOS-installer-${{ env.RELEASE_VERSION }}.zip") | .id')
echo "asset_id is $asset_id"
# Check if the asset exists and delete it
if [ ! -z "$asset_id" ]; then
curl -X DELETE \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/assets/$asset_id"
else
echo "Asset not found. Continue with upload..."
fi
- name: Upload Asset to GitHub Release
if: ${{ env.BRANCH_NAME == 'main' }}
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: "${{ github.workspace }}/install_files/macos/temp/MacOS-installer.zip"
asset_name: "MacOS-installer-${{ env.RELEASE_VERSION }}.zip"
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Uploading pinned version of installer app
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
connection_string: ${{ secrets.AZURE_CONNECTION_STRING }}
container_name: ${{ env.BUCKET_NAME }}
source_folder: ${{ github.workspace }}/install_files/macos/temp
destination_folder: ${{ env.RELEASE_VERSION }}/macos
is_recursive: false
delete_if_exists: true
- name: Uploading latest version of installer app
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
connection_string: ${{ secrets.AZURE_CONNECTION_STRING }}
container_name: ${{ env.BUCKET_NAME }}
source_folder: ${{ github.workspace }}/install_files/macos/temp
destination_folder: latest/macos
is_recursive: false
delete_if_exists: true