Skip to content

Experimental Mobile Support #178

Experimental Mobile Support

Experimental Mobile Support #178

Workflow file for this run

name: Build
on:
workflow_dispatch:
push:
paths:
- '.github/workflows/build.yml'
- 'package.json'
- 'src-tauri/**/*'
- 'src/**/*'
branches:
- main
pull_request:
paths:
- '.github/workflows/build.yml'
- 'package.json'
- 'src-tauri/**/*'
- 'src/**/*'
# Nightly release
schedule:
- cron: '0 0 * * *'
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
env:
CARGO_INCREMENTAL: 0
jobs:
build:
runs-on: ${{ matrix.config.platform }}
strategy:
fail-fast: false
matrix:
config:
- platform: ubuntu-latest
target: 'x86_64-unknown-linux-gnu'
- platform: ubuntu-latest
target: 'aarch64-unknown-linux-gnu'
- platform: ubuntu-latest
target: 'armv7-unknown-linux-gnueabihf'
- platform: macos-latest
target: 'x86_64-apple-darwin'
- platform: macos-latest
target: 'aarch64-apple-darwin'
- platform: windows-latest
target: 'x86_64-pc-windows-msvc'
- platform: windows-latest
target: 'aarch64-pc-windows-msvc'
features:
- 'default'
- 'offline'
steps:
- uses: actions-rust-lang/[email protected]
- uses: pnpm/action-setup@v3
with:
version: latest
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: latest
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
src-tauri/target/
key: ${{ runner.os }}-${{ matrix.config.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: (Linux) ARM sources.list
if: matrix.config.target == 'aarch64-unknown-linux-gnu' || matrix.config.target == 'armv7-unknown-linux-gnueabihf'
run: |
# Add [arch=amd64] to the initial entries of the sources.list
sudo sed -i 's/^deb /deb [arch=amd64] /' /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs) main restricted" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-updates main restricted" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs) universe" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-updates universe" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs) multiverse" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-updates multiverse" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-security main restricted" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-security universe" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-security multiverse" | sudo tee -a /etc/apt/sources.list
# ARM-linux related sources and dpkg config and such
- name: (Linux) ARM setup
if: matrix.config.target == 'aarch64-unknown-linux-gnu' || matrix.config.target == 'armv7-unknown-linux-gnueabihf'
run: |
sudo dpkg --add-architecture arm64
sudo dpkg --add-architecture armhf
sudo apt-get update
- name: (Linux) Install dependencies
if: matrix.config.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev \
libsoup-3.0-dev \
libudev-dev \
build-essential \
curl \
wget \
libssl-dev \
libgtk-3-dev \
librsvg2-dev
- name: (Linux) (ARMv7) Install dependencies
if: matrix.config.target == 'armv7-unknown-linux-gnueabihf'
run: |
sudo apt-get install -y \
libc6:armhf \
libudev-dev:armhf \
libwebkit2gtk-4.1-dev:armhf \
libssl-dev:armhf \
libsoup-3.0-dev:armhf \
gcc-arm-linux-gnueabihf
- name: (Linux) (ARM64) Install dependencies
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get install -y \
libc6:arm64 \
libudev-dev:arm64 \
libwebkit2gtk-4.1-dev:arm64 \
libssl-dev:arm64 \
libsoup-3.0-dev:arm64 \
gcc-aarch64-linux-gnu
- name: Add target
run: rustup target add ${{ matrix.config.target }}
- name: Install dependencies
run: pnpm install
- name: Build injection extension
run: pnpm build:ext
- name: (Offline) (Windows) If we are building the offline version, bootstrap PokeRogue locally
if: matrix.features == 'offline' && matrix.config.platform == 'windows-latest'
run: |
git clone https://github.com/pagefaultgames/pokerogue.git src-ext --depth 1
cd src-ext
pnpm install
echo VITE_BYPASS_LOGIN="1" > .env
pnpm build
cd dist
7z a -tzip -mx5 -r ../../game.dat *
- name: (Offline) (Unix) If we are building the offline version, bootstrap PokeRogue locally
if: matrix.features == 'offline' && matrix.config.platform != 'windows-latest'
run: chmod +x ./bootstrap_pokerogue.sh && ./bootstrap_pokerogue.sh
# For lite installs
- name: (Online) Create empty resource
if: matrix.features != 'offline'
run: touch game.dat
- name: (Most) Build
# If we are compiling for Windows ARM, we can only support NSIS
run: pnpm tauri build --target ${{ matrix.config.target }} ${{ matrix.config.target == 'aarch64-pc-windows-msvc' && '--bundles nsis' || '' }} ${{ matrix.config.target == 'x86_64-unknown-linux-gnu' && '--bundles deb' || '' }} --features ${{ matrix.features }}
if: matrix.config.target != 'aarch64-unknown-linux-gnu' && matrix.config.target != 'armv7-unknown-linux-gnueabihf'
env:
RUSTFLAGS: -Awarnings
CC: clang
- name: (Linux) (ARMv7) Build
if: matrix.config.target == 'armv7-unknown-linux-gnueabihf'
run: pnpm tauri build --target ${{ matrix.config.target }} --features ${{ matrix.features }} --bundles deb
env:
RUSTFLAGS: -Awarnings -L/usr/lib/arm-linux-gnueabihf
CC: arm-linux-gnueabihf-gcc
PKG_CONFIG_SYSROOT_DIR: /usr/lib/arm-linux-gnueabihf
PKG_CONFIG_PATH: /usr/lib/arm-linux-gnueabihf/pkgconfig
- name: (Linux) (ARM64) Build
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: pnpm tauri build --target ${{ matrix.config.target }} --features ${{ matrix.features }} --bundles deb
env:
RUSTFLAGS: -Awarnings -L/usr/lib/aarch64-linux-gnu
CC: aarch64-linux-gnu-gcc
PKG_CONFIG_SYSROOT_DIR: /usr/lib/aarch64-linux-gnu
PKG_CONFIG_PATH: /usr/lib/aarch64-linux-gnu/pkgconfig
# For portable installs
- name: Create empty config.json
run: cd src-tauri/target/${{ matrix.config.target }}/release && echo {} > config.json
# paths:
# Windows:
# - src-tauri/target/${{ matrix.config.target }}/release/roguetop.exe
# Ubuntu:
# - src-tauri/target/${{ matrix.config.target }}/release/pokerogue
# MacOS:
# - src-tauri/target/${{ matrix.config.target }}/release/bundle/macos/PokeRogue.app
- name: (Windows) Compress build
if: matrix.config.platform == 'windows-latest'
run: cd src-tauri/target/${{ matrix.config.target }}/release && 7z a -tzip -mx9 RogueTop.zip
roguetop.exe
config.json
_up_
- name: (Linux) Compress build
if: matrix.config.platform == 'ubuntu-latest'
run: cd src-tauri/target/${{ matrix.config.target }}/release && tar -czvf roguetop.tar.gz roguetop config.json _up_
# Windows portable
- name: (Windows) Upload portable
if: matrix.config.platform == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: roguetop-${{ matrix.features }}-${{ matrix.config.target }}-portable
path: src-tauri/target/${{ matrix.config.target }}/release/RogueTop.zip
# Windows MSI
- name: (Windows) Upload .msi
if: matrix.config.platform == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: roguetop-${{ matrix.features }}-${{ matrix.config.target }}-msi
path: src-tauri/target/${{ matrix.config.target }}/release/bundle/msi/*.msi
# Windows ARM only supports NSIS right now, but we should upload that too
- name: (Windows) Upload NSIS
if: matrix.config.platform == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: roguetop-${{ matrix.features }}-${{ matrix.config.target }}-nsis
path: src-tauri/target/${{ matrix.config.target }}/release/bundle/nsis/*.exe
# Ubuntu portable
- name: (Linux) Upload portable
if: matrix.config.platform == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: roguetop-${{ matrix.features }}-${{ matrix.config.target }}-portable
path: src-tauri/target/${{ matrix.config.target }}/release/roguetop.tar.gz
# Ubuntu deb
- name: (Linux) Upload .deb
if: matrix.config.platform == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: roguetop-${{ matrix.features }}-${{ matrix.config.target }}-deb
path: src-tauri/target/${{ matrix.config.target }}/release/bundle/deb/*.deb
# Redhat rpm
# - name: (Linux) Upload .rpm
# if: matrix.config.platform == 'ubuntu-latest'
# uses: actions/upload-artifact@v4
# with:
# name: roguetop-${{ matrix.features }}-${{ matrix.config.target }}-rpm
# path: src-tauri/target/${{ matrix.config.target }}/release/bundle/rpm/*.rpm
- name: (Linux) Upload .appimage
if: matrix.config.platform == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: roguetop-${{ matrix.features }}-${{ matrix.config.target }}-appimage
path: src-tauri/target/${{ matrix.config.target }}/release/bundle/appimage/*.AppImage
- name: (MacOS) Upload .dmg
if: matrix.config.platform == 'macos-latest'
uses: actions/upload-artifact@v4
with:
name: roguetop-${{ matrix.features }}-${{ matrix.config.target }}-dmg
path: src-tauri/target/${{ matrix.config.target }}/release/bundle/dmg/*.dmg
build_android:
runs-on: ubuntu-latest
steps:
- uses: actions-rust-lang/[email protected]
- uses: pnpm/action-setup@v3
with:
version: latest
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: latest
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Install vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: '3508985146f1b1d248c67ead13f8f54be5b4f5da'
- name: Install using vcpkg
run: vcpkg install --triplet arm64-android --x-install-root ${{ github.workspace }}/packages
- name: Set OPENSSL_DIR
run: echo "OPENSSL_DIR=${{ github.workspace }}/packages/arm64-android/" >> $GITHUB_ENV
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Install NDK with SDK
run: sdkmanager --install ndk-bundle
- name: Set NDK_HOME
run: echo "NDK_HOME=$ANDROID_HOME/ndk/$(ls -1 $ANDROID_HOME/ndk | head -1)" >> $GITHUB_ENV
- name: Add Android targets
run: rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
- name: Create empty game.dat
run: touch game.dat
- name: Install dependencies
run: pnpm install
- name: Build injection extension
run: pnpm build:ext
- name: Build for Android
run: pnpm tauri android build
env:
RUSTFLAGS: -Awarnings
- name: DEBUG find the apk
run: find ./src-tauri/target/aarch64-linux-android/release -name '*.apk'
build_ios:
runs-on: macos-latest
steps:
- uses: actions-rust-lang/[email protected]
- uses: pnpm/action-setup@v3
with:
version: latest
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: latest
- name: Add iOS target
run: rustup target add aarch64-apple-ios
- name: Install cocoapods
run: brew install cocoapods
- name: Install dependencies
run: pnpm install
- name: Build injection extension
run: pnpm build:ext
- name: Create empty game.dat
run: touch game.dat
- name: Build for iOS
run: pnpm tauri ios build
env:
RUSTFLAGS: -Awarnings
- name: DEBUG find the ipa
run: find ./src-tauri/target/aarch64-apple-ios/release -name '*.ipa'
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'schedule'
steps:
- name: Checkout
uses: actions/checkout@v4
# Download all artifacts from the build job
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Rename executables to their folder names
run: |
# get the folder name
folder_name=artifacts
# get the list of inner folders
folders=$(ls $folder_name)
# loop through the files in each folder
for folder in $folders; do
# Get the list of files in the folder
files=$(ls "$folder_name/$folder")
for file in $files; do
# Get the filename without extension
filename="${file%.*}"
# Get the extension (everything after the last dot)
extension="${file##*.}"
# Build the new filename with parent folder name and extension
new_filename="$folder_name/$folder/$folder.$extension"
# Rename the file
mv "$folder_name/$folder/$file" "$new_filename"
done
done
- name: Create release using all artifacts
uses: softprops/action-gh-release@v2
if: github.event_name != 'schedule'
with:
files: artifacts/**
token: ${{ secrets.GITHUB_TOKEN }}
# Release name is the tag name
name: ${{ github.ref_name }} - ${{ github.sha }}
draft: false
generate_release_notes: true
prerelease: false
# (nightly) upload artifacts to the nightly release
- name: Upload nightly artifacts
if: github.event_name == 'schedule'
run:
gh release upload nightly artifacts/**/* --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}