From 39752ad28a355f26a42a62189a23e1c8d1764015 Mon Sep 17 00:00:00 2001 From: gilzoide Date: Mon, 13 Jan 2025 17:17:14 -0300 Subject: [PATCH 1/6] Add automatic native library builds using GitHub Actions --- .github/workflows/build.yml | 55 +++++++++++++++++++++++++++++++++++++ Plugins/Makefile | 8 +++--- 2 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d36ce29 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,55 @@ +name: Build native libraries +on: [push, pull_request] +defaults: + run: + shell: bash + +env: + DOCKER_CACHE: ${{ github.workspace }}/.docker-cache + +jobs: + build_with_docker: + name: ${{ matrix.platform }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + include: + - platform: windows + target: docker-all-windows-llvm + - platform: linux + target: docker-all-linux + - platform: android + target: docker-all-android + - platform: webgl + target: docker-all-webgl + steps: + - uses: actions/checkout@v3 + - name: Cache SCons files + uses: actions/cache@v4 + with: + path: $DOCKER_CACHE + - name: Build + run: make -C Plugins ${{ matrix.target }} DOCKER_BUILD_ARGS="--cache-to type=local,dest=$DOCKER_CACHE --cache-from type=local,src=$DOCKER_CACHE" + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.platform }} + path: | + Plugins/lib/${{ matrix.platform }}/**.bc + Plugins/lib/${{ matrix.platform }}/**.dll + Plugins/lib/${{ matrix.platform }}/**.dylib + Plugins/lib/${{ matrix.platform }}/**.so + + build_with_macos: + name: macOS + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - name: Build + run: make -C Plugins all-apple + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: macos + path: | + Plugins/lib/macos/**.dylib diff --git a/Plugins/Makefile b/Plugins/Makefile index 2bc6da5..74dc7c6 100644 --- a/Plugins/Makefile +++ b/Plugins/Makefile @@ -130,16 +130,16 @@ all-windows-llvm-mingw: windows-mingw-x86_64 windows-mingw-x86 windows-mingw-arm # Dockerized builds docker-all-android: - docker build -f tools~/Dockerfile.build.android --platform=linux/amd64 -t gilzoide-sqlite-net-build-android:latest . + docker build -f tools~/Dockerfile.build.android --platform=linux/amd64 -t gilzoide-sqlite-net-build-android:latest $(DOCKER_BUILD_ARGS) . docker run --rm -v "$(CURDIR)":/src -w /src --platform=linux/amd64 gilzoide-sqlite-net-build-android:latest make all-android docker-all-linux: - docker build -f tools~/Dockerfile.build.linux --platform=linux/amd64 -t gilzoide-sqlite-net-build-linux:latest . + docker build -f tools~/Dockerfile.build.linux --platform=linux/amd64 -t gilzoide-sqlite-net-build-linux:latest $(DOCKER_BUILD_ARGS) . docker run --rm -v "$(CURDIR)":/src -w /src --platform=linux/amd64 gilzoide-sqlite-net-build-linux:latest make all-linux docker-all-webgl: - docker build -f tools~/Dockerfile.build.webgl -t gilzoide-sqlite-net-build-webgl:latest . + docker build -f tools~/Dockerfile.build.webgl -t gilzoide-sqlite-net-build-webgl:latest $(DOCKER_BUILD_ARGS) . docker run --rm -v "$(CURDIR)":/src -w /src gilzoide-sqlite-net-build-webgl:latest make all-webgl docker-all-windows: - docker build -f tools~/Dockerfile.build.windows -t gilzoide-sqlite-net-build-windows:latest . + docker build -f tools~/Dockerfile.build.windows -t gilzoide-sqlite-net-build-windows:latest $(DOCKER_BUILD_ARGS) . docker run --rm -v "$(CURDIR)":/src -w /src gilzoide-sqlite-net-build-windows:latest make all-windows-mingw docker-all-windows-llvm: docker run --rm -v "$(CURDIR)":/src -w /src mstorsjo/llvm-mingw:latest make all-windows-llvm-mingw From 8888ccd48b78b732ffa7dda0fc55a28cd41abfbb Mon Sep 17 00:00:00 2001 From: gilzoide Date: Mon, 13 Jan 2025 17:18:11 -0300 Subject: [PATCH 2/6] Fix add matrix --- .github/workflows/build.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d36ce29..41701ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,15 +13,16 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: false - include: - - platform: windows - target: docker-all-windows-llvm - - platform: linux - target: docker-all-linux - - platform: android - target: docker-all-android - - platform: webgl - target: docker-all-webgl + matrix: + include: + - platform: windows + target: docker-all-windows-llvm + - platform: linux + target: docker-all-linux + - platform: android + target: docker-all-android + - platform: webgl + target: docker-all-webgl steps: - uses: actions/checkout@v3 - name: Cache SCons files From f587c262c3bbb0fd0c7699a80cade8ff4a507e45 Mon Sep 17 00:00:00 2001 From: gilzoide Date: Mon, 13 Jan 2025 17:19:40 -0300 Subject: [PATCH 3/6] Fix add key to cache step --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 41701ef..81b2c0d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,10 +25,11 @@ jobs: target: docker-all-webgl steps: - uses: actions/checkout@v3 - - name: Cache SCons files + - name: Cache Docker files uses: actions/cache@v4 with: path: $DOCKER_CACHE + key: ${{ matrix.platform }} - name: Build run: make -C Plugins ${{ matrix.target }} DOCKER_BUILD_ARGS="--cache-to type=local,dest=$DOCKER_CACHE --cache-from type=local,src=$DOCKER_CACHE" - name: Upload artifact From 357e5ae93cc24c12e4a5c7ac91f0a7817d38a96d Mon Sep 17 00:00:00 2001 From: gilzoide Date: Mon, 13 Jan 2025 17:26:16 -0300 Subject: [PATCH 4/6] Fix artifact paths, try using gha cache type --- .github/workflows/build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 81b2c0d..6819a87 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,16 +31,16 @@ jobs: path: $DOCKER_CACHE key: ${{ matrix.platform }} - name: Build - run: make -C Plugins ${{ matrix.target }} DOCKER_BUILD_ARGS="--cache-to type=local,dest=$DOCKER_CACHE --cache-from type=local,src=$DOCKER_CACHE" + run: make -C Plugins ${{ matrix.target }} DOCKER_BUILD_ARGS="--cache-from type=gha --cache-to type=gha,mode=max" - name: Upload artifact uses: actions/upload-artifact@v4 with: name: ${{ matrix.platform }} path: | - Plugins/lib/${{ matrix.platform }}/**.bc - Plugins/lib/${{ matrix.platform }}/**.dll - Plugins/lib/${{ matrix.platform }}/**.dylib - Plugins/lib/${{ matrix.platform }}/**.so + Plugins/lib/${{ matrix.platform }}/**/*.bc + Plugins/lib/${{ matrix.platform }}/**/*.dll + Plugins/lib/${{ matrix.platform }}/**/*.dylib + Plugins/lib/${{ matrix.platform }}/**/*.so build_with_macos: name: macOS @@ -54,4 +54,4 @@ jobs: with: name: macos path: | - Plugins/lib/macos/**.dylib + Plugins/lib/macos/*.dylib From 1ca96d6bdb8bad81a0db23820dec4f57666ef477 Mon Sep 17 00:00:00 2001 From: gilzoide Date: Mon, 13 Jan 2025 17:34:12 -0300 Subject: [PATCH 5/6] Update artifact name --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6819a87..f3fee85 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,7 +35,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: ${{ matrix.platform }} + name: gilzoide-sqlite-net-${{ matrix.platform }} path: | Plugins/lib/${{ matrix.platform }}/**/*.bc Plugins/lib/${{ matrix.platform }}/**/*.dll @@ -52,6 +52,6 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: macos + name: gilzoide-sqlite-net-macos path: | Plugins/lib/macos/*.dylib From 29fb151d44f67ac5f12c910d9c00495d61f467a5 Mon Sep 17 00:00:00 2001 From: gilzoide Date: Mon, 13 Jan 2025 17:58:35 -0300 Subject: [PATCH 6/6] Add download-latest-build target This target downloads the latest build from GitHub Actions --- Plugins/Makefile | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Plugins/Makefile b/Plugins/Makefile index 74dc7c6..0b04449 100644 --- a/Plugins/Makefile +++ b/Plugins/Makefile @@ -1,7 +1,14 @@ -EMCC ?= emcc +# Android setup ANDROID_NDK_ROOT ?= +# WebGL/Emscripten setup +EMCC ?= emcc +# macOS code signing setup CODESIGN ?= codesign MACOS_CODESIGN_SIGNATURE ?= +# Download GitHub Action releases +GITHUB_CLI_BIN ?= gh +GITHUB_REPO ?= gilzoide/unity-sqlite-net +RUN_ID ?= ifeq ($(DEBUG),1) CFLAGS += -O0 -g -DDEBUG @@ -143,3 +150,14 @@ docker-all-windows: docker run --rm -v "$(CURDIR)":/src -w /src gilzoide-sqlite-net-build-windows:latest make all-windows-mingw docker-all-windows-llvm: docker run --rm -v "$(CURDIR)":/src -w /src mstorsjo/llvm-mingw:latest make all-windows-llvm-mingw + +# Download builds from GitHub Actions +download-latest-build: + $(eval TMPDIR := $(shell mktemp -d)) + $(GITHUB_CLI_BIN) run download $(RUN_ID) --repo $(GITHUB_REPO) -p gilzoide-sqlite-net-* -D $(TMPDIR) + rsync -r $(TMPDIR)/gilzoide-sqlite-net-windows/* lib/windows/ + rsync -r $(TMPDIR)/gilzoide-sqlite-net-linux/* lib/linux/ + rsync -r $(TMPDIR)/gilzoide-sqlite-net-android/* lib/android/ + rsync -r $(TMPDIR)/gilzoide-sqlite-net-macos/* lib/macos/ + rsync -r $(TMPDIR)/gilzoide-sqlite-net-webgl/* lib/webgl/ + $(RM) -r $(TMPDIR)