Skip to content

saving current build #1176

saving current build

saving current build #1176

Workflow file for this run

name: Build For Android
on:
push:
branches: ["main"]
workflow_dispatch:
inputs:
publish:
description: 'Publish engine'
required: true
default: 'no'
type: choice
options:
- 'no'
- 'yes'
jobs:
build:
if: (!endsWith(github.event.head_commit.message, '--norun'))
runs-on: ubuntu-latest
environment: Android
env:
ANDROID_RELEASE_STORE_PASSWORD: ${{ secrets.ANDROID_RELEASE_STORE_PASSWORD }}
ANDROID_RELEASE_KEY_PASSWORD: ${{ secrets.ANDROID_RELEASE_KEY_PASSWORD }}
ANDROID_RELEASE_KEY_PATH: ${{ vars.ANDROID_RELEASE_KEY_PATH }}
ANDROID_HOME: /usr/local/lib/android/sdk
CARGO_TERM_COLOR: always
steps:
# Setup Build Environment
- name: 🎉 The job was automatically triggered by a ${{ github.event_name }} event.
run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- name: 🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!
run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- name: 🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}.
run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: recursive
- name: 💡 The ${{ github.repository }} repository has been cloned to the runner.
run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
# Setup Java
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'graalvm'
java-version: '23'
# Setup Gradle Build Action (For Caching Builds) - ./app/.cxx|./app/build|./.gradle
- name: Setup Gradle Build Action (For Caching Builds)
uses: gradle/actions/setup-gradle@v3
# Install Dependencies
- name: Install and Cache APT Packages
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: unzip
version: 1.0
execute_install_scripts: true
# https://github.com/marketplace/actions/android-emulator-runner
# Install Screenshot Dependencies
# - name: Install and Cache Screenshot APT Packages
# uses: awalsh128/cache-apt-pkgs-action@latest
# with:
# packages: imagemagick pipewire libgl1-mesa-dri xvfb libxkbcommon-x11-dev
# version: 1.0
# execute_install_scripts: true
# Extract Keystore
- name: Extract Keystore
run: echo "${{ secrets.RELEASE_KEY }}" | base64 -d > ${{ vars.ANDROID_RELEASE_KEY_PATH }}
# Install Rust
- name: Make Tools Directory
run: mkdir -p ${{ github.workspace }}/tools
- name: Download Rust Installer
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > ${{ github.workspace }}/tools/rust.sh
- name: Make Rust Installer Executable
run: chmod +x ${{ github.workspace }}/tools/rust.sh
- name: Install Rust
run: ${{ github.workspace }}/tools/rust.sh -y
- name: Load Cargo Environment
run: source "$HOME/.cargo/env"
# Install Rust Nightly Toolchains
- name: Set Rust To The Nightly Toolchains
run: $HOME/.cargo/bin/rustup default nightly
# Setup Rust Build Caching
- uses: Swatinem/rust-cache@v2
with:
shared-key: "android-rust"
# Add Build Targets
- name: Add armv7 Android Build Target
run: $HOME/.cargo/bin/rustup target add armv7-linux-androideabi
- name: Add aarch64 Android Build Target
run: $HOME/.cargo/bin/rustup target add aarch64-linux-android
- name: Add i686 Android Build Target
run: $HOME/.cargo/bin/rustup target add i686-linux-android
- name: Add x86_64 Android Build Target
run: $HOME/.cargo/bin/rustup target add x86_64-linux-android
# Install Git Pre-Commit Hooks to Enforce Hooks
- name: Install Git Pre-Commit Hooks to Enforce Hooks
run: pip install pre-commit
# Check Pre-Commit Version
- name: Check Pre-Commit Version
run: pre-commit --version
# Install Pre-Commit Hooks
- name: Install Pre-Commit Hooks
run: pre-commit install
# Autoupdate Pre-Commit Hooks
# - name: Autoupdate Pre-Commit Hooks
# run: pre-commit autoupdate
# Check Files with Pre-Commit Hooks
- name: Check Files with Pre-Commit Hooks
run: pre-commit run --all-files
# Install Cargo-NDK
- name: Install Cargo-NDK
run: cargo install cargo-ndk
# Workaround Cargo Gradle Plugin Bug
- name: Workaround Cargo Gradle Plugin Bug
run: touch ${{ github.workspace }}/android/local.properties
# Extract/Import GPG Signing Key
- name: Extract GPG Signing Key
run: |
echo "${{ secrets.GPG_SIGNING_KEY }}" > $HOME/signing.gpg
gpg --import $HOME/signing.gpg
# Ignore Modifying android/app/build.gradle
- name: Ignore Modifying ${{ github.workspace }}/android/app/build.gradle
run: |
cd ${{ github.workspace }}
git update-index --skip-worktree ${{ github.workspace }}/android/app/build.gradle
# Build Engine As APK
- name: Build CatgirlEngine APK (FAT)
working-directory: ${{ github.workspace }}/android
run: |
export RUSTFLAGS="-Z threads=`nproc --all`" # -Z self-profile -Z time-passes
${{ github.workspace }}/android/gradlew assembleRelease
mkdir -p ${{ github.workspace }}/upload/android
cp -a ${{ github.workspace }}/android/app/build/outputs/apk/release/app-release.apk ${{ github.workspace }}/upload/android/catgirl-engine-fat.apk
#cp -a ${{ github.workspace }}/android/app/build/outputs/bundle/release/app-release.aab ${{ github.workspace }}/upload/android
# Build Engine As APK
- name: Build CatgirlEngine APK (arm64)
working-directory: ${{ github.workspace }}/android
run: |
export RUSTFLAGS="-Z threads=`nproc --all`" # -Z self-profile -Z time-passes
# export CARGO_NDK_ANDROID_TARGET="arm64-v8a"
sed -i "s/targets = [\"[a-z_0-9, ]*\"]/targets = [\"arm64\"]/" ${{ github.workspace }}/android/app/build.gradle
rm -rf ${{ github.workspace }}/android/app/src/main/jniLibs
${{ github.workspace }}/android/gradlew clean
${{ github.workspace }}/android/gradlew assembleRelease
mkdir -p ${{ github.workspace }}/upload/android
cp -a ${{ github.workspace }}/android/app/build/outputs/apk/release/app-release.apk ${{ github.workspace }}/upload/android/catgirl-engine-arm64.apk
# Build Engine As APK
- name: Build CatgirlEngine APK (armeabi-v7a)
working-directory: ${{ github.workspace }}/android
run: |
export RUSTFLAGS="-Z threads=`nproc --all`" # -Z self-profile -Z time-passes
# export CARGO_NDK_ANDROID_TARGET="armeabi-v7a"
sed -i "s/targets = [\"[a-z_0-9, ]*\"]/targets = [\"arm\"]/" ${{ github.workspace }}/android/app/build.gradle
rm -rf ${{ github.workspace }}/android/app/src/main/jniLibs
${{ github.workspace }}/android/gradlew clean
${{ github.workspace }}/android/gradlew assembleRelease
mkdir -p ${{ github.workspace }}/upload/android
cp -a ${{ github.workspace }}/android/app/build/outputs/apk/release/app-release.apk ${{ github.workspace }}/upload/android/catgirl-engine-armeabi-v7a.apk
# Build Engine As APK
- name: Build CatgirlEngine APK (x86)
working-directory: ${{ github.workspace }}/android
run: |
export RUSTFLAGS="-Z threads=`nproc --all`" # -Z self-profile -Z time-passes
# export CARGO_NDK_ANDROID_TARGET="x86"
sed -i "s/targets = [\"[a-z_0-9, ]*\"]/targets = [\"x86\"]/" ${{ github.workspace }}/android/app/build.gradle
rm -rf ${{ github.workspace }}/android/app/src/main/jniLibs
${{ github.workspace }}/android/gradlew clean
${{ github.workspace }}/android/gradlew assembleRelease
mkdir -p ${{ github.workspace }}/upload/android
cp -a ${{ github.workspace }}/android/app/build/outputs/apk/release/app-release.apk ${{ github.workspace }}/upload/android/catgirl-engine-x86.apk
# Build Engine As APK
- name: Build CatgirlEngine APK (x86_64)
working-directory: ${{ github.workspace }}/android
run: |
export RUSTFLAGS="-Z threads=`nproc --all`" # -Z self-profile -Z time-passes
# export CARGO_NDK_ANDROID_TARGET="x86_64"
sed -i "s/targets = [\"[a-z_0-9, ]*\"]/targets = [\"x86_64\"]/" ${{ github.workspace }}/android/app/build.gradle
rm -rf ${{ github.workspace }}/android/app/src/main/jniLibs
${{ github.workspace }}/android/gradlew clean
${{ github.workspace }}/android/gradlew assembleRelease
mkdir -p ${{ github.workspace }}/upload/android
cp -a ${{ github.workspace }}/android/app/build/outputs/apk/release/app-release.apk ${{ github.workspace }}/upload/android/catgirl-engine-x86_64.apk
# We no longer use the Play Store, but if another store uses AAB, we can enable it
# # Build Engine As AAB
# - name: Build CatgirlEngine AAB
# working-directory: ${{ github.workspace }}/android
# run: |
# export RUSTFLAGS="-Z threads=`nproc --all`" # -Z self-profile -Z time-passes
# ${{ github.workspace }}/android/gradlew bundleRelease
# Display Export Directory
- name: Display Git Staging
run: |
cd ${{ github.workspace }}
git status -v -s -b
# Display APK Directory
- name: Display APK Directory (Release)
run: ls -liallh ${{ github.workspace }}/android/app/build/outputs/apk/release
# # Display Bundle Directory
# - name: Display Bundle Directory (Release)
# run: ls -liallh ${{ github.workspace }}/android/app/build/outputs/bundle/release
# Prepare Artifact Uploads
- name: Prepare Artifact Uploads (Client/Server)
run: |
mkdir -p ${{ github.workspace }}/upload/android
cp -a ${{ github.workspace }}/target/binding ${{ github.workspace }}/upload/android
# Sign Files
- name: Sign Files (Client/Server)
run: |
cd ${{ github.workspace }}/upload/android
find . -type f -not -name "checksums.sha512" -exec shasum -a 512 {} \; > checksums.sha512
gpg --sign checksums.sha512
# Compress Files
- name: Compress Files (Client/Server)
run: |
export XZ_OPT=-e9
cd ${{ github.workspace }}/upload/android
tar cvJf ${{ github.workspace }}/upload/CatgirlEngine-Android.tar.xz .
# Upload Engine
- name: Upload Engine (Release)
uses: actions/upload-artifact@v4
with:
name: CatgirlEngine-Android
path: ${{ github.workspace }}/upload/CatgirlEngine-Android.tar.xz
include-hidden-files: true
# Install Code Size Profiler
- name: Install Code Size Profiler
run: |
export RUSTFLAGS="-Z threads=`nproc --all`"
$HOME/.cargo/bin/cargo install -j `nproc --all` twiggy
# Profile Code Size
- name: Profile Code Size (aarch64)
run: $HOME/.cargo/bin/twiggy top -n 20 "${{ github.workspace }}/target/aarch64-linux-android/release/libmain.so"
# Profile Code Size
- name: Profile Code Size (armv7)
run: $HOME/.cargo/bin/twiggy top -n 20 "${{ github.workspace }}/target/armv7-linux-androideabi/release/libmain.so"
# Profile Code Size
- name: Profile Code Size (i686)
run: $HOME/.cargo/bin/twiggy top -n 20 "${{ github.workspace }}/target/i686-linux-android/release/libmain.so"
# Profile Code Size
- name: Profile Code Size (x86_64)
run: $HOME/.cargo/bin/twiggy top -n 20 "${{ github.workspace }}/target/x86_64-linux-android/release/libmain.so"
# Install Miri
# - name: Install Miri
# run: |
# rustup toolchain install nightly --component miri
# rustup override set nightly
# $HOME/.cargo/bin/cargo miri setup --target=armv7-linux-androideabi
# $HOME/.cargo/bin/cargo miri setup --target=aarch64-linux-android
# $HOME/.cargo/bin/cargo miri setup --target=i686-linux-android
# $HOME/.cargo/bin/cargo miri setup --target=x86_64-linux-android
# Run Miri Tests (armv7-linux-androideabi)
# - name: Run Miri Tests (armv7-linux-androideabi)
# run: |
# # https://github.com/rust-lang/miri?tab=readme-ov-file#running-tests-in-parallel
# export RUSTFLAGS="-Z threads=`nproc --all`"
# $HOME/.cargo/bin/cargo miri test --workspace -j `nproc --all` --target=armv7-linux-androideabi --bins --tests --benches --examples
# # $HOME/.cargo/bin/cargo miri nextest run -j`nproc --all`
# Run Miri Tests (aarch64-linux-android)
# - name: Run Miri Tests (aarch64-linux-android)
# run: |
# # https://github.com/rust-lang/miri?tab=readme-ov-file#running-tests-in-parallel
# export RUSTFLAGS="-Z threads=`nproc --all`"
# $HOME/.cargo/bin/cargo miri test --workspace -j `nproc --all` --target=aarch64-linux-android --bins --tests --benches --examples
# # $HOME/.cargo/bin/cargo miri nextest run -j`nproc --all`
# Run Miri Tests (i686-linux-android)
# - name: Run Miri Tests (i686-linux-android)
# run: |
# # https://github.com/rust-lang/miri?tab=readme-ov-file#running-tests-in-parallel
# export RUSTFLAGS="-Z threads=`nproc --all`"
# $HOME/.cargo/bin/cargo miri test --workspace -j `nproc --all` --target=i686-linux-android --bins --tests --benches --examples
# # $HOME/.cargo/bin/cargo miri nextest run -j`nproc --all`
# Run Miri Tests (x86_64-linux-android)
# - name: Run Miri Tests (x86_64-linux-android)
# run: |
# # https://github.com/rust-lang/miri?tab=readme-ov-file#running-tests-in-parallel
# export RUSTFLAGS="-Z threads=`nproc --all`"
# $HOME/.cargo/bin/cargo miri test --workspace -j `nproc --all` --target=x86_64-linux-android --bins --tests --benches --examples
# # $HOME/.cargo/bin/cargo miri nextest run -j`nproc --all`
# List Environment
- name: List Environment
run: env
- name: List All Installed Packages
run: |
apt list --installed | wc -l
apt list --installed
- name: List All Files
run: find ${{ github.workspace }}
# Display Build Status
- name: 🍏 This job's status is ${{ job.status }}.
run: echo "🍏 This job's status is ${{ job.status }}."
deploy:
if: ${{ success() && (endsWith(github.event.head_commit.message, '--publish') || inputs.publish == 'yes') }}
needs: [Build]
runs-on: ubuntu-latest
environment: Android
env:
BUTLER_API_KEY: ${{ secrets.ITCH_IO_API_KEY }}
GH_TOKEN: ${{ github.token }}
permissions:
# See https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
# See https://docs.github.com/en/rest/overview/permissions-required-for-fine-grained-personal-access-tokens
contents: write
steps:
# Setup Build Environment
- name: 🎉 The job was automatically triggered by a ${{ github.event_name }} event.
run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- name: 🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!
run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- name: 🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}.
run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: recursive
- name: 💡 The ${{ github.repository }} repository has been cloned to the runner.
run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
# Install Dependencies
# - name: Install and Cache APT Packages
# uses: awalsh128/cache-apt-pkgs-action@latest
# with:
# packages: ruby-bundler # jq coreutils gitsome
# version: 1.0
# execute_install_scripts: true
# Download APK
- name: Download APK (Release)
uses: actions/download-artifact@v4
with:
name: CatgirlEngine-Android
path: ${{ github.workspace }}/artifacts
# Compress Files
- name: Extract Files (Client/Server)
run: |
mkdir -p ${{ github.workspace }}/artifacts/android
cd ${{ github.workspace }}/artifacts
tar xvf ${{ github.workspace }}/artifacts/CatgirlEngine-Android.tar.xz -C android
# Create Tag and Github Release
- name: 👩‍💻 Create Tag and Github Release
run: |
# TODO: Consider checking for -alpha and -beta to filter onto other packages
export VERSION=`cat ${{ github.workspace }}/Cargo.toml | grep '^version' | head -n1 | cut -d'"' -f2 | tr -d '\n'`
export VERSION_STRING="Catgirl Engine v$VERSION"
export BODY="Autogenerated Release From Github Actions..."
export DRAFT="false"
export PRERELEASE="false"
export LATEST="true"
export GENERATE_RELEASE_NOTES="true"
export BRANCH=`git branch --show-current --format="%s" | tr -d '\n'`
# export COMMIT=`git log -1 --oneline | cut -d' ' -f1 | tr -d '\n'`
gh api --method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/releases \
-f tag_name="v$VERSION" \
-f target_commitish="$BRANCH" \
-f name="$VERSION_STRING" \
-f body="$BODY" \
-f make_latest="$LATEST" \
-F draft="$DRAFT" \
-F prerelease="$PRERELEASE" \
-F generate_release_notes="$GENERATE_RELEASE_NOTES" || echo "Already Exists"
# Publish to Github Release
- name: 👩‍💻 Publish to Github Release (Tar)
run: |
export VERSION=`cat ${{ github.workspace }}/Cargo.toml | grep '^version' | head -n1 | cut -d'"' -f2 | tr -d '\n'`
export ARTIFACT_PATH="${{ github.workspace }}/artifacts/CatgirlEngine-Android.tar.xz"
export DISPLAY_LABEL="Android (Tar)"
gh release upload v$VERSION "$ARTIFACT_PATH"#"$DISPLAY_LABEL" -R ${{ github.repository }}
# Publish to Github Release
- name: 👩‍💻 Publish to Github Release (FAT)
run: |
export VERSION=`cat ${{ github.workspace }}/Cargo.toml | grep '^version' | head -n1 | cut -d'"' -f2 | tr -d '\n'`
export ARTIFACT_PATH="${{ github.workspace }}/artifacts/android/catgirl-engine-fat.apk"
export DISPLAY_LABEL="Android (FAT)"
gh release upload v$VERSION "$ARTIFACT_PATH"#"$DISPLAY_LABEL" -R ${{ github.repository }}
# Publish to Github Release
- name: 👩‍💻 Publish to Github Release (arm64)
run: |
export VERSION=`cat ${{ github.workspace }}/Cargo.toml | grep '^version' | head -n1 | cut -d'"' -f2 | tr -d '\n'`
export ARTIFACT_PATH="${{ github.workspace }}/artifacts/android/catgirl-engine-arm64.apk"
export DISPLAY_LABEL="Android (arm64)"
gh release upload v$VERSION "$ARTIFACT_PATH"#"$DISPLAY_LABEL" -R ${{ github.repository }}
# Publish to Github Release
- name: 👩‍💻 Publish to Github Release (armeabi-v7a)
run: |
export VERSION=`cat ${{ github.workspace }}/Cargo.toml | grep '^version' | head -n1 | cut -d'"' -f2 | tr -d '\n'`
export ARTIFACT_PATH="${{ github.workspace }}/artifacts/android/catgirl-engine-armeabi-v7a.apk"
export DISPLAY_LABEL="Android (armeabi-v7a)"
gh release upload v$VERSION "$ARTIFACT_PATH"#"$DISPLAY_LABEL" -R ${{ github.repository }}
# Publish to Github Release
- name: 👩‍💻 Publish to Github Release (x86)
run: |
export VERSION=`cat ${{ github.workspace }}/Cargo.toml | grep '^version' | head -n1 | cut -d'"' -f2 | tr -d '\n'`
export ARTIFACT_PATH="${{ github.workspace }}/artifacts/android/catgirl-engine-x86.apk"
export DISPLAY_LABEL="Android (x86)"
gh release upload v$VERSION "$ARTIFACT_PATH"#"$DISPLAY_LABEL" -R ${{ github.repository }}
# Publish to Github Release
- name: 👩‍💻 Publish to Github Release (x86_64)
run: |
export VERSION=`cat ${{ github.workspace }}/Cargo.toml | grep '^version' | head -n1 | cut -d'"' -f2 | tr -d '\n'`
export ARTIFACT_PATH="${{ github.workspace }}/artifacts/android/catgirl-engine-x86_64.apk"
export DISPLAY_LABEL="Android (x86_64)"
gh release upload v$VERSION "$ARTIFACT_PATH"#"$DISPLAY_LABEL" -R ${{ github.repository }}
# Install Butler (For Uploading to Itch.io)
- name: Install Butler (Upload to Itch.io)
run: |
# https://itch.io/docs/butler/pushing.html#channel-names
# Setup For Installation
mkdir -p ${{ github.workspace }}/tools/butler
# Install Butler
wget https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default -O ${{ github.workspace }}/butler-linux-amd64.zip
unzip ${{ github.workspace }}/butler-linux-amd64.zip -d ${{ github.workspace }}/tools/butler
# Publish to Itch.io
- name: 🎮 Publish to Itch.io
run: |
# Upload App
${{ github.workspace }}/tools/butler/butler push ${{ github.workspace }}/artifacts/android/catgirl-engine-fat.apk fomxgorl/catgirl-engine:android
${{ github.workspace }}/tools/butler/butler push ${{ github.workspace }}/artifacts/android/catgirl-engine-arm64.apk fomxgorl/catgirl-engine:android-arm64
${{ github.workspace }}/tools/butler/butler push ${{ github.workspace }}/artifacts/android/catgirl-engine-armeabi-v7a.apk fomxgorl/catgirl-engine:android-armeabi-v7a
${{ github.workspace }}/tools/butler/butler push ${{ github.workspace }}/artifacts/android/catgirl-engine-x86.apk fomxgorl/catgirl-engine:android-x86
${{ github.workspace }}/tools/butler/butler push ${{ github.workspace }}/artifacts/android/catgirl-engine-x86_64.apk fomxgorl/catgirl-engine:android-x86_64