diff --git a/.github/workflows/cloudron.yml b/.github/workflows/cloudron.yml index 7302b951e..5382e4601 100644 --- a/.github/workflows/cloudron.yml +++ b/.github/workflows/cloudron.yml @@ -22,7 +22,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: self-hosted permissions: contents: read packages: write @@ -49,6 +49,8 @@ jobs: echo "push=$PUSH" } >> "$GITHUB_OUTPUT" + # Cloudron runs amd64 images; an Apple silicon runner builds them under QEMU + - uses: docker/setup-qemu-action@v3 - uses: docker/setup-buildx-action@v3 - if: steps.meta.outputs.push == 'true' @@ -62,10 +64,12 @@ jobs: with: context: . file: Dockerfile.cloudron + platforms: linux/amd64 push: ${{ steps.meta.outputs.push == 'true' }} tags: ${{ steps.meta.outputs.tags }} - cache-from: type=gha - cache-to: type=gha,mode=max + # GitHub's cache only on GitHub's runners: uploading layers from a home connection takes longer than building + cache-from: ${{ runner.environment == 'github-hosted' && 'type=gha' || '' }} + cache-to: ${{ runner.environment == 'github-hosted' && 'type=gha,mode=max' || '' }} - name: Summary if: steps.meta.outputs.push == 'true' diff --git a/.github/workflows/qnap.yml b/.github/workflows/qnap.yml index ece9e9826..92f1c0543 100644 --- a/.github/workflows/qnap.yml +++ b/.github/workflows/qnap.yml @@ -27,10 +27,10 @@ jobs: matrix: include: - arch: x86_64 - runner: ubuntu-latest - # Built under QEMU unless the repository variable QNAP_ARM_RUNNER names an ARM runner (ubuntu-24.04-arm) + runner: self-hosted + # The repository variable QNAP_ARM_RUNNER can name another runner for it; on an x86 one it builds under QEMU - arch: arm_64 - runner: ${{ vars.QNAP_ARM_RUNNER || 'ubuntu-latest' }} + runner: ${{ vars.QNAP_ARM_RUNNER || 'self-hosted' }} runs-on: ${{ matrix.runner }} timeout-minutes: 300 env: @@ -41,7 +41,9 @@ jobs: with: ref: ${{ env.TAG }} + # Only on GitHub's runners: on a self-hosted one these would ask for a password, and prune its owner's images - name: Make room for the images + if: runner.environment == 'github-hosted' run: | sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL docker system prune -af >/dev/null @@ -62,6 +64,10 @@ jobs: ls -lh packaging/qnap/build/ # GitHub release assets are limited to 2 GiB each for f in packaging/qnap/build/*.qpkg; do - [ "$(stat -c %s "$f")" -lt 2147483648 ] || { echo "::error::$f is over 2 GiB, too big for a release asset"; exit 1; } + [ "$(wc -c < "$f")" -lt 2147483648 ] || { echo "::error::$f is over 2 GiB, too big for a release asset"; exit 1; } done gh release upload "$TAG" packaging/qnap/build/*.qpkg packaging/qnap/build/*.qpkg.md5 --clobber + + - name: Remove the images it built + if: always() + run: docker image rm "lens-backend:qnap-${TAG#v}" "lens-frontend:qnap-${TAG#v}" 2>/dev/null || true diff --git a/.github/workflows/synology.yml b/.github/workflows/synology.yml index 1f626a249..be3fd9cf4 100644 --- a/.github/workflows/synology.yml +++ b/.github/workflows/synology.yml @@ -23,7 +23,7 @@ on: jobs: spk: name: SPK (${{ matrix.arch }}) - runs-on: ubuntu-latest + runs-on: self-hosted permissions: contents: write # to attach the packages to the release strategy: @@ -33,8 +33,8 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ inputs.tag || github.ref }} + # the architecture that isn't the runner's own (armv8 on GitHub's runners, x86_64 on an Apple silicon Mac) - uses: docker/setup-qemu-action@v3 - if: matrix.arch == 'armv8' - uses: docker/setup-buildx-action@v3 with: driver: docker @@ -57,3 +57,6 @@ jobs: GH_TOKEN: ${{ github.token }} TAG: ${{ github.event.release.tag_name || inputs.tag }} run: gh release upload "$TAG" dist/synology/*.spk --clobber --repo "${{ github.repository }}" + - name: Remove the images it built + if: always() + run: docker image prune -af --filter label=net.lens.package=synology >/dev/null diff --git a/packaging/synology/build.sh b/packaging/synology/build.sh index 62f26e1c2..319944175 100755 --- a/packaging/synology/build.sh +++ b/packaging/synology/build.sh @@ -11,6 +11,7 @@ # # Needs Docker with buildx. Writes dist/synology/lens--.spk. set -eu +export COPYFILE_DISABLE=1 # macOS tar: no ._ resource-fork files in the package HERE=$(cd "$(dirname "$0")" && pwd) ROOT=$(cd "$HERE/../.." && pwd) @@ -64,7 +65,9 @@ chmod 755 "$WORK/spk/scripts/"* cp "$HERE/icons/lens_64.png" "$WORK/spk/PACKAGE_ICON.PNG" cp "$HERE/icons/lens_256.png" "$WORK/spk/PACKAGE_ICON_256.PNG" sed -e "s/@VERSION@/$VERSION/" -e "s/@ARCH@/$ARCH/" "$HERE/INFO.in" > "$WORK/spk/INFO" -echo "checksum=\"$(md5sum "$WORK/spk/package.tgz" | cut -d' ' -f1)\"" >> "$WORK/spk/INFO" +# md5sum on Linux, md5 on macOS +SUM=$( (md5sum "$WORK/spk/package.tgz" 2>/dev/null || md5 -r "$WORK/spk/package.tgz") | cut -d' ' -f1) +echo "checksum=\"$SUM\"" >> "$WORK/spk/INFO" echo "extractsize=\"$(du -sk "$WORK/package" | cut -f1)\"" >> "$WORK/spk/INFO" SPK=$OUT/lens-$VERSION-$ARCH.spk