Skip to content

Commit 6413a45

Browse files
committed
ci: add build & upload vrchat world ci
1 parent 892baeb commit 6413a45

File tree

3 files changed

+175
-0
lines changed

3 files changed

+175
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { readFileSync, existsSync, writeFileSync, mkdir, mkdirSync } = require('fs')
2+
const { homedir } = require('os')
3+
const path = require('path')
4+
5+
if (process.platform !== 'linux') {
6+
throw new Error("This script is only for linux")
7+
}
8+
9+
if (process.argv.length !== 3) {
10+
throw new Error("Usage: node add-user-package-to-vrc-get.js <path>")
11+
}
12+
13+
let vccConfigPath = path.join(homedir(), ".local", "share", 'VRChatCreatorCompanion')
14+
let vccConfigJsonPath = path.join(vccConfigPath, "settings.json")
15+
16+
console.log('vrc-get config path:', vccConfigPath)
17+
console.log('vrc-get config json path:', vccConfigJsonPath)
18+
19+
if (!existsSync(vccConfigJsonPath)) {
20+
mkdirSync(vccConfigPath, { recursive: true })
21+
writeFileSync(vccConfigJsonPath, '{}')
22+
}
23+
24+
const originConfigRaw = readFileSync(vccConfigJsonPath, 'utf8')
25+
const originConfig = JSON.parse(originConfigRaw)
26+
27+
if (!originConfig.userPackageFolders || Array.isArray(originConfig.userPackageFolders)) {
28+
originConfig.userPackageFolders = []
29+
}
30+
31+
originConfig.userPackageFolders.push(process.argv[2])
32+
33+
const newConfigRaw = JSON.stringify(originConfig)
34+
35+
writeFileSync(vccConfigJsonPath, newConfigRaw)
36+
37+
console.log('Added user package folder to vrc-get config:', process.argv[2])
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const license = require('fs').readFileSync(0, 'utf-8');
2+
3+
const startKey = `<DeveloperData Value="`;
4+
const endKey = `"/>`;
5+
const startIndex = license.indexOf(startKey) + startKey.length;
6+
if (startIndex < 0) {
7+
throw new Error(`License File was corrupted, unable to locate serial`);
8+
}
9+
const endIndex = license.indexOf(endKey, startIndex);
10+
11+
const serial = Buffer.from(license.slice(startIndex, endIndex), 'base64').toString('binary').slice(4)
12+
process.stdout.write(serial);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Build & Upload VRChat World
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
release:
8+
types: [published]
9+
workflow_dispatch:
10+
11+
jobs:
12+
build-and-upload-nightly-world:
13+
runs-on: ubuntu-latest
14+
15+
env:
16+
unity-docker-image: unityci/editor:ubuntu-2022.3.22f1-windows-mono-3.1.0
17+
workspace-path: "${{ github.workspace }}/workspace"
18+
source-path: "${{ github.workspace }}/source"
19+
add-packages-script-path: "${{ github.workspace }}/source/.github/workflow-scripts/add-user-package-to-vrc-get.js"
20+
get-serial-script-path: "${{ github.workspace }}/source/.github/workflow-scripts/get-serial-from-license-file.js"
21+
UNITY_SERIAL: XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
if: github.event_name != 'release'
27+
with:
28+
path: ${{ env.source-path }}
29+
30+
- name: Download Release Package
31+
uses: robinraju/release-downloader@a96f54c1b5f5e09e47d9504526e96febd949d4c2
32+
if: github.event_name == 'release'
33+
with:
34+
latest: true
35+
preRelease: false
36+
out-file-path: ${{ env.source-path }}
37+
fileName: "*.zip"
38+
extract: true
39+
40+
- name: Download Workspace Project
41+
uses: robinraju/release-downloader@a96f54c1b5f5e09e47d9504526e96febd949d4c2
42+
with:
43+
repository: ${{ secrets.WORKSPACE_PROJECT_REPOSITORY }}
44+
tag: ${{ secrets.WORKSPACE_PROJECT_TAG }}
45+
out-file-path: ${{ env.workspace-path }}
46+
fileName: "*.zip"
47+
extract: true
48+
token: ${{ secrets.ACTION_GITHUB_TOKEN }}
49+
50+
- name: Setup vrc-get
51+
uses: anatawa12/sh-actions/setup-vrc-get@master
52+
53+
- name: Add VPM Repositories
54+
run: |
55+
vrc-get repo add https://vpm.gyoku.tech/vpm.json
56+
vrc-get repo add https://pkg-index.yuxiaviation.com
57+
vrc-get repo add https://orels1.github.io/UdonToolkit/index.json
58+
vrc-get repo add https://vrcd-community.github.io/vpm-packages/index.json
59+
vrc-get repo list
60+
61+
- name: Resolve VPM Dependencies
62+
working-directory: ${{ env.workspace-path }}
63+
run: "vrc-get resolve"
64+
65+
- name: Add Source Package to vrc-get
66+
if: github.event_name != 'release'
67+
run: "node ${{ env.add-packages-script-path }} ${{ env.source-path }}/src/Packages/com.yuxiaviation.v320neo.fdmi"
68+
69+
- name: Add Release Pacakge to vrc-get
70+
if: github.event_name == 'release'
71+
run: "node ${{ env.add-packages-script-path }} ${{ env.source-path }}"
72+
73+
- name: Add Source Pacakge to Workspace
74+
working-directory: ${{ env.workspace-path }}
75+
run: "vrc-get install com.yuxiaviation.v320neo.fdmi -y"
76+
77+
- name: Add AutoBuild Packages to Workspace
78+
working-directory: ${{ env.workspace-path }}
79+
run: |
80+
vrc-get install com.yuxiaviation.vrchat.autobuild -y
81+
vrc-get install com.yuxiaviation.vrchat.autobuild.world -y
82+
83+
- name: Add Patcher Package to fix SDK Build on Linux
84+
working-directory: ${{ env.workspace-path }}
85+
run: |
86+
vrc-get install cn.org.vrcd.vpm.vrchat-sdk-patcher -y
87+
vrc-get install cn.org.vrcd.vpm.vrchat-sdk-patcher.worlds -y
88+
89+
- name: Cache Library
90+
uses: actions/cache@v4
91+
with:
92+
path: ${{ env.workspace-path }}/Library
93+
key: Library-Build-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
94+
restore-keys: |
95+
Library-Build-
96+
97+
- name: Get Unity Serial
98+
env:
99+
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
100+
run: |
101+
UNITY_SERIAL="$(echo $UNITY_LICENSE | node ${{ env.get-serial-script-path }})"
102+
echo "::add-mask::$UNITY_SERIAL"
103+
echo "UNITY_SERIAL=$UNITY_SERIAL" >> $GITHUB_ENV
104+
105+
- name: Build & Upload VRChat World
106+
run: |
107+
docker run \
108+
-v ${{ env.workspace-path }}:/project \
109+
-v ${{ github.workspace }}/tmp:/tmp/DefaultCompany/ \
110+
-e VRC_AUTO_BUILD_USERNAME=$VRC_AUTO_BUILD_USERNAME \
111+
-e VRC_AUTO_BUILD_PASSWORD=$VRC_AUTO_BUILD_PASSWORD \
112+
-e VRC_AUTO_BUILD_TOTP_KEY=$VRC_AUTO_BUILD_TOTP_KEY \
113+
-e VRC_AUTO_BUILD_SCENE_PATH=$VRC_AUTO_BUILD_SCENE_PATH \
114+
-e VRC_AUTO_BUILD_CONTENT_ID=$VRC_AUTO_BUILD_CONTENT_ID \
115+
${{ env.unity-docker-image }} \
116+
unity-editor -projectPath /project \
117+
-username ${{ secrets.UNITY_EMAIL }} -password ${{ secrets.UNITY_PASSWORD }} -serial ${{ env.UNITY_SERIAL }} \
118+
-batchmode -logFile - \
119+
-buildTarget Win64 \
120+
-executeMethod VRChatAerospaceUniversity.VRChatAutoBuild.Worlds.AutoBuildVRChatWorld.BuildAndUploadWorld
121+
env:
122+
VRC_AUTO_BUILD_CONTENT_ID: ${{ vars.NIGHTLY_WORLD_CONTENT_ID }}
123+
VRC_AUTO_BUILD_SCENE_PATH: ${{ secrets.WORKSPACE_SCENE_PATH }}
124+
VRC_AUTO_BUILD_USERNAME: ${{ secrets.VRCHAT_USERNAME }}
125+
VRC_AUTO_BUILD_PASSWORD: ${{ secrets.VRCHAT_PASSWORD }}
126+
VRC_AUTO_BUILD_TOTP_KEY: ${{ secrets.VRCHAT_TOTP_KEY }}

0 commit comments

Comments
 (0)