241 lines
7.1 KiB
YAML
241 lines
7.1 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@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Build Prosperon (Linux)
|
|
run: |
|
|
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
|
|
strip build/prosperon
|
|
|
|
- name: Upload Test Log (Linux)
|
|
if: ${{ always() }}
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: testlog-linux
|
|
path: build/meson-logs/testlog.txt
|
|
|
|
- name: Upload Artifact (Linux)
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: prosperon-artifacts-linux
|
|
path: build/prosperon
|
|
|
|
build-windows:
|
|
runs-on: win-native
|
|
strategy:
|
|
matrix:
|
|
msystem: [CLANG64]
|
|
|
|
steps:
|
|
- name: Check Out Code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup MSYS2
|
|
uses: msys2/setup-msys2@v2
|
|
with:
|
|
msystem: ${{ matrix.msystem }}
|
|
update: true
|
|
cache: true
|
|
install: |
|
|
git
|
|
zip
|
|
gzip
|
|
tar
|
|
base-devel
|
|
pacboy: |
|
|
meson
|
|
cmake
|
|
toolchain
|
|
|
|
- name: Build Prosperon
|
|
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
|
|
shell: msys2 {0}
|
|
env:
|
|
TRACY_NO_INVARIANT_CHECK: 1
|
|
run: |
|
|
meson test --print-errorlogs -C build
|
|
strip build/prosperon.exe
|
|
|
|
- name: Upload Test Log
|
|
if: ${{ always() }}
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: testlog-windows
|
|
path: build/meson-logs/testlog.txt
|
|
|
|
- name: Upload Artifact (Windows)
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: prosperon-artifacts-windows
|
|
path: build/prosperon.exe
|
|
|
|
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]
|
|
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 }} |