-
Notifications
You must be signed in to change notification settings - Fork 59
337 lines (309 loc) · 13.7 KB
/
BitMono.Build.yaml
File metadata and controls
337 lines (309 loc) · 13.7 KB
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
name: BitMono.Build
on:
create:
tags:
- "*"
push:
branches: [ main ]
paths:
- '.github/workflows/BitMono.Build.yaml'
- 'props/SharedPackages.props'
- 'props/SharedProjectProps.props'
- 'props/SharedTestProps.props'
- 'src/**'
- 'test/**'
pull_request:
paths:
- '.github/workflows/BitMono.Build.yaml'
- 'props/SharedPackages.props'
- 'props/SharedProjectProps.props'
- 'props/SharedTestProps.props'
- 'src/**'
- 'test/**'
jobs:
Build:
runs-on: ubuntu-latest
strategy:
matrix:
target-framework: [net10.0, net9.0, net8.0, net7.0, net6.0, net462, netstandard2.1, netstandard2.0]
runtime: [linux-x64, win-x64, linux-arm64, win-arm64, osx-x64, osx-arm64, win-x86]
exclude:
# Exclude win-x86 builds for .NET Standard as they're architecture-independent
- runtime: win-x86
target-framework: netstandard2.0
- runtime: win-x86
target-framework: netstandard2.1
outputs:
version: ${{ steps.project-build.outputs.version }}
is_prerelease: ${{ steps.project-build.outputs.is_prerelease }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
env:
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
with:
dotnet-version: 10.x
- name: Build Project
uses: ./.github/actions/project-build
id: project-build
with:
project_path: src/BitMono.CLI/BitMono.CLI.csproj
nuget_push: false
target_framework: ${{ matrix.target-framework }}
runtime_version: ${{ matrix.runtime }}
github_token: ${{ secrets.PAT }}
- name: Install zip (for Linux/macOS)
run: |
if [[ "${{ matrix.runtime }}" =~ ^linux ]]; then
sudo apt-get install -y zip
elif [[ "${{ matrix.runtime }}" =~ ^osx ]]; then
if ! command -v zip &> /dev/null; then
echo "zip is not available on this macOS runner, and it should be pre-installed."
exit 1
fi
fi
- name: Zip artifacts
run: |
cd ./src/BitMono.CLI/bin/Release/${{ matrix.target-framework }}/${{ matrix.runtime }} && \
zip -qq -r ./BitMono-v${{ steps.project-build.outputs.version }}-CLI-${{ matrix.target-framework }}-${{ matrix.runtime }}.zip *
- name: Upload build
uses: actions/upload-artifact@v6
with:
name: BitMono-v${{ steps.project-build.outputs.version }}-CLI-${{ matrix.target-framework }}-${{ matrix.runtime }}
path: "./src/BitMono.CLI/bin/Release/${{ matrix.target-framework }}/${{ matrix.runtime }}/BitMono-v${{ steps.project-build.outputs.version }}-CLI-${{ matrix.target-framework }}-${{ matrix.runtime }}.zip"
if-no-files-found: error
UnityPackage:
runs-on: ubuntu-latest
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'create' && github.event.ref_type == 'tag')
strategy:
matrix:
# Note:
# GameCI currently has delays publishing some newer Unity versions to Docker Hub.
# Newer tags (post-2024-05-16), e.g. 2022.3.50f1 and 6000.0.x (6.0/6.1/6.2), may be unavailable.
# See GameCI announcement in Discord. Using last known published versions instead.
unity-version: [
2019.4.40f1,
2020.3.48f1,
2021.3.45f1,
2022.3.29f1, # replaced 2022.3.50f1 (not published)
6000.0.2f1 # replaced 6.0.0f1/6.1.0f1/6.2.0f1 (not published)
# 2022.3.50f1, # not published on unityci/editor yet
# 6.0.0f1, # not published on unityci/editor yet
# 6.1.0f1, # not published on unityci/editor yet
# 6.2.0f1 # not published on unityci/editor yet
]
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Cache Unity Library
uses: actions/cache@v5
with:
path: test/BitMono.Unity.TestProject/Library
key: Library-BitMono-Unity-${{ matrix.unity-version }}
restore-keys: |
Library-BitMono-Unity-
Library-
- name: Setup .NET
uses: actions/setup-dotnet@v5
env:
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
with:
dotnet-version: 10.x
- name: Build BitMono.CLI for Unity Package
uses: ./.github/actions/project-build
id: cli-build
with:
project_path: src/BitMono.CLI/BitMono.CLI.csproj
nuget_push: false
target_framework: net462
runtime_version: win-x64
github_token: ${{ secrets.PAT }}
- name: Copy Unity files to test project
run: |
mkdir -p test/BitMono.Unity.TestProject/Assets/BitMono.Unity
cp -R src/BitMono.Unity/* test/BitMono.Unity.TestProject/Assets/BitMono.Unity/
# Keep CLI inside Assets but we'll disable import via PluginImporter/meta
mkdir -p test/BitMono.Unity.TestProject/Assets/BitMono.Unity/BitMono.CLI
cp -R src/BitMono.CLI/bin/Release/net462/win-x64/* test/BitMono.Unity.TestProject/Assets/BitMono.Unity/BitMono.CLI/
# Copy BitMonoConfig.cs.meta if it exists to preserve GUID for ScriptableObject binding
if [ -f src/BitMono.Unity/Editor/BitMonoConfig.cs.meta ]; then
cp src/BitMono.Unity/Editor/BitMonoConfig.cs.meta test/BitMono.Unity.TestProject/Assets/BitMono.Unity/Editor/BitMonoConfig.cs.meta
fi
# Generate .meta files to disable Unity import for all CLI DLLs (prevents load on project open)
CLI_DIR="test/BitMono.Unity.TestProject/Assets/BitMono.Unity/BitMono.CLI"
if [ -d "$CLI_DIR" ]; then
while IFS= read -r -d '' dll; do
meta="${dll}.meta"
name="$(basename "$dll")"
base="${name%.*}"
guid="${base}000000000000000000000000000000"
printf "%s\n" \
"fileFormatVersion: 2" \
"guid: ${guid}" \
"PluginImporter:" \
" serializedVersion: 2" \
" isPreloaded: 0" \
" isOverridable: 0" \
" platformData:" \
" - first:" \
" Any:" \
" second:" \
" enabled: 0" \
" userData:" \
" assetBundleName:" \
" assetBundleVariant:" \
> "$meta"
done < <(find "$CLI_DIR" -type f -name "*.dll" -print0)
fi
- name: Setup Unity for Package Export
uses: game-ci/unity-builder@v4
env:
PACKAGE_VERSION: ${{ steps.cli-build.outputs.version }}
VERSION: ${{ steps.cli-build.outputs.version }}
UNITY_VERSION: ${{ matrix.unity-version }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
unityVersion: ${{ matrix.unity-version }}
targetPlatform: StandaloneLinux64
buildMethod: BitMono.Editor.PackageExporter.ExportPackage
projectPath: test/BitMono.Unity.TestProject
buildName: BitMono-Unity-Package
allowDirtyBuild: true
- name: Verify .unitypackage was created
run: |
set -e
VERSION_NO_HASH='${{ steps.cli-build.outputs.version }}'
# Strip any SemVer build metadata (e.g., +<commit-hash>) for filenames
VERSION_NO_HASH="${VERSION_NO_HASH%%+*}"
UNITY_VER='${{ matrix.unity-version }}'
FILE="BitMono-Unity-v${VERSION_NO_HASH}-Unity${UNITY_VER}.unitypackage"
if [ ! -f "$FILE" ]; then
echo "Unity package not found at expected path: ./$FILE" >&2
echo "Available unitypackages:" >&2
find . -name "*.unitypackage" -print
exit 1
fi
echo "Unity package created: $FILE"
size_bytes=$(stat -c%s -- "$FILE")
size_mb=$(awk -v s="$size_bytes" 'BEGIN {printf "%.2f", s/1024/1024}')
echo "File size: ${size_mb} MB"
- name: Rename .unitypackage to include build metadata (if present)
run: |
VERSION_FULL='${{ steps.cli-build.outputs.version }}'
UNITY_VER='${{ matrix.unity-version }}'
BASE="BitMono-Unity-v${VERSION_FULL%%+*}-Unity${UNITY_VER}.unitypackage"
if [[ "$VERSION_FULL" == *+* ]]; then
TARGET="BitMono-Unity-v${VERSION_FULL}-Unity${UNITY_VER}.unitypackage"
if [ -f "$BASE" ]; then
echo "Renaming $BASE -> $TARGET"
mv -f "$BASE" "$TARGET"
else
echo "Expected base package not found for rename: $BASE" >&2
fi
else
echo "No build metadata in version; keeping filename: $BASE"
fi
- name: Create Unity Package Directory
run: |
mkdir -p unity-package-temp/Editor
- name: Copy Unity Package Files
run: |
cp src/BitMono.Unity/Editor/*.cs unity-package-temp/Editor/
cp src/BitMono.Unity/Editor/*.asmdef unity-package-temp/Editor/ || echo "No .asmdef files found"
cp src/BitMono.Unity/package.json unity-package-temp/
# Ensure BitMonoConfig.asset is included in package content
if [ -f src/BitMono.Unity/BitMonoConfig.asset ]; then
cp src/BitMono.Unity/BitMonoConfig.asset unity-package-temp/
else
echo "BitMonoConfig.asset not found in src/BitMono.Unity" >&2
fi
mkdir -p unity-package-temp/BitMono.CLI
cp -R src/BitMono.CLI/bin/Release/net462/win-x64/* unity-package-temp/BitMono.CLI/
- name: Update Package Version and Unity Version
run: |
sudo apt-get update && sudo apt-get install -y jq
unityVersion='${{ matrix.unity-version }}'
unityShort=$(echo "$unityVersion" | sed -E 's/^(\d+\.\d+)\..*/\1/')
tmp=$(mktemp)
jq \
--arg ver '${{ steps.cli-build.outputs.version }}' \
--arg unity "$unityShort" \
'.version=$ver | .unity=$unity' \
unity-package-temp/package.json > "$tmp" && mv "$tmp" unity-package-temp/package.json
echo "Updated package.json:"
echo " Version: ${{ steps.cli-build.outputs.version }}"
echo " Unity: $unityShort"
- name: Test Unity Package Compatibility
run: |
echo "Testing Unity version compatibility..."
pkgUnity=$(jq -r '.unity' unity-package-temp/package.json)
pkgUnityRelease=$(jq -r '.unityRelease // ""' unity-package-temp/package.json)
echo "Package Unity version: $pkgUnity"
echo "Package Unity release: $pkgUnityRelease"
echo "Target Unity version: ${{ matrix.unity-version }}"
- name: Create UPM Package (Modern Unity Package Manager)
run: |
# Create a proper UPM package structure (POSIX for Ubuntu runners)
mkdir -p upm-package/Editor
# Copy files to UPM structure
cp unity-package-temp/Editor/*.cs upm-package/Editor/ 2>/dev/null || true
cp unity-package-temp/Editor/*.asmdef upm-package/Editor/ 2>/dev/null || echo "No .asmdef files found"
cp unity-package-temp/package.json upm-package/
# Prefer copying BitMonoConfig.asset from source; fallback to temp if needed
if [ -f src/BitMono.Unity/BitMonoConfig.asset ]; then
cp src/BitMono.Unity/BitMonoConfig.asset upm-package/
else
cp unity-package-temp/BitMonoConfig.asset upm-package/ 2>/dev/null || echo "No BitMonoConfig.asset found"
fi
mkdir -p upm-package/BitMono.CLI
cp -R unity-package-temp/BitMono.CLI/* upm-package/BitMono.CLI/ 2>/dev/null || true
# Create UPM tarball using tar (better compatibility than .zip)
cd upm-package
tar -czf ../BitMono-Unity-UPM-v${{ steps.cli-build.outputs.version }}-Unity${{ matrix.unity-version }}.tgz *
cd ..
- name: Upload Unity Packages
uses: actions/upload-artifact@v6
with:
name: BitMono-Unity-v${{ steps.cli-build.outputs.version }}-Unity${{ matrix.unity-version }}
path: |
BitMono-Unity-v*-Unity${{ matrix.unity-version }}.unitypackage
BitMono-Unity-UPM-v*-Unity${{ matrix.unity-version }}.tgz
if-no-files-found: error
Release:
if: github.event_name == 'create' && github.event.ref_type == 'tag'
needs: [Build, UnityPackage]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
path: ./artifacts
- name: List downloaded artifacts
run: |
echo "Downloaded artifacts:"
find ./artifacts -type f -name "*.zip" -o -name "*.unitypackage"
echo ""
echo "Unity packages by version:"
find ./artifacts -name "*Unity*.unitypackage" | sort
- name: Create Release
uses: ncipollo/release-action@v1
with:
name: BitMono Release v${{ needs.Build.outputs.version }}
tag: ${{ needs.Build.outputs.version }}
artifacts: "./artifacts/**/*.zip,./artifacts/**/*.unitypackage,./artifacts/**/*.tgz"
token: ${{ secrets.PAT }}
prerelease: ${{ needs.Build.outputs.is_prerelease }}
allowUpdates: true
draft: true