Skip to content

Commit 133b102

Browse files
authored
chore: binary compression and separate platform builds (AscensionGameDev#2059)
* chore: split builds by OS for concurrency benefits and unix permissions * fix: disable editor before restoring * debugger job * I think the concurrent builds stepped over eachother because they were uploading the same files * fix debugger job * move packaging into publish step to reduce inter-job artifacts * limit artifacts to only Client/Editor/Server * debugging the files now :eyeroll: * possible fix to artifact source files * possible fix to artifact source files * packaging debugging * clarify description * clarify description * forum-only skip * add names and correct Debug output * better step name
1 parent b3eda0c commit 133b102

File tree

4 files changed

+207
-46
lines changed

4 files changed

+207
-46
lines changed

.github/workflows/build.yml

Lines changed: 204 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@ on:
2121
default: false
2222
type: boolean
2323
workflowDebug:
24-
description: 'If the workflow should be debugged (skip release)'
24+
description: 'If the workflow should be debugged (skips packaging and publishing)'
25+
default: true
26+
type: boolean
27+
packagingDebug:
28+
description: 'If the packaging step should be debugged (skips publishing)'
29+
default: true
30+
type: boolean
31+
skipForumPublish:
32+
description: 'If publishing to the forum should be skipped'
2533
default: true
2634
type: boolean
2735

@@ -33,10 +41,67 @@ env:
3341
VERSION_SUFFIX: -beta
3442

3543
jobs:
36-
build:
44+
build-linux:
45+
name: Build for Linux
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Checkout Code
49+
uses: actions/checkout@v4
50+
with:
51+
submodules: recursive
3752

38-
runs-on: windows-latest
53+
- name: Cache binaries
54+
uses: actions/cache@v3
55+
id: cache-binaries
56+
with:
57+
key: ${{ runner.os }}-binaries-${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}-${{ hashFiles('Intersect*/**/*.cs*') }}
58+
path: |
59+
Intersect*/bin/Release/**/*
60+
61+
- name: Setup dotnet
62+
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
63+
uses: actions/setup-dotnet@v3
64+
with:
65+
dotnet-version: 7.0.x
3966

67+
- name: Cache NuGet dependencies
68+
uses: actions/cache@v3
69+
id: cache-nuget
70+
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
71+
with:
72+
key: ${{ runner.os }}-nuget-${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}-${{ hashFiles('Intersect*/*.csproj') }}
73+
path: |
74+
~/.nuget/packages
75+
Intersect*/obj/
76+
77+
- name: Apply environment patches
78+
run: git apply disable-windows-editor.patch
79+
80+
- name: Restore NuGet Packages
81+
if: steps.cache-binaries.outputs.cache-hit != 'true' && steps.cache-nuget.outputs.cache-hit != 'true' || inputs.forceRestore == true
82+
run: dotnet restore Intersect.sln
83+
84+
- name: Build solution
85+
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
86+
run: dotnet publish Intersect.sln --sc -r linux-x64 -p:Configuration=Release -p:PackageVersion=${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}+build.${{ github.sha }} -p:Version=${{ env.VERSION_PREFIX }}.${{ github.run_number }}
87+
88+
- name: Debug files on disk
89+
if: inputs.workflowDebug == true
90+
run: ls -R .
91+
92+
- name: Upload artifacts
93+
uses: actions/upload-artifact@v3
94+
with:
95+
if-no-files-found: error
96+
name: engine
97+
path: |
98+
./Intersect.Client/bin/Release/*/*/publish
99+
./Intersect.Editor/bin/Release/*/*/publish
100+
./Intersect.Server/bin/Release/*/*/publish
101+
102+
build-macos:
103+
name: Build for MacOS
104+
runs-on: macos-latest
40105
steps:
41106
- name: Checkout Code
42107
uses: actions/checkout@v4
@@ -67,69 +132,162 @@ jobs:
67132
~/.nuget/packages
68133
Intersect*/obj/
69134
135+
- name: Apply environment patches
136+
run: git apply disable-windows-editor.patch
137+
70138
- name: Restore NuGet Packages
71139
if: steps.cache-binaries.outputs.cache-hit != 'true' && steps.cache-nuget.outputs.cache-hit != 'true' || inputs.forceRestore == true
72140
run: dotnet restore Intersect.sln
73141

74-
# - run: ls -R ~/.nuget/packages
75-
76142
- name: Build solution
77143
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
78-
run: |
79-
dotnet publish Intersect.sln -r win-x64 -p:Configuration=Release -p:PackageVersion=${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}+build.${{ github.sha }} -p:Version=${{ env.VERSION_PREFIX }}.${{ github.run_number }}
80-
git apply disable-windows-editor.patch
81-
dotnet publish Intersect.sln -r linux-x64 -p:Configuration=Release -p:PackageVersion=${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}+build.${{ github.sha }} -p:Version=${{ env.VERSION_PREFIX }}.${{ github.run_number }}
82-
dotnet publish Intersect.sln -r osx-x64 -p:Configuration=Release -p:PackageVersion=${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}+build.${{ github.sha }} -p:Version=${{ env.VERSION_PREFIX }}.${{ github.run_number }}
144+
run: dotnet publish Intersect.sln --sc -r osx-x64 -p:Configuration=Release -p:PackageVersion=${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}+build.${{ github.sha }} -p:Version=${{ env.VERSION_PREFIX }}.${{ github.run_number }}
83145

84-
# - name: Debug output of Build Solution
85-
# run: ls -R
146+
- name: Debug files on disk
147+
if: inputs.workflowDebug == true
148+
run: ls -R .
86149

87-
- name: Checkout assets main_upgrade branch
88-
uses: actions/checkout@v4
150+
- name: Upload artifacts
151+
uses: actions/upload-artifact@v3
89152
with:
90-
fetch-depth: 0
91-
path: assets_upgrade
92-
repository: AscensionGameDev/Intersect-Assets
93-
ref: main_upgrade
94-
token: ${{ secrets.INTERSECTBOT_ACCESS_TOKEN }}
153+
if-no-files-found: error
154+
name: engine
155+
path: |
156+
./Intersect.Client/bin/Release/*/*/publish
157+
./Intersect.Editor/bin/Release/*/*/publish
158+
./Intersect.Server/bin/Release/*/*/publish
95159
96-
- name: Checkout target main_full branch
160+
build-windows:
161+
name: Build for Windows
162+
runs-on: windows-latest
163+
steps:
164+
- name: Checkout Code
97165
uses: actions/checkout@v4
98166
with:
99-
fetch-depth: 0
100-
path: assets_full
101-
repository: AscensionGameDev/Intersect-Assets
102-
ref: main_full
103-
token: ${{ secrets.INTERSECTBOT_ACCESS_TOKEN }}
104-
105-
- name: Package artifacts
106-
uses: AscensionGameDev/actions@cc2eb0e356546042e4dc7eca6788fd0b5a063b32
167+
submodules: recursive
168+
169+
- name: Cache binaries
170+
uses: actions/cache@v3
171+
id: cache-binaries
107172
with:
108-
bundle: .github/bundles/*.json
109-
version: ${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}+build.${{ github.sha }}
173+
key: ${{ runner.os }}-binaries-${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}-${{ hashFiles('Intersect*/**/*.cs*') }}
174+
path: |
175+
Intersect*/bin/Release/**/*
110176
111-
- name: Publish GitHub Release
112-
if: inputs.workflowDebug != true
113-
uses: ncipollo/[email protected]
177+
- name: Setup dotnet
178+
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
179+
uses: actions/setup-dotnet@v3
114180
with:
115-
artifacts: "dist/**/*.zip"
116-
commit: ${{ github.sha }}
117-
generateReleaseNotes: true
118-
name: ${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}
119-
prerelease: true
120-
tag: v${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}
121-
122-
- name: Upload artifacts for workflow debugging
123-
if: inputs.workflowDebug == true || failure()
181+
dotnet-version: 7.0.x
182+
183+
- name: Cache NuGet dependencies
184+
uses: actions/cache@v3
185+
id: cache-nuget
186+
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
187+
with:
188+
key: ${{ runner.os }}-nuget-${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}-${{ hashFiles('Intersect*/*.csproj') }}
189+
path: |
190+
~/.nuget/packages
191+
Intersect*/obj/
192+
193+
- name: Apply environment patches
194+
run: echo "No patches to apply for Windows"
195+
196+
- name: Restore NuGet Packages
197+
if: steps.cache-binaries.outputs.cache-hit != 'true' && steps.cache-nuget.outputs.cache-hit != 'true' || inputs.forceRestore == true
198+
run: dotnet restore Intersect.sln
199+
200+
- name: Build solution
201+
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
202+
run: dotnet publish Intersect.sln --sc -r win-x64 -p:Configuration=Release -p:PackageVersion=${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}+build.${{ github.sha }} -p:Version=${{ env.VERSION_PREFIX }}.${{ github.run_number }}
203+
204+
- name: Debug files on disk
205+
if: inputs.workflowDebug == true
206+
run: ls -R .
207+
208+
- name: Upload artifacts
124209
uses: actions/upload-artifact@v3
125210
with:
126211
if-no-files-found: error
127-
name: workflow-debug
128-
path: "dist/**/*.zip"
212+
name: engine
213+
path: |
214+
./Intersect.Client/bin/Release/*/*/publish
215+
./Intersect.Editor/bin/Release/*/*/publish
216+
./Intersect.Server/bin/Release/*/*/publish
129217
130-
publish:
218+
debug-build-artifacts:
219+
name: Debug Build Artifacts
220+
if: inputs.workflowDebug == true
221+
needs: [build-linux, build-macos, build-windows]
222+
runs-on: ubuntu-latest
223+
steps:
224+
- name: Download Artifacts
225+
uses: actions/download-artifact@v3
226+
with:
227+
name: engine
228+
path: .
229+
230+
- name: Debug output
231+
run: ls -R .
232+
233+
publish-github:
234+
name: Publish GitHub Release
131235
if: inputs.workflowDebug != true
132-
needs: build
236+
needs: [build-linux, build-macos, build-windows]
237+
runs-on: ubuntu-latest
238+
steps:
239+
- name: Checkout Code
240+
uses: actions/checkout@v4
241+
242+
- name: Download Artifacts
243+
uses: actions/download-artifact@v3
244+
with:
245+
name: engine
246+
path: .
247+
248+
- name: Checkout assets main_upgrade branch
249+
uses: actions/checkout@v4
250+
with:
251+
fetch-depth: 0
252+
path: assets_upgrade
253+
repository: AscensionGameDev/Intersect-Assets
254+
ref: main_upgrade
255+
token: ${{ secrets.INTERSECTBOT_ACCESS_TOKEN }}
256+
257+
- name: Checkout target main_full branch
258+
uses: actions/checkout@v4
259+
with:
260+
fetch-depth: 0
261+
path: assets_full
262+
repository: AscensionGameDev/Intersect-Assets
263+
ref: main_full
264+
token: ${{ secrets.INTERSECTBOT_ACCESS_TOKEN }}
265+
266+
- name: Package artifacts
267+
uses: AscensionGameDev/actions@cc2eb0e356546042e4dc7eca6788fd0b5a063b32
268+
with:
269+
bundle: .github/bundles/*.json
270+
version: ${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}+build.${{ github.sha }}
271+
272+
- name: Debug packaging output
273+
if: inputs.packagingDebug == true
274+
run: ls -R ./dist
275+
276+
- name: Publish GitHub Release
277+
if: inputs.packagingDebug != true
278+
uses: ncipollo/[email protected]
279+
with:
280+
artifacts: "dist/**/*.zip"
281+
commit: ${{ github.sha }}
282+
generateReleaseNotes: true
283+
name: ${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}
284+
prerelease: true
285+
tag: v${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}
286+
287+
publish-forum:
288+
name: Publish to Forum
289+
if: inputs.workflowDebug != true && inputs.packagingDebug != true && inputs.skipForumPublish != true
290+
needs: publish-github
133291
runs-on: ubuntu-latest
134292
steps:
135293
- name: Publish to Forum

Intersect.Client/Intersect.Client.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
</PropertyGroup>
77

88
<PropertyGroup Condition="$(Configuration) != 'Debug'">
9+
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
910
<PublishSingleFile>true</PublishSingleFile>
1011
<SelfContained>true</SelfContained>
1112
</PropertyGroup>

Intersect.Editor/Intersect.Editor.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
5+
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
56
<EnableWindowsTargeting>true</EnableWindowsTargeting>
67
<OutputType>WinExe</OutputType>
78
<PublishSingleFile>true</PublishSingleFile>

Intersect.Server/Intersect.Server.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
</PropertyGroup>
77

88
<PropertyGroup Condition="$(Configuration) != 'Debug'">
9+
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
910
<PublishSingleFile>true</PublishSingleFile>
1011
<SelfContained>true</SelfContained>
1112
</PropertyGroup>

0 commit comments

Comments
 (0)