Update build action for more useful distribution
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

This commit is contained in:
2025-02-19 13:16:30 -06:00
parent dcd767e5f9
commit 29295607df
2 changed files with 139 additions and 21 deletions

View File

@@ -1,11 +1,10 @@
name: Build
name: Build and Deploy
on:
push:
branches: [ "*" ]
tags: [ "v*" ]
pull_request:
release:
types: [published]
jobs:
build-linux:
@@ -16,6 +15,16 @@ jobs:
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
@@ -33,7 +42,6 @@ jobs:
else
echo "SDL3 source is already present (possibly from cache)."
fi
mkdir -p sdl3-build
cd sdl3-build
cmake ../sdl3 -GNinja \
@@ -64,14 +72,14 @@ jobs:
path: build/meson-logs/testlog.txt
- name: Create artifact folder (Linux)
if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
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: ${{ github.event_name == 'release' && github.event.action == 'published' }}
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v3
with:
name: prosperon-artifacts-linux
@@ -85,6 +93,16 @@ jobs:
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
@@ -92,7 +110,7 @@ jobs:
path: |
sdl3-win
sdl3-build-win
key: sdl3-win-${{ hashFiles('sdl3-win/CMakeLists.txt') }}
key: sdl3-win-${{ hashFiles('sdl3-win/CMakeLists.txt') }}-v2
- name: Build SDL3 (Windows cross)
run: |
@@ -102,7 +120,6 @@ jobs:
else
echo "SDL3-win source already present (possibly from cache)."
fi
mkdir -p sdl3-build-win
cd sdl3-build-win
cmake ../sdl3-win -GNinja \
@@ -125,40 +142,49 @@ jobs:
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-linux
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: ${{ github.event_name == 'release' && github.event.action == 'published' }}
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v3
with:
name: prosperon-artifacts-windows
path: _pack
package-dist:
if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
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
@@ -175,21 +201,113 @@ jobs:
- name: Create the Dist Folder
run: |
mkdir dist
cp README.md dist/
cp license.txt dist/
cp -r examples dist/
# Make subdirectories for each platform
mkdir dist/linux
mkdir dist/win
# Copy artifacts in
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
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 }}

View File

@@ -1,5 +1,5 @@
[wrap-git]
url = https://github.com/johnalanbrook/quickjs.git
url = https://gitea.pockle.world/john/dull.git
revision = head
depth = 1