From 3d94859151d83b93ad68bf0748024c9653310c3e Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Sun, 4 May 2025 17:04:21 -0500 Subject: [PATCH] macos build --- .github/workflows/build.yml | 166 +++++++++++++++++++++------------ .github/workflows/macbuild.yml | 64 ------------- 2 files changed, 104 insertions(+), 126 deletions(-) delete mode 100644 .github/workflows/macbuild.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9cd74b5..46cc658a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,10 +3,13 @@ name: Build and Deploy on: push: branches: [ "*" ] - tags: [ "v*" ] + tags: [ "v*" ] pull_request: jobs: + # ────────────────────────────────────────────────────────────── + # LINUX BUILD + # ────────────────────────────────────────────────────────────── build-linux: runs-on: ubuntu-latest container: @@ -15,8 +18,7 @@ jobs: steps: - name: Check Out Code uses: actions/checkout@v4 - with: - fetch-depth: 0 + with: { fetch-depth: 0 } - name: Build Prosperon (Linux) run: | @@ -24,8 +26,7 @@ jobs: meson compile -C build - name: Test Prosperon (Linux) - env: - TRACY_NO_INVARIANT_CHECK: 1 + env: { TRACY_NO_INVARIANT_CHECK: 1 } run: | meson test --print-errorlogs -C build strip build/prosperon @@ -44,11 +45,13 @@ jobs: name: prosperon-artifacts-linux path: build/prosperon + # ────────────────────────────────────────────────────────────── + # WINDOWS BUILD (MSYS2 / CLANG64) + # ────────────────────────────────────────────────────────────── build-windows: runs-on: win-native strategy: - matrix: - msystem: [CLANG64] + matrix: { msystem: [ CLANG64 ] } steps: - name: Check Out Code @@ -61,31 +64,26 @@ jobs: update: true cache: true install: | - git - zip - gzip - tar - base-devel + git zip gzip tar base-devel pacboy: | meson cmake toolchain - - name: Build Prosperon + - name: Build Prosperon (Windows) shell: msys2 {0} run: | meson setup build -Dbuildtype=release -Db_lto=true -Db_ndebug=true -Dtracy:only_localhost=true -Dtracy:no_broadcast=true meson compile -C build - - name: Test Prosperon + - name: Test Prosperon (Windows) shell: msys2 {0} - env: - TRACY_NO_INVARIANT_CHECK: 1 + env: { TRACY_NO_INVARIANT_CHECK: 1 } run: | meson test --print-errorlogs -C build strip build/prosperon.exe - - name: Upload Test Log + - name: Upload Test Log (Windows) if: ${{ always() }} uses: actions/upload-artifact@v3 with: @@ -99,15 +97,59 @@ jobs: name: prosperon-artifacts-windows path: build/prosperon.exe + # ────────────────────────────────────────────────────────────── + # MACOS BUILD + # ────────────────────────────────────────────────────────────── + build-macos: + runs-on: macos-latest + + steps: + - name: Check Out Code + uses: actions/checkout@v4 + with: { fetch-depth: 0 } + + - name: Build Prosperon (macOS) + run: | + meson setup build -Dbuildtype=release -Db_lto=true -Db_ndebug=true + meson compile -C build + + - name: Test Prosperon (macOS) + run: | + meson test --pring-errorlogs -C build + strip build/prosperon + + - name: Upload Test Log (macOS) + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: testlog-macos + path: build/meson-logs/testlog.txt + + - name: Create artifact folder (macOS) + run: | + mkdir _pack + cp build_macos/prosperon _pack/ + cp sdl3-macos/libSDL3*.dylib _pack/ || true + + - name: Upload Artifact (macOS) + if: startsWith(github.ref, 'refs/tags/v') + uses: actions/upload-artifact@v3 + with: + name: prosperon-artifacts-macos + path: prosperon + + # ────────────────────────────────────────────────────────────── + # PACKAGE CROSS-PLATFORM DIST + # ────────────────────────────────────────────────────────────── package-dist: - needs: [build-linux, build-windows] + needs: [ build-linux, build-windows, build-macos ] if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest + steps: - name: Check Out Code uses: actions/checkout@v3 - with: - fetch-depth: 0 + with: { fetch-depth: 0 } - name: Get Latest Tag id: get_tag @@ -127,16 +169,21 @@ jobs: name: prosperon-artifacts-windows path: windows_artifacts - - name: Create the Dist Folder + - name: Download macOS Artifacts + uses: actions/download-artifact@v3 + with: + name: prosperon-artifacts-macos + path: mac_artifacts + + - name: Create 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/ + mkdir -p dist/linux dist/win dist/mac + cp README.md dist/ + cp license.txt dist/ + cp -r examples dist/ + cp linux_artifacts/* dist/linux/ cp windows_artifacts/* dist/win/ + cp mac_artifacts/* dist/mac/ - name: Package Final Dist run: | @@ -150,14 +197,17 @@ jobs: name: "prosperon-${{ steps.get_tag.outputs.tag }}" path: "prosperon-${{ steps.get_tag.outputs.tag }}.zip" + # ────────────────────────────────────────────────────────────── + # DEPLOY TO ITCH.IO (single ZIP containing all OSes) + # ────────────────────────────────────────────────────────────── deploy-itch: - needs: [package-dist] + needs: [ package-dist ] runs-on: ubuntu-latest + steps: - name: Check Out Code uses: actions/checkout@v3 - with: - fetch-depth: 0 + with: { fetch-depth: 0 } - name: Get Latest Tag id: get_tag @@ -176,25 +226,30 @@ jobs: - 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 }} + butler push "dist/prosperon-${{ steps.get_tag.outputs.tag }}.zip" \ + ${{ secrets.ITCHIO_USERNAME }}/prosperon:universal \ + --userversion ${{ steps.get_tag.outputs.tag }} env: BUTLER_API_KEY: ${{ secrets.ITCHIO_API_KEY }} + # ────────────────────────────────────────────────────────────── + # DEPLOY TO SELF-HOSTED GITEA + # ────────────────────────────────────────────────────────────── deploy-gitea: - needs: [package-dist] + needs: [ package-dist ] runs-on: ubuntu-latest + steps: - name: Check Out Code uses: actions/checkout@v3 - with: - fetch-depth: 0 + with: { fetch-depth: 0 } - - name: Get Latest Tag and Commit Message + - name: Get Latest Tag & 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 + COMMIT_MSG=$(git log -1 --pretty=%B "$TAG") + echo "tag=$TAG" >> $GITHUB_OUTPUT echo "commit_msg=$COMMIT_MSG" >> $GITHUB_OUTPUT - name: Download Final Distribution @@ -203,39 +258,26 @@ jobs: name: "prosperon-${{ steps.get_tag.outputs.tag }}" path: dist - - name: Create or Update Gitea Release + - name: Create / 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 '.') + ZIP=dist/prosperon-${TAG}.zip + BODY=$(echo "${{ steps.get_tag.outputs.commit_msg }}" | jq -R -s '.') + RELEASE=$(curl -s -H "Authorization: token ${{ secrets.TOKEN_GITEA }}" \ + "https://gitea.pockle.world/api/v1/repos/john/prosperon/releases/tags/$TAG" | jq -r '.id') - # 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 \ + if [ "$RELEASE" = "null" ] || [ -z "$RELEASE" ]; then + RELEASE=$(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}" \ + -d "{\"tag_name\":\"$TAG\",\"target_commitish\":\"${{ github.sha }}\",\"name\":\"$TAG\",\"body\":$BODY,\"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" + --data-binary @"$ZIP" \ + "https://gitea.pockle.world/api/v1/repos/john/prosperon/releases/$RELEASE/assets?name=prosperon-${TAG}.zip" env: - TOKEN_GITEA: ${{ secrets.TOKEN_GITEA }} \ No newline at end of file + TOKEN_GITEA: ${{ secrets.TOKEN_GITEA }} diff --git a/.github/workflows/macbuild.yml b/.github/workflows/macbuild.yml deleted file mode 100644 index 5673505e..00000000 --- a/.github/workflows/macbuild.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Build - -jobs: - # =============================================================== - # MACOS BUILD (Using Homebrew SDL3) - # =============================================================== - build-macos: - runs-on: macos-latest - continue-on-error: true - steps: - # 1) Check out code - - name: Check Out Code - uses: actions/checkout@v3 - - # 2) Install dependencies (SDL3 via Homebrew) + ccache - - name: Install Dependencies (macOS) - run: | - brew update - brew install sdl3 meson ninja cmake ccache - - # 3) Configure ccache - - name: Configure ccache - run: | - echo "CMAKE_C_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV - echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV - - # 4) Cache ccache - - name: Cache ccache - uses: actions/cache@v3 - with: - path: ~/Library/Caches/ccache - key: ccache-macos-${{ hashFiles('**/*.c', '**/*.cpp', '**/*.h', '**/CMakeLists.txt', '**/meson.build') }} - restore-keys: | - ccache-macos- - - # 5) Build Prosperon (macOS) linking against Homebrew's SDL3 - - name: Build Prosperon (macOS) - run: | - # Ensure pkg-config can find Homebrew's SDL3 .pc files - export PKG_CONFIG_PATH="$(brew --prefix sdl3)/lib/pkgconfig:$PKG_CONFIG_PATH" - meson setup build_macos -Dbuildtype=release -Db_lto=true -Db_ndebug=true - meson compile -C build_macos - - # 6) Copy SDL3 .dylib from Homebrew for packaging - - name: Copy SDL3 library for packaging - run: | - SDL3_PREFIX=$(brew --prefix sdl3) - mkdir -p sdl3-macos - # Copy all versions of the SDL3 dynamic library - cp -a "${SDL3_PREFIX}/lib/libSDL3*.dylib" sdl3-macos/ || echo "No .dylib found, ignoring" - - # 7) Create minimal artifact folder (macOS) - - name: Create artifact folder (macOS) - run: | - mkdir _pack - cp build_macos/prosperon _pack/ - cp sdl3-macos/libSDL3*.dylib _pack/ || echo "No .dylib found, ignoring" - - # 8) Upload artifact (macOS) - - name: Upload Artifact (macOS) - uses: actions/upload-artifact@v3 - with: - name: prosperon-artifacts-macos - path: _pack \ No newline at end of file