DinoGame/.github/workflows/release.yml
2025-03-13 12:33:36 +01:00

147 lines
No EOL
4.2 KiB
YAML

name: Build and Release DinoGame
on:
workflow_dispatch:
inputs:
question:
description: 'Release?'
required: false
default: 'YES'
type: choice
options:
- 'YES'
- 'PLS DONT'
permissions:
contents: write
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install -y cmake g++ xorg-dev libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
shell: bash
- name: Install Dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install cmake gcc
brew install --cask xquartz
shell: bash
- name: Install Dependencies (Windows)
if: runner.os == 'Windows'
run: |
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
shell: powershell
- name: List Current Directory
run: ls -la
shell: bash
- name: Configure CMake
run: |
if [ -d "assets" ]; then
echo "Assets directory exists"
else
echo "Assets directory does not exist"
mkdir -p assets
fi
cmake -B build
shell: bash
- name: Build Project
run: cmake --build build --config Release
shell: bash
- name: Determine Output Directory
id: get-output-dir
run: |
if [ "${{ runner.os }}" == "Windows" ]; then
echo "output_dir=build/windows" >> $GITHUB_OUTPUT
elif [ "${{ runner.os }}" == "macOS" ]; then
echo "output_dir=build/macos" >> $GITHUB_OUTPUT
else
echo "output_dir=build/linux" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Fix Assets (if necessary)
run: |
TARGET_DIR="${{ steps.get-output-dir.outputs.output_dir }}/assets"
if [ ! -d "$TARGET_DIR" ]; then
echo "Creating assets directory in output directory"
mkdir -p "$TARGET_DIR"
# Wenn das ursprüngliche assets-Verzeichnis existiert, kopiere seinen Inhalt
if [ -d "assets" ]; then
cp -r assets/* "$TARGET_DIR"/ || echo "Note: No assets to copy or copy failed"
else
echo "No source assets directory found, creating empty directory"
fi
fi
shell: bash
- name: Zip Build with Assets (Linux/macOS)
if: runner.os != 'Windows'
run: |
cd ${{ steps.get-output-dir.outputs.output_dir }}
zip -r ../../DinoGame-${{ runner.os }}.zip .
shell: bash
- name: List files before zipping
if: runner.os == 'Windows'
run: |
dir ${{ steps.get-output-dir.outputs.output_dir }}
shell: powershell
- name: Zip Build with Assets (Windows)
if: runner.os == 'Windows'
run: |
cd ${{ steps.get-output-dir.outputs.output_dir }}
Compress-Archive -Path .\* -DestinationPath ..\DinoGame-Windows.zip
shell: powershell
- name: List files after zipping
if: runner.os == 'Windows'
run: |
dir ..
shell: powershell
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: DinoGame-${{ runner.os }}
path: ${{ steps.get-output-dir.outputs.output_dir }}/DinoGame-Windows.zip
release:
needs: build
runs-on: ubuntu-latest
if: github.event.inputs.question == 'YES'
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/**/*
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}