Browse code

Reuse old artifacts if no solar build computers are reachable.

Non-Linux builds are run on computers powered by solar panels in one
geographical location, so they are not available 100% of the time. When
they are not available, the build script will reuse the previous build
artifacts for Windows and macOS, as well as create an empty file at
https://rabbits.srht.site/uxn/needs-solar-build so that this situation
can be detected. When both build computers are available, the
needs-solar-build file will not be present in the Sourcehut upload, so
that URL will return a 404 status.

Andrew Alderwick authored on 20/09/2022 11:48:27
Showing 1 changed files
... ...
@@ -4,6 +4,7 @@ packages:
4 4
     - build-essential
5 5
     - libsdl2-dev
6 6
     - rsync
7
+    - wget
7 8
     - zip
8 9
 oauth: pages.sr.ht/PAGES:RW
9 10
 environment:
... ...
@@ -45,13 +46,24 @@ tasks:
45 46
         done
46 47
         [ -e ~/.ssh/id_rsa ] || complete-build
47 48
     - build-windows: |
48
-        ssh win "export PATH=\"\${PATH}:/mingw64/bin\"; set -ex; cd uxn; git fetch; git checkout .; git clean -xfd; git checkout $(cd uxn && git rev-parse HEAD); MSYSTEM=MSYS ./build.sh --no-run"
49
-        rsync -rp win:uxn/bin/ build/uxn-win64/uxn/
49
+        if ssh win true; then
50
+            ssh win "export PATH=\"\${PATH}:/mingw64/bin\"; set -ex; cd uxn; git fetch; git checkout .; git clean -xfd; git checkout $(cd uxn && git rev-parse HEAD); MSYSTEM=MSYS ./build.sh --no-run"
51
+            rsync -rp win:uxn/bin/ build/uxn-win64/uxn/
52
+        else
53
+            wget -nv -NP out "https://${SITE}/"uxn{,-essentials}-win64.{tar.gz,zip} || true
54
+            touch out/needs-solar-build
55
+        fi
50 56
     - build-macos: |
51
-        ssh mac "export PATH=\"\${PATH}:/usr/local/bin\"; set -ex; cd uxn; git fetch; git checkout .; git clean -xfd; git checkout $(cd uxn && git rev-parse HEAD); ./build.sh --no-run"
52
-        rsync -rp mac:uxn/bin/ build/uxn-mac64/uxn/
57
+        if ssh mac true; then
58
+            ssh mac "export PATH=\"\${PATH}:/usr/local/bin\"; set -ex; cd uxn; git fetch; git checkout .; git clean -xfd; git checkout $(cd uxn && git rev-parse HEAD); ./build.sh --no-run"
59
+            rsync -rp mac:uxn/bin/ build/uxn-mac64/uxn/
60
+        else
61
+            wget -nv -NP out "https://${SITE}/"uxn{,-essentials}-mac64.{tar.gz,zip} || true
62
+            touch out/needs-solar-build
63
+        fi
53 64
     - archive: |
54 65
         for PROJECT in uxn-lin64 uxn-win64 uxn-mac64 essentials; do
66
+            [ -d "build/${PROJECT}/uxn" ] || continue
55 67
             tar -czf "out/${PROJECT}.tar.gz" -C "build/${PROJECT}" uxn
56 68
             ( cd "build/${PROJECT}" && zip -qr "../../out/${PROJECT}.zip" uxn )
57 69
             if [ "${PROJECT}" != essentials ]; then
... ...
@@ -61,8 +73,8 @@ tasks:
61 73
             fi
62 74
         done
63 75
     - upload: |
64
-        if [ "$(cd uxn && git rev-parse HEAD)" != "$(cd uxn && git rev-parse origin/main)" ]; then exit; fi
65 76
         ls -l out
77
+        if [ "$(cd uxn && git rev-parse HEAD)" != "$(cd uxn && git rev-parse origin/main)" ]; then exit; fi
66 78
         tar -czf out.tar.gz -C out .
67 79
         acurl() {
68 80
             set +x