improve it #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release | |
on: | |
push: | |
branches: [ axis ] | |
tags: | |
- 'v*.*.*' | |
pull_request: | |
branches: [ axis ] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: write | |
jobs: | |
android-build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
abi: [arm64-v8a, armeabi-v7a, x86_64, x86] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Setup Android SDK | |
uses: android-actions/setup-android@v3 | |
- name: Setup NDK | |
uses: nttld/setup-ndk@v1 | |
with: | |
ndk-version: r25c | |
local-cache: true | |
- name: Install Build Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y cmake ninja-build | |
- name: Install xmake | |
run: | | |
wget https://xmake.io/shget.text -O - | bash | |
source ~/.xmake/profile | |
- name: Set SDK and NDK path | |
run: | | |
echo "SDK_PATH=$ANDROID_SDK_ROOT" >> $GITHUB_ENV | |
echo "NDK_PATH=$ANDROID_NDK_ROOT" >> $GITHUB_ENV | |
- name: Cache SDL builds | |
uses: actions/cache@v3 | |
with: | |
path: | | |
vendor/SDL/build-android-prefab | |
android/app/libs | |
key: ${{ runner.os }}-sdl-${{ matrix.abi }}-${{ hashFiles('vendor/SDL/**') }} | |
restore-keys: | | |
${{ runner.os }}-sdl-${{ matrix.abi }}- | |
- name: Build SDL2 | |
run: | | |
if [ ! -f "android/app/libs/SDL2-*.aar" ]; then | |
cd vendor/SDL/build-scripts | |
chmod +x android-prefab.sh | |
./android-prefab.sh | |
mkdir -p ../../../android/app/libs | |
SDL_AAR=$(find ../build-android-prefab/prefab-* -name "SDL2-*.aar") | |
cp "$SDL_AAR" ../../../android/app/libs/ | |
fi | |
- name: Build SDL Dependencies | |
run: | | |
xmake build_sdl_android --ARCH=${{ matrix.abi }} | |
- name: Build Android Project | |
run: | | |
xmake f -p android --arch=${{ matrix.abi }} --ndk=$ANDROID_NDK_ROOT | |
xmake | |
- name: Decode Keystore | |
run: | | |
mkdir -p android/app/app | |
echo "${{ secrets.RELEASE_KEYSTORE }}" > release.keystore.base64 | |
base64 -d release.keystore.base64 > android/app/app/release.keystore | |
- name: Setup Gradle | |
run: | | |
cd android | |
if [ ! -f "gradlew" ]; then | |
gradle wrapper | |
fi | |
chmod +x gradlew | |
- name: Build Release APK | |
env: | |
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
run: | | |
cd android | |
./gradlew clean | |
./gradlew assembleRelease --warning-mode all | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: android-release-apk-${{ matrix.abi }} | |
path: android/app/build/outputs/apk/release/app-${{ matrix.abi }}-release.apk | |
linux-build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update | |
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \ | |
build-essential \ | |
clang \ | |
lld \ | |
cmake \ | |
ninja-build \ | |
pkg-config \ | |
wget \ | |
git \ | |
libsdl2-dev \ | |
libsdl2-image-dev \ | |
libsdl2-ttf-dev \ | |
libsdl2-gfx-dev | |
- name: Install xmake | |
run: | | |
wget https://xmake.io/shget.text -O - | bash | |
source ~/.xmake/profile | |
- name: Build | |
run: | | |
xmake f -p linux -y | |
xmake -y | |
mkdir -p artifacts/myquest-linux-x86_64 | |
cp build/clay/main artifacts/myquest-linux-x86_64/myquest | |
cp -r fonts artifacts/myquest-linux-x86_64/ | |
cp -r images artifacts/myquest-linux-x86_64/ | |
chmod +x artifacts/myquest-linux-x86_64/myquest | |
cd artifacts | |
tar czf myquest-linux-x86_64.tar.gz myquest-linux-x86_64/ | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: linux-x86_64-build | |
path: artifacts/myquest-linux-x86_64.tar.gz | |
create-release: | |
needs: [android-build, linux-build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Android Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: android-artifacts | |
- name: Download Linux Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: linux-artifacts | |
- name: Display structure of downloaded files | |
run: ls -R | |
- name: Generate date | |
id: date | |
if: "!startsWith(github.ref, 'refs/tags/')" | |
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT | |
- name: Create Nightly Release | |
if: "!startsWith(github.ref, 'refs/tags/')" | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: nightly-${{ steps.date.outputs.date }} | |
name: Development Build ${{ steps.date.outputs.date }} | |
draft: false | |
prerelease: true | |
files: | | |
android-artifacts/android-release-apk-*/app-*-release.apk | |
linux-artifacts/linux-x86_64-build/myquest-linux-x86_64.tar.gz | |
- name: Create Tagged Release | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref_name }} | |
name: Release ${{ github.ref_name }} | |
draft: false | |
prerelease: false | |
generate_release_notes: true | |
files: | | |
android-artifacts/android-release-apk-*/app-*-release.apk | |
linux-artifacts/linux-x86_64-build/myquest-linux-x86_64.tar.gz |