Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Enhance Android build process in GitHub Actions: add Java setup, Andr… #19

Enhance Android build process in GitHub Actions: add Java setup, Andr…

Enhance Android build process in GitHub Actions: add Java setup, Andr… #19

Workflow file for this run

name: Build and Notify
description: Build the project for different platforms and notify via Discord
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
Args: "-D officialBuild -D NotDeveloper"
jobs:
setup-haxe:
name: Setup and Cache Haxe Dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v4
with:
path: ~/.haxelib
key: ${{ runner.os }}-haxe-${{ hashFiles('**/*.hxml') }}
buildLinux:
name: Build on Linux
runs-on: ubuntu-latest
needs: setup-haxe
steps:
- name: Checkout Code
uses: actions/checkout@v4.1.7
- name: Setup Haxe
uses: krdlab/setup-haxe@master
with:
haxe-version: 4.3.6
- name: Install Dependencies & Setup
run: |
sudo apt-get update
sudo apt-get install -y libvlc-dev libvlccore-dev
haxelib setup ~/haxelib
haxelib install hxcpp --quiet
chmod +x ./setup/unix.sh
./setup/unix.sh
- name: Create Version Tag
run: echo "${{ github.run_id }}" > VERSION
- name: Compile for Linux
run: haxelib run lime build Project.xml linux --app-version="4.0.0-${{ github.run_id }}" $Args
- name: Upload Artifact
uses: actions/upload-artifact@v4.3.4
with:
name: linuxBuild
path: export/release/linux/bin
buildWindows64:
name: Build on Windows (64-bit)
runs-on: windows-latest
needs: setup-haxe
steps:
- uses: actions/checkout@v4.1.7
- uses: krdlab/setup-haxe@master
with:
haxe-version: 4.3.6
- run: |
haxelib setup C:/haxelib
haxelib install hxcpp --quiet
setup\windows.bat
shell: cmd
- run: echo "${{ github.run_id }}" > VERSION
shell: bash
- run: haxelib run lime build windows --app-version="4.0.0-${{ github.run_id }}" $Args
- uses: actions/upload-artifact@v4.3.4
with:
name: windowsBuild64
path: export/release/windows/bin
buildWindows32:
name: Build on Windows (32-bit)
runs-on: windows-latest
needs: setup-haxe
steps:
- uses: actions/checkout@v4.1.7
- uses: krdlab/setup-haxe@master
with:
haxe-version: 4.3.6
- run: |
haxelib setup C:/haxelib
haxelib install hxcpp --quiet
setup\windows.bat
shell: cmd
- run: echo "${{ github.run_id }}" > VERSION
shell: bash
- run: haxelib run lime build windows -32 --app-version="4.0.0-${{ github.run_id }}" $Args
- uses: actions/upload-artifact@v4.3.4
with:
name: windowsBuild32
path: export/release/windows/bin
buildMac:
name: Build on macOS (Universal)
runs-on: macos-13
needs: setup-haxe
steps:
- uses: actions/checkout@v4.1.7
- uses: krdlab/setup-haxe@master
with:
haxe-version: 4.3.6
- run: |
haxelib setup ~/haxelib
haxelib install hxcpp --quiet
haxelib install lime --quiet
haxelib run lime rebuild lime mac -64
haxelib run lime rebuild lime mac -Dmac-catalyst -Dmac-arm64
chmod +x ./setup/unix.sh
./setup/unix.sh
- run: echo "${{ github.run_id }}" > VERSION
- run: haxelib run lime build mac --app-version="4.0.0-${{ github.run_id }}" $Args
- uses: actions/upload-artifact@v4.3.4
with:
name: macBuild
path: export/release/macos/bin
buildWeb:
name: Build Web (HTML5)
runs-on: ubuntu-latest
needs: setup-haxe
steps:
- uses: actions/checkout@v4.1.7
- uses: krdlab/setup-haxe@master
with:
haxe-version: 4.3.6
- run: |
haxelib setup ~/haxelib
haxelib install lime --quiet
haxelib install openfl --quiet
chmod +x ./setup/unix.sh
./setup/unix.sh
- run: echo "${{ github.run_id }}" > VERSION
- run: haxelib run lime build html5 --app-version="4.0.0-${{ github.run_id }}" $Args
- uses: actions/upload-artifact@v4.3.4
with:
name: webBuild
path: export/release/html5/bin
buildAndroid:
name: Build Android
runs-on: ubuntu-latest
needs: setup-haxe # Dependency remains, though the cache job itself might have limited direct impact here
steps:
- name: Checkout Code
uses: actions/checkout@v4.1.7
# 1. Setup Java (Required for Android SDK tools)
- name: Setup Java JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin' # Or another distribution like 'zulu'
java-version: '11' # JDK 11 is widely compatible for Android. Use '17' if needed.
# 2. Setup Haxe
- name: Setup Haxe
uses: krdlab/setup-haxe@master
with:
haxe-version: 4.3.6
# 3. Setup Android SDK & NDK
# This action downloads and sets up the necessary Android components
# and sets environment variables like ANDROID_HOME, ANDROID_SDK_ROOT
- name: Setup Android SDK
uses: android-actions/setup-android@v3 # Use the latest stable version
# 4. Install Haxe Dependencies (using your existing script)
- name: Install Haxe Dependencies
run: |
haxelib setup ~/haxelib
# Install core libs needed before running setup script or lime commands
# (Ensure these are present even if list.haxelib also lists them)
haxelib install hxcpp --quiet
haxelib install lime --quiet
haxelib install openfl --quiet
# Run the project's specific dependency script
chmod +x ./setup/unix.sh
./setup/unix.sh
# 5. Create Version Tag
- name: Create Version Tag
run: echo "${{ github.run_id }}" > VERSION
# 6. Setup Lime for Android and Build
# Now that JDK/SDK/NDK are present, this should work
- name: Setup Lime and Build Android
# The setup-android action usually sets necessary env vars (like ANDROID_SDK_ROOT)
run: |
haxelib run lime setup android
haxelib run lime build android --app-version="4.0.0-${{ github.run_id }}" $Args
# 7. Upload Artifact
- name: Upload Artifact
uses: actions/upload-artifact@v4.3.4
with:
name: androidBuild
# Double-check this path is correct for your project's Android output
path: export/release/android/bin
buildiOS:
name: Build iOS
runs-on: macos-13
needs: setup-haxe
steps:
- name: Checkout Code
uses: actions/checkout@v4.1.7
- name: Setup Haxe
uses: krdlab/setup-haxe@master
with:
haxe-version: 4.3.6
- name: Install Haxe Dependencies
run: |
haxelib setup ~/haxelib
# Ensure core libs needed for iOS build are present
haxelib install hxcpp --quiet # Often needed by Lime targets
haxelib install lime --quiet
haxelib install openfl --quiet
# Run the project's specific dependency script
chmod +x ./setup/unix.sh
./setup/unix.sh
- name: Create Version Tag
run: echo "${{ github.run_id }}" > VERSION
- name: Build for iOS Simulator
run: haxelib run lime build ios --app-version="4.0.0-${{ github.run_id }}" $Args
- name: Upload Artifact
uses: actions/upload-artifact@v4.3.4
with:
name: iosSimulatorBuild
path: export/release/ios/build/Release-iphonesimulator/*.app
notifyDiscord:
name: 📣 Notify Discord
runs-on: ubuntu-latest
if: always()
needs: [setup-haxe, buildLinux, buildWindows64, buildWindows32, buildMac, buildWeb, buildAndroid, buildiOS]
steps:
- name: Get Commit Info
id: commit
run: |
MESSAGE=$(git log -1 --pretty=%B | head -n 1)
AUTHOR=$(git log -1 --pretty=%an)
echo "message=${MESSAGE}" >> $GITHUB_OUTPUT
echo "author=${AUTHOR}" >> $GITHUB_OUTPUT
- name: Send Enhanced Notification
env:
WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
RUN_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
COMMIT_URL: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
REPO_URL: https://github.com/${{ github.repository }}
BRANCH: ${{ github.ref_name }}
run: |
# Function to generate status emoji and color
status_ui() {
case "$1" in
"success") echo -e "🟢 Success\n#00FF00" ;;
"failure") echo -e "🔴 Failed\n#FF0000" ;;
"cancelled") echo -e "🟡 Cancelled\n#FFFF00" ;;
*) echo -e "⚪ Skipped\n#AAAAAA" ;;
esac
}
# Generate platform status fields
generate_fields() {
echo -n '"fields": ['
echo -n '{"name": "Platform", "value": "Linux\nWindows 64\nWindows 32\nmacOS\nWeb\nAndroid\niOS", "inline": true},'
echo -n '{"name": "Status", "value": "'
echo -n "$(status_ui ${{ needs.buildLinux.result }} | head -n 1)\n"
echo -n "$(status_ui ${{ needs.buildWindows64.result }} | head -n 1)\n"
echo -n "$(status_ui ${{ needs.buildWindows32.result }} | head -n 1)\n"
echo -n "$(status_ui ${{ needs.buildMac.result }} | head -n 1)\n"
echo -n "$(status_ui ${{ needs.buildWeb.result }} | head -n 1)\n"
echo -n "$(status_ui ${{ needs.buildAndroid.result }} | head -n 1)\n"
echo -n "$(status_ui ${{ needs.buildiOS.result }} | head -n 1)"
echo -n '", "inline": true},'
echo -n '{"name": "Details", "value": "'
echo -n "**Branch:** [$BRANCH]($REPO_URL/tree/$BRANCH)\n"
echo -n "**Commit:** [${GITHUB_SHA:0:7}]($COMMIT_URL)\n"
echo -n "**Author:** ${{ steps.commit.outputs.author }}\n"
echo -n "**Message:** ${{ steps.commit.outputs.message }}"
echo -n '", "inline": false}'
echo '],'
}
# Determine overall status
if [[ "${{ needs.buildLinux.result }}" != "success" ]] ||
[[ "${{ needs.buildWindows64.result }}" != "success" ]] ||
[[ "${{ needs.buildWindows32.result }}" != "success" ]] ||
[[ "${{ needs.buildMac.result }}" != "success" ]] ||
[[ "${{ needs.buildWeb.result }}" != "success" ]] ||
[[ "${{ needs.buildAndroid.result }}" != "success" ]] ||
[[ "${{ needs.buildiOS.result }}" != "success" ]]; then
OVERALL="failure"
TITLE="🚨 Build Failed"
else
OVERALL="success"
TITLE="🎉 Build Successful"
fi
COLOR=$(status_ui $OVERALL | tail -n 1)
# Send the webhook
curl -H "Content-Type: application/json" -X POST -d "{
\"username\": \"GitHub Actions\",
\"avatar_url\": \"https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png\",
\"embeds\": [{
\"title\": \"$TITLE - ${{ github.workflow }}\",
\"url\": \"$RUN_URL\",
\"color\": $(echo $COLOR | sed 's/#//g'),
\"thumbnail\": {\"url\": \"https://haxe.org/img/haxe-logo.svg\"},
$(generate_fields)
\"footer\": {
\"text\": \"Triggered by ${{ github.actor }} • $(date +'%Y-%m-%d %H:%M:%S %Z')\",
\"icon_url\": \"https://cdn.discordapp.com/emojis/741605543046807552.png\"
}
}],
\"components\": [{
\"type\": 1,
\"components\": [
{\"type\": 2, \"label\": \"View Workflow\", \"style\": 5, \"url\": \"$RUN_URL\"},
{\"type\": 2, \"label\": \"View Commit\", \"style\": 5, \"url\": \"$COMMIT_URL\"},
{\"type\": 2, \"label\": \"View Repository\", \"style\": 5, \"url\": \"$REPO_URL\"}
]
}]
}" $WEBHOOK