Skip to content

BelowTheSurface - fix/toxic-blocks #357

BelowTheSurface - fix/toxic-blocks

BelowTheSurface - fix/toxic-blocks #357

Workflow file for this run

name: Compile Games
on:
repository_dispatch:
pull_request_target:
types: [opened, reopened, synchronize, labeled, unlabeled]
branches: [main]
jobs:
get-game-directory:
if: "!contains( github.event.pull_request.labels.*.name, 'compiled')"
runs-on: ubuntu-latest
env:
GAME_DIR:
GIT_BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }}
GITHUB_CONTEXT: ${{ toJson(github) }}
outputs:
game-directory: ${{ steps.get-game-directory.outputs.game-directory }}
CSharpFound: ${{ steps.get-game-directory.outputs.CSharpFound }}
NoCSharpFound: ${{ steps.get-game-directory.outputs.NoCSharpFound }}
Number-of-games: ${{ steps.get-game-directory.outputs.Number-of-games }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
fetch-depth: 0
submodules: "recursive"
- id: get-game-directory
run: |
cd $GITHUB_WORKSPACE
if [ "${GIT_BASE_REPO}" == "thoth-tech/arcade-games" ]; then
git remote add upstream https://github.com/thoth-tech/arcade-games.git
git fetch upstream
echo "Compare upstream ${GITHUB_BASE_REF} with origin ${GITHUB_HEAD_REF}"
declare DIRECTORIES=($(git diff --name-only --merge-base upstream/${GITHUB_BASE_REF} origin/${GITHUB_HEAD_REF} games | awk -F'/' '{print "games/" $2 "/"}' | sort -u))
else
echo "Compare origin ${GITHUB_BASE_REF} with origin ${GITHUB_HEAD_REF}"
declare DIRECTORIES=($(git diff --name-only --merge-base origin/${GITHUB_BASE_REF} origin/${GITHUB_HEAD_REF} games | awk -F'/' '{print "games/" $2 "/"}' | sort -u))
fi
GAME_DIR=()
for dir in "${DIRECTORIES[@]}"
do
if [ $(expr length ${dir//[!\/]}) -eq 2 ]; then
GAME_DIR+=($dir)
else
echo skipping: $dir
fi
done
#echo "::set-output name=game-directory::${GAME_DIR[@]}"
echo game-directory=${GAME_DIR[@]} >> $GITHUB_OUTPUT
CSharpFound=false
NoCSharpFound=false
echo Games:
for dir in "${GAME_DIR[@]}"
do
echo "$dir"
if [ -f "$dir"*.csproj ]; then
CSharpFound=true #if any program has a .csproj file, set the variable to true
else
NoCSharpFound=true #if any program does not have a .csproj file, set the variable to true
fi
done
echo Games located: "${#GAME_DIR[@]}"
echo C# Found: $CSharpFound
echo No C# Found: $NoCSharpFound
echo CSharpFound=$CSharpFound >> $GITHUB_OUTPUT
echo NoCSharpFound=$NoCSharpFound >> $GITHUB_OUTPUT
echo Number-of-games=${#GAME_DIR[@]} >> $GITHUB_OUTPUT
compile-games-linux:
if: needs.get-game-directory.outputs.Number-of-games > 0
runs-on: ubuntu-latest
needs: get-game-directory
steps:
- name: Checkout feature branch
uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: "recursive"
- name: Update Packages
run: sudo apt-get update
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Install SplashKit
run: |
bash <(curl -s https://raw.githubusercontent.com/splashkit/skm/master/install-scripts/skm-install.sh)
- name: Add splashkit to path
run: echo "$HOME/.splashkit" >> $GITHUB_PATH
- name: Install dependencies, compile splashkit
run: |
skm linux install
- name: Compile Game
run: |
read GAME_DIR <<< "${{ needs.get-game-directory.outputs.game-directory }}"
for dir in ${GAME_DIR[@]}
do
echo $dir
./compile-game.sh $GITHUB_WORKSPACE/$dir linux-x86
done
- uses: actions/upload-artifact@v3
with:
name: linux-programs
path: |
**/games/*/published/
# This can be used to debug the build, see https://github.com/lhotari/action-upterm
# Open the comile log for Linux, and copy the ssh connection. Note you need to have setup a public key for your SSh connection try ssh-keygen -t ed25519 if you get Permission denied (publickey)
# - name: Setup upterm session
# uses: lhotari/action-upterm@v1
compile-dotnet-games-arm:
if: needs.get-game-directory.outputs.CSharpFound == 'true' && needs.get-game-directory.outputs.Number-of-games > 0
runs-on: ubuntu-latest
needs: get-game-directory
steps:
- name: Checkout feature branch
uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: "recursive"
- name: Update Packages
run: sudo apt-get update
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Install SplashKit
run: |
bash <(curl -s https://raw.githubusercontent.com/splashkit/skm/master/install-scripts/skm-install.sh)
- name: Add splashkit to path
run: echo "$HOME/.splashkit" >> $GITHUB_PATH
- name: Install dependencies, compile splashkit
run: |
skm linux install
- name: Compile Game
run: |
read GAME_DIR <<< "${{ needs.get-game-directory.outputs.game-directory }}"
GAME_DIR=($GAME_DIR)
for dir in ${GAME_DIR[@]}
do
echo "check " $dir
if [ -f "$dir"*.csproj ]; then
echo "Running for " $dir
./compile-game.sh $GITHUB_WORKSPACE/$dir linux-arm
fi
done
- uses: actions/upload-artifact@v3
with:
name: arm-programs
path: |
**/games/*/published/
compile-games-windows:
if: needs.get-game-directory.outputs.Number-of-games > 0
runs-on: windows-latest
needs: get-game-directory
defaults:
run:
shell: msys2 {0}
steps:
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: git mingw-w64-x86_64-cc
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: "recursive"
- name: Install SplashKit
run: |
bash <(curl -s https://raw.githubusercontent.com/splashkit/skm/master/install-scripts/skm-install.sh)
- name: Compile Game
run: |
export PATH=$PATH:/home/runneradmin/.splashkit
export PATH=$PATH:/c/Program\ Files/dotnet
echo $PATH
read GAME_DIR <<< "${{ needs.get-game-directory.outputs.game-directory }}"
for dir in ${GAME_DIR[@]}
do
./compile-game.sh $GITHUB_WORKSPACE/$dir win-x86
done
- uses: actions/upload-artifact@v3
with:
name: windows-programs
path: |
**/games/*/published/
compile-games-arm:
if: needs.get-game-directory.outputs.NoCSharpFound == 'true' && needs.get-game-directory.outputs.Number-of-games > 0
runs-on: ubuntu-latest
needs: get-game-directory
steps:
- uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: "recursive"
- name: Install Splashkit & Compile Game
uses: pguyot/arm-runner-action@v2
with:
cpu: cortex-a8
base_image: raspios_lite:latest
image_additional_mb: 4096
shell: bash
import_github_env: true
export_github_env: true
bind_mount_repository: true
commands: |
read GAME_DIR <<< "${{ needs.get-game-directory.outputs.game-directory }}"
sudo apt-get update
sudo apt install --assume-yes git cmake
# curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel STS
# export PATH=$PATH:$HOME/.dotnet
# export DOTNET_ROOT=$HOME/.dotnet
# echo $PATH
# echo $DOTNET_ROOT
# dotnet --version
bash <(curl -s https://raw.githubusercontent.com/splashkit/skm/master/install-scripts/skm-install.sh)
export PATH=$PATH:$HOME/.splashkit
sudo apt install --assume-yes libsdl2-dev libsdl2-gfx-dev libsdl2-mixer-dev libsdl2-ttf-dev libsdl2-net-dev libsdl2-image-dev libncurses-dev libpng-dev libcurl4-openssl-dev libbz2-dev libflac-dev libvorbis-dev libmikmod-dev libwebp-dev libfreetype6-dev
skm linux install
for dir in ${GAME_DIR[@]}
do
if [ ! -f "$dir"*.csproj ]; then
./compile-game.sh $dir linux-arm
fi
done
- uses: actions/upload-artifact@v3
with:
name: arm-programs
path: |
**/games/*/published/
push-games:
runs-on: ubuntu-latest
needs:
[
get-game-directory,
compile-games-linux,
compile-games-windows,
compile-games-arm,
compile-dotnet-games-arm,
]
if: |
always() &&
needs.compile-games-windows.result == 'success' &&
needs.compile-games-linux.result == 'success' &&
(needs.compile-games-arm.result == 'success' || needs.compile-games-arm.result == 'skipped') &&
(needs.compile-dotnet-games-arm.result == 'success' || needs.compile-dotnet-games-arm.result == 'skipped')
steps:
- name: Checkout feature branch
uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: "recursive"
- uses: actions/download-artifact@v3
with:
name: windows-programs
path: ./windows-downloads
- uses: actions/download-artifact@v3
with:
name: linux-programs
path: ./linux-downloads
- uses: actions/download-artifact@v3
with:
name: arm-programs
path: ./arm-downloads
- name: Files downloaded
run: |
read GAME_DIR <<< "${{ needs.get-game-directory.outputs.game-directory }}"
FOLDERS=("windows-downloads" "linux-downloads" "arm-downloads")
for dir in ${GAME_DIR[@]}
do
game_name=$(basename $dir)
cd $GITHUB_WORKSPACE/compiled-games
if [ ! -d "${game_name}" ]; then
mkdir ${game_name}
else
rm -rf ${game_name}/*
fi
cd ${game_name}
for folder in "${FOLDERS[@]}"
do
chmod 777 $GITHUB_WORKSPACE/$folder/games/${game_name}/*
cp $GITHUB_WORKSPACE/$folder/games/${game_name}/published/* .
done
done
- name: Git Add, Commit, Push
run: |
cd $GITHUB_WORKSPACE
git config user.name github-actions
git config user.email github-actions@github.com
read GAME_DIR <<< "${{ needs.get-game-directory.outputs.game-directory }}"
for dir in ${GAME_DIR[@]}
do
game_name=$(basename $dir)
git add compiled-games/$game_name
done
git commit -m "Compiled Games"
git push origin HEAD:${GITHUB_HEAD_REF}
add-compiled-label:
needs: push-games
if: |
always() &&
needs.push-games.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Add label
uses: andymckay/labeler@master
with:
add-labels: "compiled"