1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2025-04-25 15:25:32 +00:00
doukutsu-rs/.github/workflows/ci.yml
biroder 46710dd31a Make some changes to README and CI config[ci skip]
Change links to nightly builds in README.

Change the version of nightly builds (use the build number at the end of the version string for master and part of the commit hash for other branches). Make it so that the workflow can be run manually. Disable cache saving for non-master branches, because in this case the cache is always created new and doesn't update the existing one, which wastes cache space. Temporarily disable build for Android
2023-11-11 00:38:47 +02:00

214 lines
6.7 KiB
YAML

name: CI
on:
push:
branches-ignore:
- cpp-rewrite
- horizon-os
paths-ignore:
- '.gitignore'
- '**.md'
- 'LICENSE'
- 'drshorizon/**'
- 'res/**'
workflow_dispatch:
defaults:
run:
shell: bash
env:
VERSION: "0.101.0"
jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- name: Linux x86_64
os: ubuntu-latest
channel: stable
target: x86_64-unknown-linux-gnu
target_name: linux-x64
arch_name: x86_64
- name: Windows x64
os: windows-latest
channel: stable
target: x86_64-pc-windows-msvc
target_name: windows-x64
arch_name: x86_64
- name: Windows x32
os: windows-latest
channel: stable
target: i686-pc-windows-msvc
target_name: windows-x32
arch_name: i686
- name: macOS x64 (Intel Macs)
os: macos-latest
channel: stable
target: x86_64-apple-darwin
target_name: mac-x64
- name: macOS ARM64 (M1 Macs)
os: macos-latest
channel: stable
target: aarch64-apple-darwin
target_name: mac-arm64
steps:
- uses: actions/checkout@v3
- name: Install dependencies
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt install libasound2-dev libudev-dev libgl1-mesa-dev pkg-config
- name: Restore cache
uses: actions/cache/restore@v3
with:
path: |
~/.cargo
~/.rustup
target
key: ${{ matrix.target_name }}-cargo
- name: Setup rust toolchain
run: |
rustup default ${{ matrix.channel }}
rustup target add ${{ matrix.target }}
rustc -vV
cargo -vV
if [ "${{ runner.os }}" == "macOS" ]; then
cargo install cargo-bundle
fi
- name: Build
run: |
if [ "${{ github.ref_type }}" == "tag" ]; then
export DRS_BUILD_VERSION_OVERRIDE="{{ github.ref_name }}"
elif [ "${{ github.ref_name }} == "master"]; then
export DRS_BUILD_VERSION_OVERRIDE="$VERSION-$((${{ github.run_number }} + 654))"
else
export DRS_BUILD_VERSION_OVERRIDE="$VERSION-${GITHUB_SHA:0:7}"
fi
mkdir release
cp LICENSE release
if [ "${{ runner.os }}" == "macOS" ]; then
CARGO_INCREMENTAL=1 cargo bundle --release --target ${{ matrix.target }}
cp -a ./target/${{ matrix.target }}/release/bundle/osx/doukutsu-rs.app release/doukutsu-rs.app
codesign -s - -f ./release/doukutsu-rs.app/Contents/MacOS/doukutsu-rs
elif [ "${{ runner.os }}" == "Windows" ]; then
CARGO_INCREMENTAL=1 cargo build --release --bin doukutsu-rs
cp ./target/release/doukutsu-rs.exe release/doukutsu-rs.${{ matrix.arch_name }}.exe
elif [ "${{ runner.os }}" == "Linux" ]; then
RUSTFLAGS="-C link-args=-s" CARGO_INCREMENTAL=1 cargo build --release --bin doukutsu-rs
cp -a ./target/release/doukutsu-rs release/doukutsu-rs.${{ matrix.arch_name }}.elf
fi
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: doukutsu-rs_${{ matrix.target_name }}
path: ./release/*
if-no-files-found: error
- name: Save cache
if: ${{ github.ref_name == 'master' || github.ref_type == 'tag' }}
uses: actions/cache/save@v3
with:
path: |
~/.cargo
~/.rustup
target
key: ${{ matrix.target_name }}-cargo
build_android:
name: Android build
if: false
runs-on: ubuntu-latest
env:
APP_OUTPUTS_DIR: "app/app/build/outputs/apk/release"
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v3
- name: Restore cache
uses: actions/cache/restore@v3
with:
path: |
~/.cache
~/.cargo
~/.rustup
~/.gradle
app/app/.cxx
app/app/build
drsandroid/target
key: android-cargo
- name: Setup rust toolchain
run: |
rustup default stable
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android
rustc -vV
cargo -vV
cargo install cargo-ndk
- name: Build
run: |
if [ "${{ github.ref_type }}" == "tag" ]; then
export DRS_BUILD_VERSION_OVERRIDE="{{ github.ref_name }}"
elif [ "${{ github.ref_name }} == "master"]; then
export DRS_BUILD_VERSION_OVERRIDE="$VERSION-$((${{ github.run_number }} + 654))"
else
export DRS_BUILD_VERSION_OVERRIDE="$VERSION-${GITHUB_SHA:0:7}"
fi
cd app
touch local.properties
chmod +x ./gradlew
./gradlew assembleRelease
- name: Sign app
run: |
BUILD_TOOLS=$ANDROID_HOME/build-tools/33.0.0
echo "${{ secrets.ANDROID_SIGNING_KEYSTORE }}" | base64 --decode > keystore.jks
if [ "${{ secrets.ANDROID_SIGNING_KEY_PASS }}" != "" ]; then
$BUILD_TOOLS/apksigner sign --ks ./keystore.jks --ks-key-alias "${{ secrets.ANDROID_SIGNING_ALIAS }}" --ks-pass "pass:${{ secrets.ANDROID_SIGNING_KEYSTORE_PASS }}" --key-pass "pass:${{ secrets.ANDROID_SIGNING_KEY_PASS }}" --out $APP_OUTPUTS_DIR/app-signed.apk $APP_OUTPUTS_DIR/app-release-unsigned.apk
else
$BUILD_TOOLS/apksigner sign --ks ./keystore.jks --ks-key-alias "${{ secrets.ANDROID_SIGNING_ALIAS }}" --ks-pass "pass:${{ secrets.ANDROID_SIGNING_KEYSTORE_PASS }}" --out $APP_OUTPUTS_DIR/app-signed.apk $APP_OUTPUTS_DIR/app-release-unsigned.apk
fi
rm keystore.jks
- name: Prepare artifact
run: |
mkdir release
mv $APP_OUTPUTS_DIR/app-signed.apk release/doukutsu-rs.apk
cp LICENSE ./release
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: doukutsu-rs_android
path: ./release/*
if-no-files-found: error
- name: Save cache
if: ${{ github.ref_name == 'master' || github.ref_type == 'tag' }}
uses: actions/cache/save@v3
with:
path: |
~/.cache
~/.cargo
~/.rustup
~/.gradle
app/app/.cxx
app/app/build
drsandroid/target
key: android-cargo