2021-04-08 22:36:49 -04:00
|
|
|
name: switch
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
2021-04-13 13:01:09 -04:00
|
|
|
- feature/gh-actions-switch-cache
|
2021-04-08 22:36:49 -04:00
|
|
|
tags:
|
|
|
|
- '*'
|
|
|
|
pull_request: {}
|
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build_switch:
|
|
|
|
name: Build Switch
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container:
|
|
|
|
image: 'devkitpro/devkita64'
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
2021-04-13 13:01:09 -04:00
|
|
|
# We need 0 so we get all commits for mtime!
|
|
|
|
fetch-depth: 0
|
2021-04-08 22:36:49 -04:00
|
|
|
path: "./stk-code"
|
|
|
|
- name: Grab assets
|
|
|
|
run: |
|
|
|
|
wget -q https://github.com/supertuxkart/stk-assets-mobile/releases/download/git/stk-assets-full.zip
|
|
|
|
unzip -q stk-assets-full.zip -d stk-assets
|
|
|
|
rm stk-assets-full.zip
|
2021-04-13 13:01:09 -04:00
|
|
|
- name: Restore modified date
|
|
|
|
run: |
|
|
|
|
cd stk-code
|
|
|
|
git restore-mtime .
|
2021-05-14 11:45:52 -04:00
|
|
|
cd ..
|
2021-04-08 22:36:49 -04:00
|
|
|
|
|
|
|
# Env setup!
|
|
|
|
- name: Configure packaging name for git master branch
|
|
|
|
if: ${{ github.ref == 'refs/heads/master' }}
|
|
|
|
run: |
|
|
|
|
echo "release_tag=git`date +%Y%m%d`" >> $GITHUB_ENV
|
|
|
|
echo "release_name=preview" >> $GITHUB_ENV
|
|
|
|
- name: Configure packaging name for tag
|
|
|
|
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
|
|
run: |
|
|
|
|
echo "release_tag=`basename $GITHUB_REF`" >> $GITHUB_ENV
|
|
|
|
echo "release_name=`basename $GITHUB_REF`" >> $GITHUB_ENV
|
|
|
|
- name: Configure packaging name for non-releasing branch
|
|
|
|
if: ${{ (github.ref != 'refs/heads/master' && !startsWith(github.ref, 'refs/tags/')) || github.repository_owner != 'supertuxkart' }}
|
|
|
|
run: |
|
|
|
|
echo "release_tag=" >> $GITHUB_ENV
|
|
|
|
echo "release_name=" >> $GITHUB_ENV
|
|
|
|
- name: Check for prerelease
|
|
|
|
if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'rc') || contains(github.ref, 'beta') }}
|
|
|
|
run: |
|
|
|
|
echo "release_pre=true" >> $GITHUB_ENV
|
|
|
|
- name: Check for non-prerelease
|
|
|
|
if: ${{ github.ref != 'refs/heads/master' && !contains(github.ref, 'rc') && !contains(github.ref, 'beta') }}
|
|
|
|
run: |
|
|
|
|
echo "release_pre=false" >> $GITHUB_ENV
|
|
|
|
- name: Show packaging name
|
|
|
|
run : |
|
|
|
|
echo "${{ env.release_tag }}"
|
|
|
|
echo "${{ env.release_name }}"
|
|
|
|
echo "${{ env.release_pre }}"
|
2021-04-29 13:08:07 -04:00
|
|
|
- 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=switch-${{ github.ref }}-$id" >> $GITHUB_ENV
|
|
|
|
done
|
|
|
|
- name: Handle build cache
|
2021-04-08 22:36:49 -04:00
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
2021-04-13 13:01:09 -04:00
|
|
|
# This is unnecessarily verbose and might break, but again ! seems broken
|
|
|
|
# See: https://github.com/Mstrodl/stk-code/runs/2333673736?check_suite_focus=true#step:16:34
|
2021-04-08 22:36:49 -04:00
|
|
|
path: |
|
2021-04-13 13:01:09 -04:00
|
|
|
stk-code/cmake_build/CMakeFiles
|
|
|
|
stk-code/cmake_build/Makefile
|
|
|
|
stk-code/cmake_build/lib
|
|
|
|
stk-code/cmake_build/bin/supertuxkart
|
|
|
|
stk-code/cmake_build/*.cmake
|
|
|
|
stk-code/cmake_build/*.txt
|
|
|
|
|
2021-04-08 22:36:49 -04:00
|
|
|
# Make sure PRs can't overwrite!
|
2021-04-29 13:08:07 -04:00
|
|
|
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 }}
|
2021-04-08 22:36:49 -04:00
|
|
|
- name: Run build script
|
|
|
|
run: |
|
|
|
|
cd stk-code/switch
|
|
|
|
PROJECT_VERSION="${{ env.release_tag }}" ./make.sh
|
|
|
|
- name: Create release
|
2021-09-10 00:03:50 -04:00
|
|
|
uses: ncipollo/release-action@v1.8.8
|
2021-04-08 22:36:49 -04:00
|
|
|
if: ${{ env.release_tag != '' }}
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
artifacts: "stk-code/cmake_build/bin/SuperTuxKart-${{ env.release_tag }}-switch.zip"
|
2021-04-08 23:24:38 -04:00
|
|
|
tag: ${{ env.release_name }}
|
2021-04-08 22:36:49 -04:00
|
|
|
omitBodyDuringUpdate: true
|
|
|
|
omitNameDuringUpdate: true
|
|
|
|
allowUpdates: true
|
|
|
|
prerelease: ${{ env.release_pre }}
|