Fix GitHub Actions cache not saved

This commit is contained in:
Benau 2021-04-30 01:08:07 +08:00
parent 74010b74b9
commit a2004e53fb
2 changed files with 44 additions and 18 deletions

View File

@ -86,9 +86,16 @@ jobs:
echo "${{ env.release_tag }}" echo "${{ env.release_tag }}"
echo "${{ env.release_name }}" echo "${{ env.release_name }}"
echo "${{ env.release_pre }}" echo "${{ env.release_pre }}"
- name: List build cache restore keys
- name: Cache cmake_build shell : bash
id: cache-switch-cmake run: |
# Look for the last 9 build caches (GitHub supports max 10 including current one)
for number in 1 2 3 4 5 6 7 8 9
do
id=$((${{ github.run_number }} - number))
echo "cache_$number=switch-${{ github.ref }}-$id" >> $GITHUB_ENV
done
- name: Handle build cache
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
# This is unnecessarily verbose and might break, but again ! seems broken # This is unnecessarily verbose and might break, but again ! seems broken
@ -104,8 +111,17 @@ jobs:
stk-code/lib/openal/cmake_build stk-code/lib/openal/cmake_build
stk-code/lib/harfbuzz/cmake_build stk-code/lib/harfbuzz/cmake_build
# Make sure PRs can't overwrite! # Make sure PRs can't overwrite!
key: ${{ github.ref }}-switch-cmake-0 key: switch-${{ github.ref }}-${{ github.run_number }}
restore-keys: |
${{ env.cache_1 }}
${{ env.cache_2 }}
${{ env.cache_3 }}
${{ env.cache_4 }}
${{ env.cache_5 }}
${{ env.cache_6 }}
${{ env.cache_7 }}
${{ env.cache_8 }}
${{ env.cache_9 }}
- name: Run build script - name: Run build script
run: | run: |
cp -v stk-code/switch/pkgbuild-scripts/* "$DEVKITPRO/" cp -v stk-code/switch/pkgbuild-scripts/* "$DEVKITPRO/"

View File

@ -44,12 +44,31 @@ jobs:
${{ env.wget }} https://github.com/MestreLion/git-tools/archive/refs/heads/master.zip ${{ env.wget }} https://github.com/MestreLion/git-tools/archive/refs/heads/master.zip
${{ env.unzip }} master.zip ${{ env.unzip }} master.zip
python git-tools-master/git-restore-mtime python git-tools-master/git-restore-mtime
- name: Cache build - name: List build cache restore keys
shell : bash
run: |
# Look for the last 9 build caches (GitHub supports max 10 including current one)
for number in 1 2 3 4 5 6 7 8 9
do
id=$((${{ github.run_number }} - number))
echo "cache_$number=windows-${{ github.ref }}-${{ matrix.arch }}-${{ matrix.os }}-$id" >> $GITHUB_ENV
done
- name: Handle build cache
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: | path: |
build build
key: ${{ github.ref }}-${{ matrix.arch }}-${{ matrix.os }}-windows-build key: windows-${{ github.ref }}-${{ matrix.arch }}-${{ matrix.os }}-${{ github.run_number }}
restore-keys: |
${{ env.cache_1 }}
${{ env.cache_2 }}
${{ env.cache_3 }}
${{ env.cache_4 }}
${{ env.cache_5 }}
${{ env.cache_6 }}
${{ env.cache_7 }}
${{ env.cache_8 }}
${{ env.cache_9 }}
- name: Download dependencies - name: Download dependencies
run: | run: |
${{ env.wget }} https://github.com/supertuxkart/dependencies/releases/download/preview/dependencies-win-${{ matrix.arch }}.zip ${{ env.wget }} https://github.com/supertuxkart/dependencies/releases/download/preview/dependencies-win-${{ matrix.arch }}.zip
@ -105,22 +124,13 @@ jobs:
run: | run: |
mkdir -p build mkdir -p build
cd build cd build
# Always run with -DUSE_DIRECTX=ON breaks the cache cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCHECK_ASSETS=OFF -DUSE_DIRECTX=ON
if [[ ! -f CMakeCache.txt ]]; then
cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCHECK_ASSETS=OFF -DUSE_DIRECTX=ON
else
cmake ..
fi
- name: Configure bulid for MinGW (aarch64) - name: Configure bulid for MinGW (aarch64)
if: ${{ matrix.os == 'ubuntu-latest' && matrix.arch == 'aarch64' }} if: ${{ matrix.os == 'ubuntu-latest' && matrix.arch == 'aarch64' }}
run: | run: |
mkdir -p build mkdir -p build
cd build cd build
if [[ ! -f CMakeCache.txt ]]; then cmake .. -DLLVM_ARCH=aarch64 -DLLVM_PREFIX=/llvm-mingw -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-llvm-mingw.cmake -DCHECK_ASSETS=OFF -DUSE_DIRECTX=ON
cmake .. -DLLVM_ARCH=aarch64 -DLLVM_PREFIX=/llvm-mingw -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-llvm-mingw.cmake -DCHECK_ASSETS=OFF -DUSE_DIRECTX=ON
else
cmake ..
fi
- name: Build for MSVC - name: Build for MSVC
if: ${{ matrix.os == 'windows-latest' }} if: ${{ matrix.os == 'windows-latest' }}
working-directory: build working-directory: build