-
Notifications
You must be signed in to change notification settings - Fork 11
155 lines (131 loc) · 5.15 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
# Workflow to automatically build and release an Android Plugin with GDExtension capabilities
name: Build ARCore Plugin
on: [push, pull_request]
jobs:
build:
name: Building for Android (Ubuntu 20.04)
runs-on: ubuntu-20.04
# Note, to satisfy the asset library we need to make sure our zip files have a root folder
# this is why we checkout into repo and build into asset
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
path: repo
submodules: "recursive"
#- name: Setup Godot build cache
# uses: ./repo/godot-cpp/.github/actions/godot-cache-restore # TODO: CREATE THIS
# with:
# cache-name: godot-cpp-cache
# continue-on-error: true
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 17
distribution: "adopt"
- name: Setup Android NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r23c
link-to-sdk: true
- name: Install SCons
run: |
python -m pip install scons==4.0.0
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: tree
run: tree -L 2 && ls -alh $GITHUB_WORKSPACE/repo/plugin/
- name: Create libgodot-cpp Android templates
run: |
cd $GITHUB_WORKSPACE/repo/godot-cpp
scons platform=android target=template_debug arch=arm64
scons platform=android target=template_release arch=arm64
cd $GITHUB_WORKSPACE
- name: Assemble the plugin
run: |
cd $GITHUB_WORKSPACE/repo
./gradlew assemble
- name: List files for debugging
run: ls -alh $GITHUB_WORKSPACE/repo/plugin/build/outputs/aar
- name: Upload build files
uses: actions/upload-artifact@v4
with:
name: arcore-build
path: $GITHUB_WORKSPACE/repo/plugin/build/outputs/aar/ARCorePlugin*.aar
# This job collects the build output and assembles the final asset (artifact)
release:
if: github.event.name == 'push' && (github.ref == 'refs/head/master' || startsWith(github.ref, 'refs/tags'))
name: Assembling the asset
runs-on: ubuntu-20.04
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
repository: "GodotVR/godot_arcore"
path: godot_arcore
- name: Download all workflow run artifacts
uses: actions/download-artifact@v2
#- name: Copy files to destination
# run: |
# mkdir godot_arcore_plugin
# mkdir godot_arcore_plugin/addons
# mkdir godot_arcore_plugin/android
# mkdir godot_arcore_plugin/android/plugins
# cp -r godot_arcore/demo/addons/ARCorePlugin godot_arcore_plugin/addons
# cp arcore-build/*.aar godot_arcore_plugin/android/plugins/
- name: Calculate GIT short ref
if: github.ref == 'refs/heads/master'
run: |
cd $GITHUB_WORKSPACE/repo/godot_arcore
echo "GITHUB_SHA_SHORT=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
cd $GITHUB_WORKSPACE
- name: Get tag name
if: startsWith(github.ref, 'refs/tags')
run: |
echo "GITHUB_SHA_SHORT=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
- name: Clean up extracted files # TODO: Check what to clean here
run: |
rm -rf arcore-build
rm -rf godot_arcore
rm -rf .git
mv godot_arcore_plugin godot_arcore_${{ env.GITHUB_SHA_SHORT }}
- name: Zip asset
run: |
zip -qq -r godot_arcore.zip .
- name: Create and upload asset
if: startsWith(github.ref, 'refs/tags')
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "godot_arcore.zip"
body: "Godot ARCore has a new release!"
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create release for asset
if: github.ref == 'refs/heads/master'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.GITHUB_SHA_SHORT }}
release_name: Automatic build for changeset ${{ env.GITHUB_SHA_SHORT }}
body: "This is an automated build for changeset ${{ env.GITHUB_SHA_SHORT }}"
draft: false
prerelease: true
- name: Upload asset
if: github.ref == 'refs/heads/master'
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./godot_arcore.zip
asset_name: godot_arcore.zip
asset_content_type: application/zip