From 3e1e5d330cadefb125d0ea53eeafe7f147b662de Mon Sep 17 00:00:00 2001
From: Hazel <git@ravy.org>
Date: Mon, 9 Oct 2023 19:39:11 +0100
Subject: [PATCH] ci: hxcpp + export caching

---
 .github/actions/setup-haxeshit/action.yml |  1 -
 .github/workflows/build-shit.yml          | 19 ++++++++++++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/.github/actions/setup-haxeshit/action.yml b/.github/actions/setup-haxeshit/action.yml
index 756530178..0cc544cf7 100644
--- a/.github/actions/setup-haxeshit/action.yml
+++ b/.github/actions/setup-haxeshit/action.yml
@@ -25,7 +25,6 @@ runs:
         key: ${{ runner.os }}-hmm-${{ hashFiles('**/hmm.json') }}
         restore-keys: |
           ${{ runner.os }}-hmm-
-          ${{ runner.os }}-
     - if: ${{ steps.cache-hmm.outputs.cache-hit != 'true' }}
       name: hmm install
       run: |
diff --git a/.github/workflows/build-shit.yml b/.github/workflows/build-shit.yml
index 3ce0d538b..92d915a8e 100644
--- a/.github/workflows/build-shit.yml
+++ b/.github/workflows/build-shit.yml
@@ -52,13 +52,30 @@ jobs:
           submodules: 'recursive'
           token: ${{ secrets.GH_RO_PAT }}
       - uses: ./.github/actions/setup-haxeshit
+      - name: Make HXCPP cache dir
+        shell: bash
+        run: |
+          mkdir -p ${{ runner.temp }}/hxcpp_cache
+      - name: Restore build cache
+        id: cache-build-win
+        uses: actions/cache@v3
+        with:
+          path: |
+            .haxelib
+            export
+            ${{ runner.temp }}/hxcpp_cache
+          key: ${{ runner.os }}-build-win-${{ github.ref_name }}
+          restore-keys: |
+            ${{ runner.os }}-build-win-
       - name: Build game
         run: |
           haxelib run lime build windows -release -DNO_REDIRECT_ASSETS_FOLDER
           dir
+        env:
+          HXCPP_COMPILE_CACHE: "${{ runner.temp }}/hxcpp_cache"
       - uses: ./.github/actions/upload-itch
         with:
-          butler-key: ${{ secrets.BUTLER_API_KEY}}
+          butler-key: ${{ secrets.BUTLER_API_KEY }}
           build-dir: export/release/windows/bin
           target: win
 #  test-unit-win: