Feature/mobile #64
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 and Deploy | |
on: | |
workflow_dispatch: {} | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
env: | |
UNITY_MAJOR_VERSION: 2022 | |
UNITY_MINOR_VERSION: 2 | |
UNITY_PATCH_VERSION: 17f1 | |
jobs: | |
prepare_release: | |
name: Prepare release π | |
runs-on: ubuntu-latest | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y-%m-%d-%H-%M-%S')" | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
with: | |
draft: false | |
prerelease: false | |
tag_name: ${{ env.TAG_NAME }} | |
release_name: ${{ env.RELEASE_NAME }} | |
env: | |
TAG_NAME: release-${{ steps.date.outputs.date }} | |
RELEASE_NAME: release-${{ steps.date.outputs.date }} | |
GITHUB_TOKEN: ${{ github.token }} | |
- id: step_upload_url | |
name: Store Release upload URL for proceeding jobs | |
run: echo "::set-output name=upload_url::${{ steps.create_release.outputs.upload_url }}" | |
# request_alf: | |
# name: Request .alf file πβ | |
# runs-on: ubuntu-latest | |
# outputs: | |
# alf: ${{ steps.output.outputs.alf }} | |
# steps: | |
# - name: π Request manual activation file | |
# id: alfFile | |
# uses: game-ci/unity-request-activation-file@main | |
# with: | |
# unityVersion: ${{ env.UNITY_MAJOR_VERSION }}.${{ env.UNITY_MINOR_VERSION }}.${{ env.UNITY_PATCH_VERSION }} | |
# - name: π€ Expose as artifact | |
# uses: actions/upload-artifact@v1 | |
# with: | |
# name: ${{ steps.alfFile.outputs.filePath }} | |
# path: ${{ steps.alfFile.outputs.filePath }} | |
# - name: π€ Output | |
# id: output | |
# run: | | |
# echo "::set-output name=alf::${{ steps.alfFile.outputs.filePath }}" | |
# acquire_ulf: | |
# name: Acquire .ulf file πβοΈ | |
# runs-on: ubuntu-latest | |
# needs: [request_alf] | |
# steps: | |
# - name: β¬οΈ Download .alf artifact | |
# uses: actions/download-artifact@v2 | |
# with: | |
# name: ${{ needs.request_alf.outputs.alf }} | |
# - name: π§ Set up Node.js | |
# uses: actions/setup-node@v1 | |
# with: | |
# node-version: '16' | |
# - name: π¦ Install node package, `unity-verify-code` | |
# run: npm install --global unity-verify-code | |
# - name: π¦ Install node package, `unity-license-activate` | |
# run: npm install --global andrewiankidd/unity-license-activate | |
# - name: βοΈ Activate the license | |
# run: unity-license-activate "${{ secrets.UNITY_EMAIL }}" "${{ secrets.UNITY_PASSWORD }}" "${{ needs.request_alf.outputs.alf }}" --authenticator-key "${{ secrets.UNITY_TOTP_KEY }}" --email-password "${{ secrets.EMAIL_PASSWORD }}" | |
# - name: π©Ί Upload error screenshot | |
# if: failure() | |
# uses: actions/upload-artifact@v1 | |
# with: | |
# name: screenshot_error | |
# path: error.png | |
# - name: π Read ulf | |
# id: ulfRead | |
# uses: juliangruber/read-file-action@v1.1.4 | |
# with: | |
# path: 'Unity_v${{ env.UNITY_MAJOR_VERSION }}.x.ulf' | |
# - name: π Update secret UNITY_LICENSE | |
# uses: hmanzur/actions-set-secret@v2.0.0 | |
# with: | |
# name: 'UNITY_LICENSE' | |
# value: '${{ steps.ulfRead.outputs.content }}' | |
# token: ${{ secrets.ACCESS_TOKEN }} | |
build: | |
name: Building for ${{ matrix.name }} π οΈ | |
runs-on: ubuntu-latest | |
needs: [ | |
# acquire_ulf, | |
prepare_release | |
] | |
if: ${{ always() && !cancelled() }} | |
strategy: | |
fail-fast: false | |
matrix: | |
targetPlatform: | |
- StandaloneOSX # Build a macOS standalone (Intel 64-bit). | |
- StandaloneWindows64 # Build a Windows 64-bit standalone. | |
- StandaloneLinux64 # Build a Linux 64-bit standalone. | |
- WebGL # WebGL. | |
include: | |
- targetPlatform: StandaloneOSX | |
name: 'OSX' | |
channel: 'mac' | |
- targetPlatform: StandaloneWindows64 | |
name: 'Windows' | |
channel: 'windows' | |
- targetPlatform: StandaloneLinux64 | |
name: 'Linux' | |
channel: 'linux' | |
- targetPlatform: WebGL | |
name: 'WebGL' | |
channel: 'webgl' | |
- targetPlatform: Android | |
name: 'Android' | |
channel: 'android' | |
- targetPlatform: iOS | |
name: 'iOS' | |
channel: 'ios' | |
steps: | |
# Checkout | |
- name: β¬οΈ Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
lfs: true | |
# Cache | |
- name: ποΈ Caching | |
uses: actions/cache@v1.1.0 | |
with: | |
path: src/Library | |
key: src/Library-${{ matrix.targetPlatform }} | |
# Create build path | |
- name: π Create the build path | |
run: mkdir Build | |
# Build | |
- name: ποΈ Build project | |
uses: game-ci/unity-builder@v4 | |
env: | |
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
with: | |
unityVersion: ${{ env.UNITY_MAJOR_VERSION }}.${{ env.UNITY_MINOR_VERSION }}.${{ env.UNITY_PATCH_VERSION }} | |
targetPlatform: ${{ matrix.targetPlatform }} | |
projectPath: src | |
buildsPath: Build | |
buildMethod: UnityBuilderAction.Builder.BuildProject | |
allowDirtyBuild: true | |
- name: ποΈ Compress Release | |
run: | | |
sudo chmod -R 777 Build && \ | |
cd Build && \ | |
zip -r "Build-${{ matrix.targetPlatform }}.zip" "${{ matrix.targetPlatform }}" | |
- name: β¬οΈ Upload ${{ matrix.targetPlatform }} Release | |
uses: actions/upload-release-asset@v1 | |
# if: github.ref == 'refs/heads/master' | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ needs.prepare_release.outputs.upload_url }} | |
asset_path: Build/Build-${{ matrix.targetPlatform }}.zip | |
asset_name: ${{ matrix.targetPlatform }}-release.zip | |
asset_content_type: application/zip | |
- name: β¬οΈ Upload ${{ matrix.targetPlatform }} Release | |
uses: softprops/action-gh-release@v2 | |
# if: github.ref == 'refs/heads/master' | |
with: | |
files: | | |
${{ matrix.targetPlatform }}-release.zip | |
publish_web: | |
name: Publish to GitHub Pages πΈοΈ | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Read ReadMe.md | |
id: mdRead | |
uses: juliangruber/read-file-action@v1.1.4 | |
with: | |
path: 'ReadMe.md' | |
- name: get repository name | |
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV | |
- uses: cschleiden/replace-tokens@v1 | |
with: | |
tokenPrefix: '{{' | |
tokenSuffix: '}}' | |
files: '[".github/pages/**/*.html"]' | |
env: | |
USER: ${{ github.repository_owner }} | |
PROJECT: ${{ env.REPOSITORY_NAME }} | |
MARKDOWN: ${{ steps.mdRead.outputs.content }} | |
- name: Download WebGL Build | |
uses: robinraju/release-downloader@v1.8 | |
with: | |
fileName: "WebGL-release.zip" | |
latest: true | |
extract: true | |
- name: Move WebGL | |
run: | | |
mv WebGL/WebGL .github/pages | |
- name: Deploy π | |
uses: JamesIves/github-pages-deploy-action@4.1.4 | |
with: | |
branch: gh-pages | |
folder: .github/pages |