Skip to content

Run build

Run build #108

Workflow file for this run

name: Run build
on:
workflow_dispatch: {}
pull_request:
branches:
- main
types: [opened, synchronize, reopened]
schedule:
- cron: '0 0 * * *' # 毎日UTCで午前0時に実行
jobs:
check-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
with:
fetch-depth: 0 # すべての履歴とタグを取得
- name: Check event type and branch
run: |
echo "イベント名: ${{ github.event_name }}"
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "これはプルリクエストイベントです。"
echo "PRのソースブランチ: ${{ github.head_ref }}"
echo "PRのターゲットブランチ: ${{ github.base_ref }}"
if [ "${{ github.head_ref }}" == "develop" ] && [ "${{ github.base_ref }}" == "main" ]; then
echo "これは 'develop' から 'main' へのPRです。バージョンチェックを実行します。"
# ProjectSettings.assetから現在のバージョンを取得
current_version=$(grep -m1 'bundleVersion:' ProjectSettings/ProjectSettings.asset | awk '{print $2}')
echo "現在のプロジェクトバージョン: $current_version"
# gitからバージョンタグのリストを取得
git fetch --tags
version_tags=$(git tag -l 'v*')
echo "既存のバージョンタグ: $version_tags"
# タグからバージョン番号を抽出
versions=()
for tag in $version_tags; do
versions+=("${tag#v}")
done
if [ ${#versions[@]} -eq 0 ]; then
highest_version="0.0.0"
else
highest_version=$(printf '%s\n' "${versions[@]}" | sort -V | tail -n1)
fi
echo "最高の既存バージョン: $highest_version"
# 現在のバージョンと最高の既存バージョンを比較
if [ "$(printf '%s\n' "$highest_version" "$current_version" | sort -V | tail -n1)" != "$current_version" ]; then
echo "エラー: 現在のバージョン ($current_version) は最高の既存バージョン ($highest_version) よりも高くありません。"
exit 1
else
echo "現在のバージョン ($current_version) は最高の既存バージョン ($highest_version) よりも高いです。"
fi
else
echo "これは 'develop' から 'main' へのPRではありません。バージョンチェックをスキップします。"
fi
else
echo "プルリクエストイベントではありません。チェックをスキップします。"
fi
build:
needs: [check-branch]
runs-on: ${{ matrix.runsOn }}
name: Run builds for Windows, Mac
strategy:
fail-fast: false
matrix:
targetPlatform:
- StandaloneWindows64
- StandaloneOSX
unityVersion: ['6000.0.31f1']
include:
- targetPlatform: StandaloneWindows64
runsOn: windows-latest
modules: windows-il2cpp
- targetPlatform: StandaloneOSX
runsOn: macos-latest
modules: mac-il2cpp
steps:
- name: Check out my unity project.
uses: actions/checkout@v4.2.2
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v4.2.0
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
- name: Git LFS Pull
run: |
git lfs pull
git add .
git reset --hard
- name: Set outputs
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4.2.0
with:
path: Library
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: |
Library-
- name: Run the build for ${{ matrix.targetPlatform }}
uses: game-ci/unity-builder@v4.3.0
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
targetPlatform: ${{ matrix.targetPlatform }}
unityVersion: ${{ matrix.unityVersion }}
buildName: 'uDesktopMascot'
- name: Change build folder name
run: |
cd build
mv "${{ matrix.targetPlatform }}" "uDesktopMascot"
cd ..
- name: Unzip macOS build output
if: matrix.targetPlatform == 'StandaloneOSX'
run: |
unzip "build/uDesktopMascot/StandaloneOSX.zip" -d "build/uDesktopMascot"
rm "build/uDesktopMascot/StandaloneOSX.zip"
- name: Upload the Build for ${{ matrix.targetPlatform }}
uses: actions/upload-artifact@v4.6.0
with:
name: Build-${{ matrix.targetPlatform }}-${{ steps.vars.outputs.sha_short }}
path: build
- name: Set up Inno Setup
if: matrix.targetPlatform == 'StandaloneWindows64'
uses: Minionguyjpro/Inno-Setup-Action@v1.0.0
with:
path: 'setup.iss'
- name: Upload Installer
if: matrix.targetPlatform == 'StandaloneWindows64'
uses: actions/upload-artifact@v4.6.0
with:
name: uDesktopMascot_win64_installer
path: "build/uDesktopMascot_win64_installer.exe"