name: switch on: push: branches: - master - feature/gh-actions-switch-cache tags: - '*' pull_request: {} workflow_dispatch: jobs: build_switch: name: Build Switch runs-on: ubuntu-latest container: image: 'devkitpro/devkita64' steps: - name: Install git run: | echo "deb http://ftp.debian.org/debian stretch-backports main" | sudo tee /etc/apt/sources.list.d/stretch-backports.list sudo apt update sudo apt install -t stretch-backports git -y - name: Checkout code uses: actions/checkout@v2 with: # We need 0 so we get all commits for mtime! fetch-depth: 0 path: "./stk-code" - name: Checkout OpenAL uses: actions/checkout@v2 with: fetch-depth: 0 path: "./stk-code/lib/openal" repository: "kcat/openal-soft" - name: Checkout Harfbuzz uses: actions/checkout@v2 with: fetch-depth: 0 path: "./stk-code/lib/harfbuzz" repository: "harfbuzz/harfbuzz" - name: Grab assets run: | sudo apt update sudo apt install unzip zip -y 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 - name: Restore modified date run: | sudo apt install -y git-restore-mtime cd stk-code git restore-mtime . cd lib/openal git restore-mtime . cd ../../lib/harfbuzz git restore-mtime . cd ../../.. # 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 }}" - name: Cache cmake_build id: cache-switch-cmake uses: actions/cache@v2 with: # 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 path: | 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 stk-code/lib/openal/cmake_build stk-code/lib/harfbuzz/cmake_build # Make sure PRs can't overwrite! key: ${{ github.ref }}-switch-cmake-0 - name: Run build script run: | cp -v stk-code/switch/pkgbuild-scripts/* "$DEVKITPRO/" cd stk-code/switch PROJECT_VERSION="${{ env.release_tag }}" ./make.sh - name: Create release uses: ncipollo/release-action@v1 if: ${{ env.release_tag != '' }} with: token: ${{ secrets.GITHUB_TOKEN }} artifacts: "stk-code/cmake_build/bin/SuperTuxKart-${{ env.release_tag }}-switch.zip" tag: ${{ env.release_name }} omitBodyDuringUpdate: true omitNameDuringUpdate: true allowUpdates: true prerelease: ${{ env.release_pre }}