-
Notifications
You must be signed in to change notification settings - Fork 1
208 lines (196 loc) · 6.95 KB
/
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
name: Build Project
on:
workflow_call:
inputs:
release:
type: boolean
default: false
required: false
workflow_dispatch:
inputs:
release:
type: boolean
default: true
required: false
jobs:
rust-build:
strategy:
matrix:
platform: ['linux', 'windows', 'darwin']
arch: ['x86_64', 'aarch64']
include:
- platform: linux
os: ubuntu-22.04
vendor: unknown
env: -gnu
lib: libnative.so
- platform: windows
os: windows-2019
vendor: pc
env: '-msvc'
lib: native.dll
- platform: darwin
os: macos-14
vendor: apple
lib: libnative.dylib
exclude:
- platform: linux
arch: aarch64
runs-on: ${{ matrix.os }}
env:
TARGET_TRIPLET: ${{ matrix.arch }}-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}
CARGO_BUILD: cargo build --target
RUST_BACKTRACE: full
steps:
- name: checkout
uses: actions/checkout@v4
with:
lfs: true
- name: Set up clang64
if: contains(matrix.os, 'windows')
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
- uses: Swatinem/rust-cache@v2
with:
workspaces: ./native/
key: ${{ matrix.arch }}
- name: Add Build target
run: |
cd native/
rustup target add ${{ env.TARGET_TRIPLET }}
- name: Build Debug
if: ${{ !inputs.release }}
run: |
cd native/
${{ env.CARGO_BUILD}} ${{ env.TARGET_TRIPLET}}
- name: Build Release
if: inputs.release
run: |
cd native/
${{ env.CARGO_BUILD }} ${{ env.TARGET_TRIPLET}} --release
- name: Artifacts
uses: actions/upload-artifact@v4
with:
name: libnative-${{ matrix.platform }}-${{ matrix.arch }}
path: native/target/${{ env.TARGET_TRIPLET }}/${{ inputs.release && 'release' || 'debug' }}/${{ matrix.lib }}
godot-export:
strategy:
matrix:
profile: ['macOS', 'Windows', 'Linux']
version: ['4.2.2']
include:
- profile: 'macOS'
platform: darwin
vendor: apple
os: macos-14
x86_64: true
aarch64: true
extension: '.dmg'
lib: libnative.dylib
template_dir: '$HOME/Library/Application\ Support/Godot/export_templates'
- profile: 'Windows'
platform: windows
env: '-msvc'
vendor: pc
os: ubuntu-22.04
x86_64: true
aarch64: true
extension: '.exe'
lib: native.dll
template_dir: '$HOME/.local/share/godot/export_templates'
- profile: 'Linux'
platform: 'linux'
env: '-gnu'
vendor: 'unknown'
os: ubuntu-20.04
lib: libnative.so
template_dir: '$HOME/.local/share/godot/export_templates'
x86_64: true
needs: rust-build
runs-on: ${{ matrix.os }}
env:
EXPORT_DIR: build/${{ matrix.profile }}
EXPORT_ARGS: ${{ matrix.profile }} build/${{ matrix.profile }}/SimChopper${{ matrix.extension }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
lfs: true
- name: setup Godot
uses: lihop/setup-godot@v2
with:
version: ${{ matrix.version }}
export-templates: false
- name: download Godot export template
run: |
mkdir -p ${{ matrix.template_dir }}/${{ matrix.version }}.stable
cd ${{ matrix.template_dir }}/${{ matrix.version }}.stable
curl -LO https://github.com/godotengine/godot/releases/download/${{ matrix.version }}-stable/Godot_v${{ matrix.version }}-stable_export_templates.tpz
unzip -j Godot_v${{ matrix.version }}-stable_export_templates.tpz
- name: download host libs
if: ${{ matrix.platform != 'linux' && startsWith(matrix.os, 'ubuntu') }}
uses: actions/download-artifact@v4
with:
name: libnative-linux-x86_64
path: native/target/x86_64-unknown-linux-gnu/debug/
- name: download x86_64 libs
if: matrix.x86_64
uses: actions/download-artifact@v4
with:
name: libnative-${{ matrix.platform }}-x86_64
path: native/target/x86_64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/debug/
- name: download aarch64 libs
if: matrix.aarch64
uses: actions/download-artifact@v4
with:
name: libnative-${{ matrix.platform }}-aarch64
path: native/target/aarch64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/debug/
- name: create universal libnative
if: matrix.platform == 'darwin'
run: |
platform_dir="${{ matrix.vendor }}-${{ matrix.platform }}"
mkdir -p native/target/universal-$platform_dir/debug/
lipo -create native/target/x86_64-$platform_dir/debug/${{ matrix.lib }} native/target/aarch64-$platform_dir/debug/${{ matrix.lib }} -output native/target/universal-$platform_dir/debug/${{ matrix.lib }}
- name: copy libs
run: |
set -x
platform_dir="${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}"
x86_64="native/target/x86_64-$platform_dir"
aarch64="native/target/aarch64-$platform_dir"
universal="native/target/universal-$platform_dir"
if [[ -d "$x86_64/debug/" ]]; then
mkdir -p "$x86_64/release/"
cp $x86_64/debug/* "$x86_64/release/"
fi
if [[ -d "$aarch64/debug/" ]]; then
mkdir -p "$aarch64/release/"
cp $aarch64/debug/* "$aarch64/release/"
fi
if [[ -d "$universal/debug/" ]]; then
mkdir -p "$universal/release/"
cp $universal/debug/* "$universal/release/"
fi
- name: import godot project
run: |
# import assets
.github/build_godot_cache.sh
# restart to make sure all rust scripts are detected
.github/build_godot_cache.sh
- name: export-debug
if: ${{ !inputs.release }}
run: |
mkdir -p "${{ env.EXPORT_DIR }}"
godot --headless --export-debug ${{ env.EXPORT_ARGS }}
test $(ls -al "${{ env.EXPORT_DIR }}" | wc -l) -gt 1
- name: export-release
if: inputs.release
run: |
mkdir -p "${{ env.EXPORT_DIR }}"
godot --headless --export-release ${{ env.EXPORT_ARGS }}
test $(ls -al "${{ env.EXPORT_DIR }}" | wc -l) -gt 1
- name: describe revision
id: describe
run: echo "ref=$(git describe --tags --always)" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
with:
name: SimChopper_${{ matrix.profile }}_${{ steps.describe.outputs.ref }}
path: ${{ env.EXPORT_DIR }}