All checks were successful
Build and Deploy / build-linux (push) Successful in 41s
Build and Deploy / build-windows (push) Successful in 47s
Build and Deploy / package-dist (push) Has been skipped
Build and Deploy / deploy-itch (push) Has been skipped
Build and Deploy / deploy-gitea (push) Has been skipped
313 lines
9.9 KiB
YAML
313 lines
9.9 KiB
YAML
name: Build and Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [ "*" ]
|
|
tags: [ "v*" ]
|
|
pull_request:
|
|
|
|
jobs:
|
|
build-linux:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: gitea.pockle.world/john/prosperon/linux:latest
|
|
|
|
steps:
|
|
- name: Check Out Code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Gitea credentials
|
|
run: |
|
|
git config --global credential.helper store
|
|
echo "https://$GITEA_USER:$GITEA_TOKEN@gitea.pockle.world" >> ~/.git-credentials
|
|
env:
|
|
GITEA_USER: ${{ secrets.USER_GITEA }}
|
|
GITEA_TOKEN: ${{ secrets.TOKEN_GITEA }}
|
|
|
|
- name: Cache SDL3 (Linux)
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
sdl3
|
|
sdl3-build
|
|
key: sdl3-linux-${{ hashFiles('sdl3/CMakeLists.txt') }}
|
|
|
|
- name: Build SDL3 (Linux)
|
|
run: |
|
|
if [ ! -d "sdl3/.git" ]; then
|
|
echo "Cloning SDL3 repository..."
|
|
git clone --depth 1 --branch main https://github.com/libsdl-org/SDL.git sdl3
|
|
else
|
|
echo "SDL3 source is already present (possibly from cache)."
|
|
fi
|
|
mkdir -p sdl3-build
|
|
cd sdl3-build
|
|
cmake ../sdl3 -GNinja \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_INSTALL_PREFIX="${PWD}/installed_sdl3" \
|
|
-DSDL_SHARED=ON \
|
|
-DSDL_STATIC=OFF
|
|
ninja
|
|
ninja install
|
|
|
|
- name: Build Prosperon (Linux)
|
|
run: |
|
|
export PKG_CONFIG_PATH="${PWD}/sdl3-build/installed_sdl3/lib/pkgconfig:$PKG_CONFIG_PATH"
|
|
meson setup build -Dbuildtype=release -Db_lto=true -Db_ndebug=true
|
|
meson compile -C build
|
|
|
|
- name: Test Prosperon (Linux)
|
|
env:
|
|
TRACY_NO_INVARIANT_CHECK: 1
|
|
run: |
|
|
meson test --print-errorlogs -C build
|
|
|
|
- name: Upload Test Log (Linux)
|
|
if: ${{ always() }}
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: testlog-linux
|
|
path: build/meson-logs/testlog.txt
|
|
|
|
- name: Create artifact folder (Linux)
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
mkdir _pack
|
|
cp build/prosperon _pack/
|
|
cp sdl3-build/installed_sdl3/lib/libSDL3.so _pack/
|
|
|
|
- name: Upload Artifact (Linux)
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: prosperon-artifacts-linux
|
|
path: _pack
|
|
|
|
build-windows:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: gitea.pockle.world/john/prosperon/linux:latest
|
|
|
|
steps:
|
|
- name: Check Out Code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Gitea credentials
|
|
run: |
|
|
git config --global credential.helper store
|
|
echo "https://$GITEA_USER:$GITEA_TOKEN@gitea.pockle.world" >> ~/.git-credentials
|
|
env:
|
|
GITEA_USER: ${{ secrets.USER_GITEA }}
|
|
GITEA_TOKEN: ${{ secrets.TOKEN_GITEA }}
|
|
|
|
- name: Cache SDL3 (Windows cross)
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
sdl3-win
|
|
sdl3-build-win
|
|
key: sdl3-win-${{ hashFiles('sdl3-win/CMakeLists.txt') }}-v2
|
|
|
|
- name: Build SDL3 (Windows cross)
|
|
run: |
|
|
if [ ! -d "sdl3-win/.git" ]; then
|
|
echo "Cloning SDL3 for Windows cross..."
|
|
git clone --depth 1 --branch main https://github.com/libsdl-org/SDL.git sdl3-win
|
|
else
|
|
echo "SDL3-win source already present (possibly from cache)."
|
|
fi
|
|
mkdir -p sdl3-build-win
|
|
cd sdl3-build-win
|
|
cmake ../sdl3-win -GNinja \
|
|
-DCMAKE_SYSTEM_NAME=Windows \
|
|
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
|
|
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
|
|
-DCMAKE_RC_COMPILER=x86_64-w64-mingw32-windres \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_INSTALL_PREFIX="${PWD}/installed_sdl3_win" \
|
|
-DSDL_SHARED=ON \
|
|
-DSDL_STATIC=OFF
|
|
ninja
|
|
ninja install
|
|
|
|
- name: Configure PKG_CONFIG_PATH (Windows cross)
|
|
run: |
|
|
echo "PKG_CONFIG_PATH=${GITHUB_WORKSPACE}/sdl3-build-win/installed_sdl3_win/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
|
|
|
|
- name: Build Prosperon (Windows cross)
|
|
run: |
|
|
meson setup build -Dbuildtype=release -Db_lto=true -Db_ndebug=true --cross-file mingw32.cross
|
|
meson compile -C build
|
|
|
|
- name: Test Prosperon
|
|
env:
|
|
TRACY_NO_INVARIANT_CHECK: 1
|
|
run: |
|
|
meson test --print-errorlogs -C build
|
|
|
|
- name: Upload Test Log
|
|
if: ${{ always() }}
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: testlog-windows
|
|
path: build/meson-logs/testlog.txt
|
|
|
|
- name: Create package folder
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
mkdir _pack
|
|
cp build/prosperon.exe _pack/
|
|
cp sdl3-build-win/installed_sdl3_win/bin/SDL3.dll _pack/
|
|
|
|
- name: Upload Artifact (Windows cross)
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: prosperon-artifacts-windows
|
|
path: _pack
|
|
|
|
package-dist:
|
|
needs: [build-linux, build-windows]
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check Out Code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Get Latest Tag
|
|
id: get_tag
|
|
run: |
|
|
TAG=$(git describe --tags --abbrev=0)
|
|
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
|
|
|
- name: Download Linux Artifacts
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: prosperon-artifacts-linux
|
|
path: linux_artifacts
|
|
|
|
- name: Download Windows Artifacts
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: prosperon-artifacts-windows
|
|
path: windows_artifacts
|
|
|
|
- name: Create the Dist Folder
|
|
run: |
|
|
mkdir dist
|
|
cp README.md dist/
|
|
cp license.txt dist/
|
|
cp -r examples dist/
|
|
mkdir dist/linux
|
|
mkdir dist/win
|
|
cp linux_artifacts/* dist/linux/
|
|
cp windows_artifacts/* dist/win/
|
|
|
|
- name: Package Final Dist
|
|
run: |
|
|
TAG=${{ steps.get_tag.outputs.tag }}
|
|
zip -r "prosperon-${TAG}.zip" dist
|
|
echo "Created prosperon-${TAG}.zip"
|
|
|
|
- name: Upload Final Dist
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: "prosperon-${{ steps.get_tag.outputs.tag }}"
|
|
path: "prosperon-${{ steps.get_tag.outputs.tag }}.zip"
|
|
|
|
deploy-itch:
|
|
needs: [package-dist]
|
|
if: ${{ false }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check Out Code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Get Latest Tag
|
|
id: get_tag
|
|
run: |
|
|
TAG=$(git describe --tags --abbrev=0)
|
|
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
|
|
|
- name: Download Final Distribution
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: "prosperon-${{ steps.get_tag.outputs.tag }}"
|
|
path: dist
|
|
|
|
- name: Set up Butler
|
|
uses: jdno/setup-butler@v1
|
|
|
|
- name: Push to itch.io
|
|
run: |
|
|
butler push "dist/prosperon-${{ steps.get_tag.outputs.tag }}.zip" ${{ secrets.ITCHIO_USERNAME }}/prosperon:win-linux --userversion ${{ steps.get_tag.outputs.tag }}
|
|
env:
|
|
BUTLER_API_KEY: ${{ secrets.ITCHIO_API_KEY }}
|
|
|
|
deploy-gitea:
|
|
needs: [package-dist]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check Out Code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Get Latest Tag and Commit Message
|
|
id: get_tag
|
|
run: |
|
|
TAG=$(git describe --tags --abbrev=0)
|
|
COMMIT_MSG=$(git log -1 --pretty=%B "${TAG}")
|
|
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
|
echo "commit_msg=$COMMIT_MSG" >> $GITHUB_OUTPUT
|
|
|
|
- name: Download Final Distribution
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: "prosperon-${{ steps.get_tag.outputs.tag }}"
|
|
path: dist
|
|
|
|
- name: Create or Update Gitea Release
|
|
run: |
|
|
TAG=${{ steps.get_tag.outputs.tag }}
|
|
ZIP_FILE="dist/prosperon-${TAG}.zip"
|
|
COMMIT_MSG=$(echo "${{ steps.get_tag.outputs.commit_msg }}" | jq -R -s '.')
|
|
|
|
# Check if release exists
|
|
RELEASE_ID=$(curl -s -H "Authorization: token ${{ secrets.TOKEN_GITEA }}" \
|
|
"https://gitea.pockle.world/api/v1/repos/john/prosperon/releases/tags/${TAG}" | jq -r '.id')
|
|
|
|
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" == "null" ]; then
|
|
# Create a new release if it doesn't exist
|
|
echo "Creating new release for tag ${TAG}"
|
|
RELEASE_ID=$(curl -X POST \
|
|
-H "Authorization: token ${{ secrets.TOKEN_GITEA }}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"${TAG}\",\"target_commitish\":\"${{ github.sha }}\",\"name\":\"${TAG}\",\"body\":${COMMIT_MSG},\"draft\":false,\"prerelease\":false}" \
|
|
"https://gitea.pockle.world/api/v1/repos/john/prosperon/releases" | jq -r '.id')
|
|
|
|
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" == "null" ]; then
|
|
echo "Failed to create release for tag ${TAG}"
|
|
exit 1
|
|
fi
|
|
echo "Created release with ID: ${RELEASE_ID}"
|
|
else
|
|
echo "Release already exists with ID: ${RELEASE_ID}"
|
|
fi
|
|
|
|
# Upload the zip file as an asset
|
|
curl -X POST \
|
|
-H "Authorization: token ${{ secrets.TOKEN_GITEA }}" \
|
|
-H "Content-Type: application/octet-stream" \
|
|
--data-binary @"${ZIP_FILE}" \
|
|
"https://gitea.pockle.world/api/v1/repos/john/prosperon/releases/${RELEASE_ID}/assets?name=prosperon-${TAG}.zip"
|
|
env:
|
|
TOKEN_GITEA: ${{ secrets.TOKEN_GITEA }} |