Files
PR/.github/workflows/build-linux.yml
T
Zephyron f859a3622d ci: switch all workflows to fix/audio-biquad-filter-metroid-prime-4 branch
Update build workflows (Linux, macOS, Windows, Android), PKGBUILD, and
build-citron.sh to use the fix/audio-biquad-filter-metroid-prime-4 branch
for testing.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-05 16:52:04 +10:00

232 lines
8.1 KiB
YAML

name: Build Citron (Linux)
concurrency:
group: build-nightly-${{ github.ref }}
cancel-in-progress: true
on:
schedule:
- cron: "0 12 * * *"
workflow_dispatch: {}
jobs:
check-version:
name: Check if new version available
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.compare.outputs.should_build }}
new_hash: ${{ steps.upstream.outputs.hash_short }}
new_hash_full: ${{ steps.upstream.outputs.hash_full }}
steps:
- name: Checkout this repo
uses: actions/checkout@v4
- name: Get upstream commit hash
id: upstream
run: |
REPO_URL="https://git.citron-emu.org/Citron/Emulator.git"
BRANCH="fix/audio-biquad-filter-metroid-prime-4"
FULL_HASH=$(git ls-remote "$REPO_URL" "refs/heads/$BRANCH" | cut -f1)
SHORT_HASH=$(echo "$FULL_HASH" | cut -c1-7)
echo "hash_short=$SHORT_HASH" >> $GITHUB_OUTPUT
echo "hash_full=$FULL_HASH" >> $GITHUB_OUTPUT
echo "Upstream hash short: $SHORT_HASH"
echo "Upstream hash full: $FULL_HASH"
- name: Get last built version
id: last_built
run: |
LAST_HASH=$(cat LATEST_VERSION | tr -d '\n' || echo "none")
echo "last_hash=$LAST_HASH" >> $GITHUB_OUTPUT
echo "Last built hash: $LAST_HASH"
- name: Check if release exists
id: release_check
run: |
if gh release view nightly-linux --repo "${{ github.repository }}" > /dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Release exists"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Release does not exist"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
- name: Compare versions
id: compare
run: |
if [ "${{ steps.upstream.outputs.hash_short }}" != "${{ steps.last_built.outputs.last_hash }}" ]; then
echo "should_build=true" >> $GITHUB_OUTPUT
echo "āœ… New version detected - will build"
elif [ "${{ steps.release_check.outputs.exists }}" != "true" ]; then
echo "should_build=true" >> $GITHUB_OUTPUT
echo "āœ… No release exists - will build"
else
echo "should_build=false" >> $GITHUB_OUTPUT
echo "ā­ļø No changes - skipping build"
fi
build:
name: "${{ matrix.name }}"
needs: [check-version]
if: needs.check-version.outputs.should_build == 'true'
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
include:
- name: "Citron Build (Normal x86_64)"
os: ubuntu-latest
artifact_suffix: "_x86_64"
script_suffix: ""
build_arg: ""
- name: "Citron Build (Optimized x86_64)"
os: ubuntu-latest
artifact_suffix: "_v3"
script_suffix: "_v3"
build_arg: "v3"
- name: "Citron Build (aarch64)"
os: ubuntu-24.04-arm
artifact_suffix: "_aarch64"
script_suffix: ""
build_arg: ""
container: ghcr.io/pkgforge-dev/archlinux:latest
steps:
- name: Install Git
run: pacman -Syu --noconfirm --needed git
- name: Checkout Workflow Scripts
uses: actions/checkout@v4
- name: Checkout Upstream Source Code
run: git clone --recurse-submodules -b fix/audio-biquad-filter-metroid-prime-4 https://git.citron-emu.org/Citron/Emulator.git emulator
- name: Prepare Build Environment
run: |
mv get-dependencies.sh emulator/
mv build-citron.sh emulator/
mv package-citron.sh emulator/
- name: Add Git Safe Directory
working-directory: ./emulator
run: git config --global --add safe.directory "$PWD"
- name: Install dependencies
working-directory: ./emulator
run: chmod +x ./get-dependencies.sh && ./get-dependencies.sh
- name: Build Citron from source
working-directory: ./emulator
run: |
NPROC_VAL=$(nproc --all)
JOBS_VAL=$((NPROC_VAL > 4 ? 4 : NPROC_VAL))
chmod +x ./build-citron.sh
JOBS=${JOBS_VAL} DEVEL=true ./build-citron.sh ${{ matrix.build_arg }}
- name: Package AppImage with Correct Name
working-directory: ./emulator
run: |
GIT_SHA=$(git rev-parse --short HEAD)
export APP_VERSION="${GIT_SHA}"
export VERSION="${GIT_SHA}"
export ARCH_SUFFIX="${{ matrix.script_suffix }}"
export DEVEL="true"
chmod +x ./package-citron.sh
./package-citron.sh
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: Artifacts${{ matrix.artifact_suffix }}
path: emulator/dist/
release:
if: ${{ github.ref_name == 'main' }}
name: "release"
needs: [check-version, build]
permissions:
actions: read
security-events: write
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/checkout@v4
- name: Checkout Upstream Repository
run: git clone -b fix/audio-biquad-filter-metroid-prime-4 https://git.citron-emu.org/Citron/Emulator.git upstream_repo
- name: Set Version
id: version
working-directory: ./upstream_repo
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: Artifacts*
merge-multiple: true
path: .
- name: Del Previous Release
run: gh release delete "nightly-linux" --repo "${GITHUB_REPOSITORY}" --cleanup-tag -y && sleep 5
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
continue-on-error: true
- name: Set Build Date
run: echo "BUILD_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- uses: softprops/action-gh-release@v2
with:
name: "Continuous Build (Linux Nightly: ${{ steps.version.outputs.sha }})"
tag_name: "nightly-linux"
prerelease: true
draft: false
generate_release_notes: false
make_latest: false
files: |
*.AppImage*
*.tar.zst
body: |
**Citron Upstream Commit:** [`${{ needs.check-version.outputs.new_hash }}`](https://git.citron-emu.org/Citron/Emulator/commit/${{ needs.check-version.outputs.new_hash_full }})
This build is based on the latest Citron emulator source code from the upstream repository.
**Build Details:**
- Platform: Linux (x86_64, x86_64_v3, aarch64)
- Format: AppImage + tar.zst packages
- Build Type: Release with optimizations
- Date: ${{ env.BUILD_DATE }}
- name: Update LATEST_VERSION
if: success()
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
echo "${{ steps.version.outputs.sha }}" > LATEST_VERSION
git add LATEST_VERSION
git commit -m "Update LATEST_VERSION to ${{ steps.version.outputs.sha }} [skip ci]" || exit 0
for i in {1..5}; do
git pull --rebase origin main && git push && break || sleep 2
done
- name: Post to Discord
if: success()
run: |
DOWNLOAD_URL="https://github.com/${{ github.repository }}/releases/tag/nightly-linux"
DATE=$(date +'%Y-%m-%d')
WEBHOOK_URL="${{ secrets.DISCORD_WEBHOOK }}"
if [ -z "$WEBHOOK_URL" ]; then
WEBHOOK_URL="https://discord.com/api/webhooks/1428304731809517588/fG7t7MBprKFss5oGcI05DIFM3JdO41Z0juSV_zOfb9K-UTvyI2fd3-Ciwi48npWXYHLb"
fi
curl -H "Content-Type: application/json" \
-d "{\"content\":\"🐧 **New Linux Build Available!**\n\nšŸ“¦ **Version:** \`${{ steps.version.outputs.sha }}\`\nšŸ“… **Date:** ${DATE}\nšŸ”— **Download:** $DOWNLOAD_URL\n\n✨ Includes x86_64, x86_64_v3 & aarch64 builds!\"}" \
"$WEBHOOK_URL"