generated from ayutaz/unity_template_repository
-
-
Notifications
You must be signed in to change notification settings - Fork 27
216 lines (187 loc) · 7.34 KB
/
release-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
name: Build and Release
on:
workflow_dispatch:
inputs:
tag_name:
description: 'タグ名を「v数字.数字.数字」の形式で入力してください(例:v1.0.0)'
required: true
jobs:
create_tag:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.get_tag.outputs.tag_name }}
steps:
- name: タグ名の検証と取得
id: get_tag
run: |
TAG_NAME="${{ github.event.inputs.tag_name }}"
if [[ ! "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "エラー: タグ名が有効な形式ではありません。v数字.数字.数字 の形式で入力してください。"
exit 1
fi
echo "::set-output name=tag_name::$TAG_NAME"
- name: リポジトリをチェックアウト
uses: actions/[email protected]
with:
fetch-depth: 0
- name: タグが既に存在しないか確認
run: |
TAG_NAME="${{ steps.get_tag.outputs.tag_name }}"
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
echo "エラー: タグ '$TAG_NAME' は既に存在します。"
exit 1
fi
- name: タグを作成してプッシュ
env:
TAG_NAME: ${{ steps.get_tag.outputs.tag_name }}
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git tag "$TAG_NAME"
git push origin "$TAG_NAME"
check-branch:
needs: [create_tag]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: タグ名の確認
run: |
echo "イベント名: ${{ github.event_name }}"
TAG_NAME="${{ needs.create_tag.outputs.tag_name }}"
echo "タグ名: $TAG_NAME"
# タグ名からバージョン番号を取得
current_version="${TAG_NAME#v}"
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
build:
needs: [check-branch]
runs-on: ${{ matrix.runsOn }}
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: Unityプロジェクトをチェックアウト
uses: actions/[email protected]
- name: LFSファイルリストを作成
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: LFSキャッシュを復元
uses: actions/[email protected]
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: ビルド情報を設定
id: build_info
run: |
TAG_NAME="${{ needs.create_tag.outputs.tag_name }}"
VERSION="${{ needs.check-branch.outputs.current_version }}"
REPO_NAME="${GITHUB_REPOSITORY##*/}"
if [ "${{ matrix.targetPlatform }}" == "StandaloneWindows64" ]; then
PLATFORM="win"
elif [ "${{ matrix.targetPlatform }}" == "StandaloneOSX" ]; then
PLATFORM="mac"
else
PLATFORM="unknown"
fi
ARTIFACT_NAME="${REPO_NAME}_v${VERSION}_${PLATFORM}"
echo "artifact_name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT
- uses: actions/[email protected]
with:
path: Library
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: |
Library-
- name: ${{ matrix.targetPlatform }} 用のビルドを実行
uses: game-ci/[email protected]
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
targetPlatform: ${{ matrix.targetPlatform }}
unityVersion: ${{ matrix.unityVersion }}
- name: ビルド成果物を圧縮して名前を変更
run: |
cd build
zip -r "${{ steps.build_info.outputs.artifact_name }}.zip" *
cd ..
mv "build/${{ steps.build_info.outputs.artifact_name }}.zip" "./${{ steps.build_info.outputs.artifact_name }}.zip"
- name: ${{ matrix.targetPlatform }} 用のビルドをアップロード
uses: actions/[email protected]
with:
name: ${{ steps.build_info.outputs.artifact_name }}
path: "${{ steps.build_info.outputs.artifact_name }}.zip"
- name: Inno Setup のセットアップ
if: matrix.targetPlatform == 'StandaloneWindows64'
uses: Minionguyjpro/[email protected]
with:
path: 'setup.iss'
- name: インストーラーをアップロード
if: matrix.targetPlatform == 'StandaloneWindows64'
uses: actions/[email protected]
with:
name: uDesktopMascot_win64_installer
path: "build/uDesktopMascot_win64_installer.exe"
release:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: コードをチェックアウト
uses: actions/checkout@v4
- name: アーティファクトをダウンロード
uses: actions/download-artifact@v3
with:
path: ./artifacts
- name: タグ名を取得
id: vars
run: |
TAG_NAME="${{ needs.create_tag.outputs.tag_name }}"
echo "リリースタグ名は '${TAG_NAME}' です"
echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT
- name: ドラフトリリースを作成し、アーティファクトをアップロード
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.vars.outputs.tag_name }}
draft: true
files: artifacts/**/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}