chore(ci): \it works/ #6
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
# branches: [ main ] | |
tags: | |
- '[0-9]+.[0-9]+.[0-9]+**' # this one will trigger a release | |
# pull_request: | |
# branches: [ main ] | |
workflow_dispatch: | |
permissions: | |
contents: write | |
env: | |
# Preview mode: Publishes the build output as a CI artifact instead of creating | |
# a release, allowing for manual inspection of the output. This mode is | |
# activated if the CI run was triggered by events other than pushed tags | |
preview: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
pre-release: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }} | |
version: 0.0.0 | |
jobs: | |
buildForAllSupportedPlatforms: | |
name: Build for ${{ matrix.targetPlatform }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- targetPlatform: StandaloneOSX | |
name: universal-macos | |
suffix: .app.tar.gz | |
- targetPlatform: StandaloneWindows64 | |
name: x86_64-windows | |
suffix: .zip | |
- targetPlatform: StandaloneLinux64 | |
name: x86_64-linux | |
suffix: .tar.gz | |
- targetPlatform: Android | |
name: android | |
suffix: .apk | |
steps: | |
- uses: actions/checkout@v4 | |
# For preview version it will be dev{SHA} otherwise it will be the tag | |
- name: Initialize version env | |
shell: bash | |
run: | | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
else | |
echo "version=dev${GITHUB_SHA::7}" >> $GITHUB_ENV | |
fi | |
# Cache | |
- uses: actions/cache@v3 | |
with: | |
path: Library | |
key: Library-${{ matrix.targetPlatform }}-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} | |
restore-keys: Library- | |
- if: matrix.targetPlatform == 'Android' | |
uses: jlumbroso/[email protected] | |
- name: Build | |
id: buildStep | |
uses: game-ci/unity-builder@v4 | |
env: | |
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
with: | |
targetPlatform: ${{ matrix.targetPlatform }} | |
versioning: ${{ env.preview != 'true' && 'Tag' || 'Custom' }} | |
version: ${{ env.preview == 'true' && env.version || '' }} | |
customParameters: -CompressWithLz4 | |
- run: | | |
echo 'Project Version ${{ steps.buildStep.outputs.buildVersion }}' | |
echo 'Android Version Code ${{ steps.buildStep.outputs.androidVersionCode }}' | |
echo 'Build Step Exit Code ${{ steps.buildStep.outputs.engineExitCode }}' | |
- run: mkdir dist | |
- if: matrix.targetPlatform == 'StandaloneOSX' | |
run: | | |
set -ex | |
cd build/StandaloneOSX | |
tar -czvf ../../dist/REFRACTION-${{ env.version }}-${{ matrix.name }}.app.tar.gz StandaloneOSX.app | |
- if: matrix.targetPlatform == 'StandaloneWindows64' | |
run: | | |
set -ex | |
cd build/StandaloneWindows64 | |
7z a -r ../../dist/REFRACTION-${{ env.version }}-${{ matrix.name }}.zip . | |
- if: matrix.targetPlatform == 'StandaloneLinux64' | |
run: | | |
set -ex | |
cd build/StandaloneLinux64 | |
tar -czvf ../../dist/REFRACTION-${{ env.version }}-${{ matrix.name }}.tar.gz . | |
- if: matrix.targetPlatform == 'Android' | |
run: | | |
cp build/Android/Android.apk dist/REFRACTION-${{ env.version }}-${{ matrix.name }}.apk | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: REFRACTION-${{ env.version }}-${{ matrix.name }} | |
path: dist/REFRACTION-${{ env.version }}-${{ matrix.name }}${{ matrix.suffix }} | |
release: | |
name: Release | |
needs: [ buildForAllSupportedPlatforms ] | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
- shell: bash | |
run: | | |
set -ex | |
mkdir dist | |
for dir in REFRACTION-* ; do | |
cp $dir/* dist/ | |
done | |
- name: Upload binaries to release | |
uses: svenstaro/upload-release-action@v2 | |
if: env.preview == 'false' | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: dist/* | |
file_glob: true | |
tag: ${{ github.ref_name }} | |
release_name: "Release v${{ github.ref_name }}" | |
prerelease: ${{ env.pre-release }} | |
body: "" | |
overwrite: true | |
# - name: Create dmg | |
# if: matrix.targetPlatform == 'StandaloneOSX' | |
# uses: L-Super/[email protected] | |
# with: | |
# dmg_name: 'REFRACTION-${{ env.version }}-${{ matrix.name }}' | |
# src_dir: 'build/StandaloneOSX/StandaloneOSX.app' | |