Skip to content

Commit 4426f8d

Browse files
committed
Fix CI/Docker
1 parent f93042a commit 4426f8d

File tree

10 files changed

+99
-35
lines changed

10 files changed

+99
-35
lines changed

.envrc.local.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export DOCKER_HOST_NGINX_PORT=80
99
export UNITY_CMD=/mnt/c/Program\ Files/Unity/Hub/Editor/6000.0.37f1/Editor/Unity.exe # wsl
1010
export UNITY_PACKAGES_BUCKET=s3://my-unity-packages
1111
export UNITY_PACKAGES_CACHE_PREFIX=1
12-
export ULF_FILE=Unity_v6000.0.37f1.alf
12+
export ULF_FILE=Unity_v6000.x.ulf
1313
export BASE64_ULF=$(cat $ULF_FILE | base64)
1414

1515
#-------------------------------------------------------------------------------

.github/workflows/main.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,22 @@ jobs:
1616
build:
1717
runs-on: ubuntu-latest
1818
container:
19-
image: gableroux/unity3d:2019.3.9f1-webgl
19+
image: unityci/editor:ubuntu-6000.0.37f1-webgl-3.1
2020
env:
21-
UNITY_CMD: /opt/Unity/Editor/Unity
21+
UNITY_CMD: /opt/unity/Editor/Unity
22+
ULF_FILE: Unity_v6000.x.ulf
2223
BASE64_ULF: ${{ secrets.BASE64_ULF }}
2324
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
2425
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
2526
UNITY_PACKAGES_BUCKET: ${{ secrets.UNITY_PACKAGES_BUCKET }}
2627
UNITY_PACKAGES_CACHE_PREFIX: ${{ secrets.UNITY_PACKAGES_CACHE_PREFIX }}
2728
FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
2829
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
30+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
2931

3032
steps:
3133
# Checkout
32-
- uses: actions/checkout@v2
34+
- uses: actions/checkout@v4
3335

3436
# Add PATH
3537
- run: echo "::add-path::${GITHUB_WORKSPACE}/bin"
@@ -60,7 +62,7 @@ jobs:
6062

6163
# Download Unity packages
6264
- name: Cache Unity packages
63-
uses: actions/cache@v1
65+
uses: actions/cache@v4
6466
with:
6567
path: /root/unity-assets
6668
key: minecraft-clone-unity-packages-${{ secrets.UNITY_PACKAGES_CACHE_PREFIX }}-${{ hashFiles('Packages/asset.json') }}
@@ -69,17 +71,13 @@ jobs:
6971

7072
# Build
7173
- name: Expand ULF file
72-
run: echo ${BASE64_ULF} | base64 -d > Unity_v2019.x.ulf
74+
run: echo ${BASE64_ULF} | base64 -d > ${ULF_FILE}
7375
- name: Activation
74-
run: unity -manualLicenseFile Unity_v2019.x.ulf || true
76+
run: unity -manualLicenseFile ${ULF_FILE} || true
7577
- name: Import Assets
7678
run: unity -executeMethod ImportAssets.Import /basePath /root/unity-assets
77-
- name: Apply patches
78-
run: apply_patch
79-
- name: Generate Textures
80-
run: generate_texture
8179
- name: Build
82-
run: unity -executeMethod Builder.Build /platform webgl
80+
run: unity -executeMethod Builder.BuildWebGL
8381

8482
# Deploy to Firebase
8583
- name: Make .firebaserc
@@ -88,7 +86,7 @@ jobs:
8886
run: firebase deploy --token=${FIREBASE_TOKEN}
8987

9088
# Upload Artifacts
91-
- uses: actions/upload-artifact@v2
89+
- uses: actions/upload-artifact@v4
9290
with:
9391
name: minecraft-clone.webgl
9492
path: Build/minecraft-clone.webgl

Assets/MinecraftClone/Editor/Builder.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ public class Builder
1010
{
1111
{ "webgl", BuildTarget.WebGL },
1212
{ "osx", BuildTarget.StandaloneOSX },
13+
{ "windows", BuildTarget.StandaloneWindows64 },
1314
};
1415

1516
private static Dictionary<BuildTarget, string> OutputNames { get; } = new Dictionary<BuildTarget, string>
1617
{
17-
{ BuildTarget.WebGL, "minecraft-clone.webgl" },
18-
{ BuildTarget.StandaloneOSX, "minecraft-clone.app" },
18+
{ BuildTarget.WebGL, "webgl/minecraft-clone.webgl" },
19+
{ BuildTarget.StandaloneOSX, "osx/minecraft-clone.app" },
20+
{ BuildTarget.StandaloneWindows64, "windows/minecraft-clone.exe" },
1921
};
2022

2123
public class Args
@@ -34,6 +36,12 @@ public static void BuildWebGL()
3436
Build(new Args(platform: BuildTarget.WebGL));
3537
}
3638

39+
[MenuItem("Window/BuildWindows")]
40+
public static void BuildWindows()
41+
{
42+
Build(new Args(platform: BuildTarget.StandaloneWindows64));
43+
}
44+
3745
public static void Build(Args args = null)
3846
{
3947
args = args ?? ArgsFromCommandLine();
0 Bytes
Binary file not shown.

Assets/Resources.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Docker/nginx/nginx.conf

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
11
server {
2-
listen 80 default;
3-
server_name _;
2+
listen 80 default;
3+
server_name _;
44

5-
location / {
6-
root /app/Build/minecraft-clone.webgl;
7-
index index.html index.htm;
5+
location / {
6+
root /app/Build/webgl/minecraft-clone.webgl;
7+
index index.html index.htm;
8+
9+
# Add for single page application
10+
try_files $uri /index.html;
11+
12+
# On-disk gzip-precompressed data files should be served with compression enabled:
13+
location ~ .+\.(data|symbols\.json)\.gz$ {
14+
gzip off; # Do not attempt dynamic gzip compression on an already compressed file
15+
add_header Content-Encoding gzip;
16+
default_type application/gzip;
17+
}
18+
19+
# On-disk gzip-precompressed JavaScript code files:
20+
location ~ .+\.js\.gz$ {
21+
gzip off; # Do not attempt dynamic gzip compression on an already compressed file
22+
add_header Content-Encoding gzip; # The correct MIME type here would be application/octet-stream, but due to Safari bug https://bugs.webkit.org/show_bug.cgi?id=247421, it's preferable to use MIME Type application/gzip instead.
23+
default_type application/javascript;
24+
}
25+
26+
# On-disk gzip-precompressed WebAssembly files:
27+
location ~ .+\.wasm\.gz$ {
28+
gzip off; # Do not attempt dynamic gzip compression on an already compressed file
29+
add_header Content-Encoding gzip;
30+
# Enable streaming WebAssembly compilation by specifying the correct MIME type for
31+
# Wasm files.
32+
default_type application/wasm;
833
}
34+
}
935
}

Docker/unity/Dockerfile

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,26 @@ RUN git clone https://github.com/progrium/entrykit.git && \
1212
#------------------------------------------------------------------------------
1313
# Base
1414
#------------------------------------------------------------------------------
15-
FROM gableroux/unity3d:2019.3.9f1-webgl
15+
FROM unityci/editor:ubuntu-6000.0.37f1-webgl-3.1
1616

1717
# Install basic packages
18-
RUN apt-get update -qq && \
19-
apt-get install -y build-essential tree vim less curl unzip dnsutils net-tools procps && \
20-
apt-get install -y --no-install-recommends apt-utils && \
21-
apt-get install -y gettext
18+
RUN apt update -qq && \
19+
apt install -y build-essential tree vim less curl unzip dnsutils net-tools procps && \
20+
apt install -y --no-install-recommends apt-utils && \
21+
apt install -y gettext
2222

2323
# Install Ruby
24-
RUN apt-get install -y ruby
24+
RUN apt install -y ruby
2525

26-
# Install Node.js 12.16.3
26+
# Install Node.js(System)
27+
RUN apt install -y nodejs npm
28+
29+
# Install Node.js 22.14.0
2730
# @see https://www.trifields.jp/how-to-install-node-js-on-ubuntu1804-3544
28-
RUN npm install -g n && n 12.16.3
31+
RUN npm install -g n && n 22.14.0
2932

3033
# Install ImageMagick
31-
RUN apt-get install -y imagemagick
34+
RUN apt install -y imagemagick
3235

3336
# Install openupm
3437
RUN npm install -g openupm-cli
@@ -55,7 +58,8 @@ RUN echo "dash dash/sh boolean false" | debconf-set-selections && \
5558
ENV APP_HOME /app
5659
ENV SHELL /bin/bash
5760
ENV EDITOR vim
58-
ENV UNITY_CMD /opt/Unity/Editor/Unity
61+
ENV UNITY_CMD /opt/unity/Editor/Unity
62+
ENV ULF_FILE Unity_v6000.x.ulf
5963
ENV PATH $APP_HOME/bin:$PATH
6064
RUN mkdir -p $APP_HOME
6165

ProjectSettings/ProjectSettings.asset

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,10 @@ PlayerSettings:
600600
m_BuildTargetGroupLightmapSettings: []
601601
m_BuildTargetGroupLoadStoreDebugModeSettings: []
602602
m_BuildTargetNormalMapEncoding: []
603-
m_BuildTargetDefaultTextureCompressionFormat: []
603+
m_BuildTargetDefaultTextureCompressionFormat:
604+
- serializedVersion: 3
605+
m_BuildTarget: WebGL
606+
m_Formats: 05000000
604607
playModeTestRunnerEnabled: 0
605608
runPlayModeTestAsEditModeTest: 0
606609
actionOnDotNetUnhandledException: 1

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
* ImageMagick
1313
* Ruby
1414
* direnv
15-
* Docker: >= 18.06
16-
* docker-compose: >= 1.25.0
15+
* Docker: >= 27.3.1
16+
* docker-compose: >= v2.29.7-desktop.1
1717

1818
### Optional
1919

@@ -36,6 +36,7 @@ direnv allow .
3636

3737
# Activation
3838
unity -createManualActivationFile
39+
3940
## Upload the manual activation file on https://license.unity3d.com/manual
4041
unity -manualLicenseFile ${ULF_FILE}
4142

@@ -54,14 +55,30 @@ generate_texture
5455
# Create activation file
5556
unity -createManualActivationFile
5657

58+
# Create activation file(for docker/CI)
59+
unity -createManualActivationFile -username <email> -password <password>
60+
5761
# Activation
5862
unity -manualLicenseFile ${ULF_FILE}
5963

6064
# Import assets
6165
unity -executeMethod ImportAssets.Import /basePath /path/to/assets
6266

6367
# Build app
64-
unity -executeMethod Builder.Build /platform webgl
68+
unity -executeMethod Builder.BuildWebGL
69+
```
70+
71+
### WebGL
72+
73+
```sh
74+
# Build docker image
75+
docker compose build
76+
77+
# Build WebGL app
78+
docker compose run -it --rm unity "unity -manualLicenseFile ${ULF_FILE} && unity -executeMethod Builder.BuildWebGL"
79+
80+
# Boot WebGL app
81+
docker compose up
6582
```
6683

6784
### Deploy to Firebase
@@ -76,3 +93,4 @@ firebase deploy
7693
* [Minecraft clone design | mrk21 Kibela](https://mrk21.kibe.la/shared/entries/3d340747-4142-4568-9d78-d0ce494ca9d7)
7794
* [Minecraft clone memo | mrk21 Kibela](https://mrk21.kibe.la/shared/entries/294c5ea1-70db-40ca-a455-7f3266158789)
7895
* [【Unity】Unityでメモリリーク発生?原因と調査方法について – 株式会社ロジカルビート](https://logicalbeat.jp/blog/15426/)
96+
* [UnityのPersonalライセンスで.ulfファイルをダウンロードする方法(2024/6時点)](https://zenn.dev/hirosukekayaba/articles/067693ad146d18)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
version: '3.7'
32
services:
43
app:
54
image: nginx

0 commit comments

Comments
 (0)