-
Notifications
You must be signed in to change notification settings - Fork 7
231 lines (212 loc) · 9.82 KB
/
build-on-push.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# Workflow to automatically compile a Linux/Windows library on commit/push
name: Build on push
# Controls when the action will run. Triggers the workflow on push or pull request
# events, but only for the main branch we'll create .zip files
on:
[push, pull_request]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This job builds the plugin for our target platforms
build:
name: Building for ${{ matrix.platform }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
# Unsupported platforms are commented out.
- name: 🐧 Linux (GCC)
os: ubuntu-20.04
platform: linux
artifact-name: gdtiltfive.linux
artifact-path: |
build/bin/linux/x86_64/libgdtiltfive.linux.template_debug.x86_64.so
build/bin/linux/x86_64/libgdtiltfive.linux.template_release.x86_64.so
extension/TiltFiveNDK/lib/linux/x86_64/libTiltFiveNative.so
- name: 🏁 Windows (x86_64, MSVC)
os: windows-2019
platform: windows
artifact-name: gdtiltfive.windows
artifact-path: |
build/bin/windows/x86_64/libgdtiltfive.windows.template_debug.x86_64.dll
build/bin/windows/x86_64/libgdtiltfive.windows.template_release.x86_64.dll
extension/TiltFiveNDK/lib/win/x86_64/TiltFiveNative.dll
#- name: 🍎 macOS (universal)
# os: macos-11
# platform: macos
# flags: arch=universal
# artifact-name: gdtiltfive.macos
# artifact-path: build/bin/libgdtiltfive.macos.*
- name: 🤖 Android (arm64)
os: ubuntu-20.04
platform: android
#flags: ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME arch=arm64
artifact-name: gdtiltfive.android
artifact-path: |
build/bin/android/arm64/libgdtiltfive.android.*
androidplugin/plugin/build/outputs/aar/gdtiltfive*
#- name: 🍏 iOS (arm64)
# os: macos-11
# platform: ios
# flags: arch=arm64
# artifact-name: gdtiltfive.ios
# artifact-path: build/bin/libgdtiltfive.ios.*
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Setup actions
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Set up Python (for SCons)
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Linux dependencies
if: ${{ matrix.platform == 'linux' }}
run: |
sudo apt-get update -qq
sudo apt-get install -qqq build-essential pkg-config
- name: Set up GCC
if: ${{ matrix.platform == 'linux' }}
uses: egor-tensin/setup-gcc@v1
with:
version: 11
platform: x64
- name: Android dependencies
if: ${{ matrix.platform == 'android' }}
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26c
add-to-path: false
- name: Install scons
run: |
python -m pip install scons==4.0.0
- name: Build debug build
run: |
scons platform=${{ matrix.platform }} target=template_debug ${{ matrix.flags }} --no-gradle
env:
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Build release build
run: |
scons platform=${{ matrix.platform }} target=template_release ${{ matrix.flags }} --no-gradle
env:
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Set up Java
if: ${{ matrix.platform == 'android' }}
uses: actions/setup-java@v4
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'
- name: Gradle build
if: ${{ matrix.platform == 'android' }}
run: |
mkdir plugin/libs
cp ../extension/TiltFiveNDK/lib/android/TiltFiveAndroidClient.jar plugin/libs/TiltFiveAndroidClient.jar
chmod +x ./gradlew
./gradlew build
working-directory: ./androidplugin
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.artifact-path }}
if-no-files-found: error
# This job collects the build output and assembles the final asset (artifact)
asset:
name: Assembling the asset (artifact)
runs-on: ubuntu-20.04
needs: build
permissions:
contents: write
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Setup actions
uses: actions/checkout@v3
with:
path: source
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
- name: Copy files to destination for gdscript
run: |
mkdir plugin
mkdir plugin/addons
cp -r source/example.gd/addons/tiltfive plugin/addons
cp source/LICENSE.txt plugin/addons/tiltfive
cp source/CONTRIBUTORS.md plugin/addons/tiltfive
cp source/CHANGES.md plugin/addons/tiltfive
mkdir plugin/addons/tiltfive/bin
mkdir plugin/addons/tiltfive/bin/linux
mkdir plugin/addons/tiltfive/bin/linux/x86_64
mkdir plugin/addons/tiltfive/bin/windows
mkdir plugin/addons/tiltfive/bin/windows/x86_64
mkdir plugin/addons/tiltfive/bin/android/
mkdir plugin/addons/tiltfive/bin/android/arm64
cp gdtiltfive.linux/build/bin/linux/x86_64/*.so plugin/addons/tiltfive/bin/linux/x86_64/
cp gdtiltfive.linux/extension/TiltFiveNDK/lib/linux/x86_64/*.so plugin/addons/tiltfive/bin/linux/x86_64/
cp gdtiltfive.windows/build/bin/windows/x86_64/*.dll plugin/addons/tiltfive/bin/windows/x86_64/
cp gdtiltfive.windows/extension/TiltFiveNDK/lib/win/x86_64/*.dll plugin/addons/tiltfive/bin/windows/x86_64/
cp gdtiltfive.android/build/bin/android/arm64/*.so plugin/addons/tiltfive/bin/android/arm64/
cp source/extension/TiltFiveNDK/lib/android/arm64-v8a/*.so plugin/addons/tiltfive/bin/android/arm64/
cp gdtiltfive.android/androidplugin/plugin/build/outputs/aar/gdtiltfive-debug.aar plugin/addons/tiltfive/bin/android
cp gdtiltfive.android/androidplugin/plugin/build/outputs/aar/gdtiltfive-release.aar plugin/addons/tiltfive/bin/android
- name: Copy files to destination for csharp
run: |
mkdir plugin_cs
mkdir plugin_cs/addons
cp -r source/example.csharp/addons/tiltfive plugin_cs/addons
cp source/LICENSE.txt plugin_cs/addons/tiltfive
cp source/CONTRIBUTORS.md plugin_cs/addons/tiltfive
cp source/CHANGES.md plugin_cs/addons/tiltfive
mkdir plugin_cs/addons/tiltfive/bin
mkdir plugin_cs/addons/tiltfive/bin/linux
mkdir plugin_cs/addons/tiltfive/bin/linux/x86_64
mkdir plugin_cs/addons/tiltfive/bin/windows
mkdir plugin_cs/addons/tiltfive/bin/windows/x86_64
mkdir plugin_cs/addons/tiltfive/bin/android/
mkdir plugin_cs/addons/tiltfive/bin/android/arm64
cp gdtiltfive.linux/build/bin/linux/x86_64/*.so plugin_cs/addons/tiltfive/bin/linux/x86_64/
cp gdtiltfive.linux/extension/TiltFiveNDK/lib/linux/x86_64/*.so plugin_cs/addons/tiltfive/bin/linux/x86_64/
cp gdtiltfive.windows/build/bin/windows/x86_64/*.dll plugin_cs/addons/tiltfive/bin/windows/x86_64/
cp gdtiltfive.windows/extension/TiltFiveNDK/lib/win/x86_64/*.dll plugin_cs/addons/tiltfive/bin/windows/x86_64/
cp gdtiltfive.android/build/bin/android/arm64/*.so plugin_cs/addons/tiltfive/bin/android/arm64/
cp source/extension/TiltFiveNDK/lib/android/arm64-v8a/*.so plugin_cs/addons/tiltfive/bin/android/arm64/
cp gdtiltfive.android/androidplugin/plugin/build/outputs/aar/gdtiltfive-debug.aar plugin_cs/addons/tiltfive/bin/android
cp gdtiltfive.android/androidplugin/plugin/build/outputs/aar/gdtiltfive-release.aar plugin_cs/addons/tiltfive/bin/android
- name: Calculate GIT short ref
run: |
cd source
echo "GITHUB_SHA_SHORT=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
cd ..
if: github.ref == 'refs/heads/main'
- name: Get tag name
run: |
echo "GITHUB_SHA_SHORT=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags')
- name: Clean up extracted files
run: |
# rm -rf gdtiltfive.linux
rm -rf gdtiltfive.windows
# rm -rf gdtiltfive.android
# rm -rf gdtiltfive.macos
# rm -rf gdtiltfive.ios
rm -rf source
rm -rf .git
mv plugin gdtiltfive_${{ env.GITHUB_SHA_SHORT }}
mv plugin_cs gdtiltfive_cs_${{ env.GITHUB_SHA_SHORT }}
- name: Zip asset
run: |
zip -qq -r gdtiltfive_gdscript.zip gdtiltfive_${{ env.GITHUB_SHA_SHORT }}
zip -qq -r gdtiltfive_csharp.zip gdtiltfive_cs_${{ env.GITHUB_SHA_SHORT }}
- name: Create and upload asset
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "gdtiltfive_gdscript.zip, gdtiltfive_csharp.zip"
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
omitPrereleaseDuringUpdate : true
token: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')