Skip to content

Linux Develop Workflow (Unit tests and Android build) #84

Linux Develop Workflow (Unit tests and Android build)

Linux Develop Workflow (Unit tests and Android build) #84

name: Linux Develop Workflow (Unit tests and Android build)
on:
workflow_dispatch:
schedule:
- cron: 0 19 * * 5
jobs:
# test:
# name: Test Unity
# runs-on: ubuntu-latest
# steps:
# # Activation stage
# - name: Checkout repository
# uses: actions/checkout@v2
# with:
# lfs: 'true'
# ref: develop
# - name: LFS pull
# run: git lfs pull
# - name: Set up credentials
# env:
# ASSISTANTKEYS: ${{ secrets.ASSISTANTKEYS }}
# OAIKEYS: ${{ secrets.OAISECRET }}
# SENTRYCFG: ${{ secrets.SENTRYCFG }}
# SENTRYCLI: ${{ secrets.SENTRYCLI }}
# run: |
# echo -n "$ASSISTANTKEYS" > $GITHUB_WORKSPACE/ibm-credentials.env
# echo "path of the credentials resource $GITHUB_WORKSPACE/ibm-credentials.txt"
# export IBM_CREDENTIALS_FILE="$GITHUB_WORKSPACE/ibm-credentials.env"
# echo -n "$OAIKEYS" > $GITHUB_WORKSPACE/Assets/Resources/openai.txt
# echo "path of the OAI credentials resource $GITHUB_WORKSPACE/Assets/Resources/openai.txt"
# echo -n "$SENTRYCFG" > $GITHUB_WORKSPACE/Assets/Resources/Sentry/SentryOptions.asset
# echo "path of the Sentry options yaml file $GITHUB_WORKSPACE/Assets/Resources/Sentry/SentryOptions.asset"
# echo -n "$SENTRYCLI" > $GITHUB_WORKSPACE/Assets/Plugins/Sentry/SentryCliOptions.asset
# echo "path of the Sentry CLI options yaml file $GITHUB_WORKSPACE/Assets/Plugins/Sentry/SentryCliOptions.asset"
# # Fonts
# - name: Install fonts
# run: |
# echo -n "Installing core fonts"
# echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | sudo debconf-set-selections
# echo "ttf-mscorefonts-installer msttcorefonts/present-mscorefonts-eula note" | sudo debconf-set-selections
# sudo apt install ttf-mscorefonts-installer
# sudo fc-cache -f
# fc-match Arial
# # Cache
# - name: Caching
# uses: actions/cache@v3
# with:
# path: Library
# key: Library-linux-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
# restore-keys: |
# Library-linux
# # Test stage
# - name: Unity Test runner (edit and play mode)
# uses: game-ci/unity-test-runner@v4.1.1
# env:
# UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
# UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
# UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
# with:
# testMode: EditMode
# githubToken: ${{ secrets.GITHUB_TOKEN }}
# unityVersion: 2022.3.7f1
build:
name: Build Unity
runs-on: ubuntu-latest
#needs: test
outputs:
buildVersion: ${{ steps.buildStep.outputs.buildVersion }}
steps:
# Free up disk space
- uses: jlumbroso/free-disk-space@v1.3.1
# Activation stage
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: 'true'
ref: develop
- name: LFS pull
run: git lfs pull
- name: Set up IBM Watson credentials
env:
ASSISTANTKEYS: ${{ secrets.ASSISTANTKEYS }}
OAIKEYS: ${{ secrets.OAISECRET }}
SENTRYCFG: ${{ secrets.SENTRYCFG }}
run: |
echo -n "$ASSISTANTKEYS" > $GITHUB_WORKSPACE/ibm-credentials.env
echo "path of the credentials resource $GITHUB_WORKSPACE/ibm-credentials.txt"
export IBM_CREDENTIALS_FILE="$GITHUB_WORKSPACE/ibm-credentials.env"
echo -n "$OAIKEYS" > $GITHUB_WORKSPACE/Assets/Resources/openai.txt
echo "path of the OAI credentials resource $GITHUB_WORKSPACE/Assets/Resources/openai.txt"
echo -n "$SENTRYCFG" > $GITHUB_WORKSPACE/Assets/Resources/Sentry/SentryOptions.asset
echo "path of the Sentry options yaml file $GITHUB_WORKSPACE/Assets/Resources/Sentry/SentryOptions.asset"
export TARGET_PLATFORM="Android"
# Fonts
- name: Install fonts
run: |
echo -n "Installing core fonts"
echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | sudo debconf-set-selections
echo "ttf-mscorefonts-installer msttcorefonts/present-mscorefonts-eula note" | sudo debconf-set-selections
sudo apt install ttf-mscorefonts-installer
sudo fc-cache -f
fc-match Arial
# Cache
- name: Caching
uses: actions/cache@v3
with:
path: Library
key: Library-linux-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: |
Library-linux
# Build stage
- name: Unity builder
uses: game-ci/unity-builder@v4
id: buildStep
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
targetPlatform: Android
unityVersion: 2022.3.7f1
versioning: Semantic
# dirty build needed to include generated Watson credentials
allowDirtyBuild: true
androidExportType: androidPackage # for store upload change to 'androidAppBundle'
androidKeystoreName: miragexr # This file won't exist, but this property needs to exist.
androidKeystoreBase64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
androidKeystorePass: ${{ secrets.ANDROID_KEYSTORE_PASS }}
androidKeyaliasName: ${{ secrets.ANDROID_KEYALIAS_NAME }}
androidKeyaliasPass: ${{ secrets.ANDROID_KEYALIAS_PASS }}
androidTargetSdkVersion: AndroidApiLevel33
- name: Upload build artifacts
uses: actions/upload-artifact@v2
with:
name: Android
path: build
retention-days: 3
if-no-files-found: error
# Deploy stage
prerelease-notification:
name: Prerelease Slack notification
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/develop' && !github.event.pull_request
env:
SLACK_URL: ${{ secrets.SLACK_URL }}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
APP_VERSION: ${{ needs.build.outputs.buildVersion }}
TARGET_PLATFORM: $RUNNER_OS
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Post notification
run: |
echo $APP_VERSION
sudo apt-get update && sudo apt-get -y install curl
chmod +x ./ci/notify-preview.sh && ./ci/notify-preview.sh