2023-11-06 17:48:00 +00:00
|
|
|
name: CI
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2023-11-10 22:38:47 +00:00
|
|
|
branches-ignore:
|
|
|
|
- cpp-rewrite
|
|
|
|
- horizon-os
|
2023-11-06 17:48:00 +00:00
|
|
|
paths-ignore:
|
|
|
|
- '.gitignore'
|
2023-11-26 13:31:09 +00:00
|
|
|
- '.github/*'
|
2023-11-06 17:48:00 +00:00
|
|
|
- '**.md'
|
|
|
|
- 'LICENSE'
|
|
|
|
- 'drshorizon/**'
|
|
|
|
- 'res/**'
|
2023-11-10 22:38:47 +00:00
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
env:
|
|
|
|
VERSION: "0.101.0"
|
2023-11-06 17:48:00 +00:00
|
|
|
|
|
|
|
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' }}
|
2023-11-26 13:31:09 +00:00
|
|
|
run: sudo apt install libasound2-dev libudev-dev libgl1-mesa-dev
|
2023-11-06 17:48:00 +00:00
|
|
|
|
2023-11-10 22:38:47 +00:00
|
|
|
- name: Restore cache
|
|
|
|
uses: actions/cache/restore@v3
|
2023-11-06 17:48:00 +00:00
|
|
|
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 }}"
|
2023-11-12 10:34:38 +00:00
|
|
|
elif [ "${{ github.ref_name }}" == "master"]; then
|
|
|
|
export DRS_BUILD_VERSION_OVERRIDE="${{ env.VERSION }}-$((${{ github.run_number }} + 654))"
|
2023-11-06 17:48:00 +00:00
|
|
|
else
|
2023-11-12 10:34:38 +00:00
|
|
|
export DRS_BUILD_VERSION_OVERRIDE="${{ env.VERSION }}-${GITHUB_SHA:0:7}"
|
2023-11-06 17:48:00 +00:00
|
|
|
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
|
|
|
|
|
2023-11-10 22:38:47 +00:00
|
|
|
- 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
|
|
|
|
|
2023-11-06 17:48:00 +00:00
|
|
|
build_android:
|
|
|
|
name: Android build
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
|
|
APP_OUTPUTS_DIR: "app/app/build/outputs/apk/release"
|
|
|
|
strategy:
|
|
|
|
fail-fast: true
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
2023-11-10 22:38:47 +00:00
|
|
|
- name: Restore cache
|
|
|
|
uses: actions/cache/restore@v3
|
2023-11-06 17:48:00 +00:00
|
|
|
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 }}"
|
2023-11-12 10:34:38 +00:00
|
|
|
elif [ "${{ github.ref_name }}" == "master"]; then
|
|
|
|
export DRS_BUILD_VERSION_OVERRIDE="${{ env.VERSION }}-$((${{ github.run_number }} + 654))"
|
2023-11-06 17:48:00 +00:00
|
|
|
else
|
2023-11-12 10:34:38 +00:00
|
|
|
export DRS_BUILD_VERSION_OVERRIDE="${{ env.VERSION }}-${GITHUB_SHA:0:7}"
|
2023-11-06 17:48:00 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
cd app
|
|
|
|
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
|
2023-12-14 18:04:44 +00:00
|
|
|
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
|
2023-11-06 17:48:00 +00:00
|
|
|
|
|
|
|
rm keystore.jks
|
|
|
|
|
|
|
|
- name: Prepare artifact
|
|
|
|
run: |
|
|
|
|
mkdir release
|
2023-11-10 22:38:47 +00:00
|
|
|
mv $APP_OUTPUTS_DIR/app-signed.apk release/doukutsu-rs.apk
|
2023-11-06 17:48:00 +00:00
|
|
|
cp LICENSE ./release
|
|
|
|
|
|
|
|
- name: Upload artifact
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: doukutsu-rs_android
|
|
|
|
path: ./release/*
|
|
|
|
if-no-files-found: error
|
2023-11-10 22:38:47 +00:00
|
|
|
|
|
|
|
- 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
|
2023-11-26 13:31:09 +00:00
|
|
|
|
|
|
|
update_metadata:
|
|
|
|
name: Update metadata
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
if: ${{ github.ref_type != 'tag' && always() }}
|
|
|
|
needs: [build, build_android]
|
|
|
|
permissions:
|
|
|
|
contents: write
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
repository: doukutsu-rs/metadata
|
|
|
|
token: ${{ secrets.METADATA_USER_TOKEN }}
|
|
|
|
|
|
|
|
- name: Update metadata
|
|
|
|
id: metadata
|
|
|
|
run: |
|
|
|
|
export FILE="./metadata/nightly.json"
|
|
|
|
if [ "${{ github.ref_name }}" == "master" ]; then
|
|
|
|
export VERSION="${{ env.VERSION }}-$((${{ github.run_number }} + 654))"
|
|
|
|
else
|
|
|
|
export VERSION="${{ env.VERSION }}-${GITHUB_SHA:0:7}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${{ needs.build.result }}" == "success" ]; then
|
2023-11-27 09:13:14 +00:00
|
|
|
node ./metadata.js --os linux --arch x86_64 --version $VERSION --commit $GITHUB_SHA --link https://nightly.link/doukutsu-rs/doukutsu-rs/actions/runs/${{ github.run_id }}/doukutsu-rs_linux-x64.zip $FILE
|
|
|
|
node ./metadata.js --os windows --arch x86_64 --version $VERSION --commit $GITHUB_SHA --link https://nightly.link/doukutsu-rs/doukutsu-rs/actions/runs/${{ github.run_id }}/doukutsu-rs_windows-x64.zip $FILE
|
|
|
|
node ./metadata.js --os windows --arch i686 --version $VERSION --commit $GITHUB_SHA --link https://nightly.link/doukutsu-rs/doukutsu-rs/actions/runs/${{ github.run_id }}/doukutsu-rs_windows-x32.zip $FILE
|
|
|
|
node ./metadata.js --os macos --arch x64 --version $VERSION --commit $GITHUB_SHA --link https://nightly.link/doukutsu-rs/doukutsu-rs/actions/runs/${{ github.run_id }}/doukutsu-rs_mac-x64.zip $FILE
|
|
|
|
node ./metadata.js --os macos --arch arm64 --version $VERSION --commit $GITHUB_SHA --link https://nightly.link/doukutsu-rs/doukutsu-rs/actions/runs/${{ github.run_id }}/doukutsu-rs_mac-arm64.zip $FILE
|
2023-11-26 13:31:09 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${{ needs.build_android.result }}" == "success" ]; then
|
2023-11-27 09:13:14 +00:00
|
|
|
node ./metadata.js --os android --version $VERSION --commit $GITHUB_SHA --link https://nightly.link/doukutsu-rs/doukutsu-rs/actions/runs/${{ github.run_id }}/doukutsu-rs_android.zip $FILE
|
2023-11-26 13:31:09 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "file=$FILE" >> "$GITHUB_OUTPUT"
|
|
|
|
|
|
|
|
- name: Upload metadata
|
|
|
|
run: |
|
|
|
|
git config user.name ${{ vars.METADATA_USER_NAME }}
|
|
|
|
git config user.email ${{ vars.METADATA_USER_EMAIL }}
|
|
|
|
|
|
|
|
git add ${{ steps.metadata.outputs.file }}
|
|
|
|
git commit -m "Update nightly builds metadata(CI)"
|
2023-11-26 13:56:49 +00:00
|
|
|
git push
|