-
Notifications
You must be signed in to change notification settings - Fork 35
141 lines (126 loc) · 5.07 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
name: Build on push
# TODO: Add mingw to matrix
# Controls when the action will run. Triggers the workflow on push or pull request
# events, but only for the master branch we'll create .zip files
on: [push, pull_request]
jobs:
build:
name: Building for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-20.04
platform: linux
- os: windows-latest
platform: windows
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install dependencies (Ubuntu)
run: |
sudo apt-get update -qq
sudo apt-get install -qqq build-essential pkg-config
if: matrix.platform == 'linux'
- name: Set up Python (for SCons)
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install scons
run: |
python -m pip install scons~=4.0
- name: Run the build for godot-cpp
run: |
scons -C godot-cpp platform=${{ matrix.platform }} -j2 target=template_release generate_bindings=yes bits=64
- name: Run the build for godot_openvr
run: |
scons platform=${{ matrix.platform }} -j2 target=release bits=64
# There's no option to preserve the path structure on the upload action, so we just
# treat each asset as its respective bin/ subfolder and put it in the right place in
# the next job. The names are important, they become the platform names.
# https://github.com/actions/upload-artifact/issues/174
- name: Upload Windows build results
uses: actions/upload-artifact@v4
with:
name: x11
path: demo/addons/godot-openvr/bin/x11/
if: matrix.platform == 'linux'
- name: Upload Linux build results
uses: actions/upload-artifact@v4
with:
name: win64
path: demo/addons/godot-openvr/bin/win64/
if: matrix.platform == 'windows'
# This job collects the build output and assembles the final asset (artifact)
asset:
name: Assemble release bundle
runs-on: ubuntu-20.04
needs: build
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags'))
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v4
with:
# Giving an explicit path prevents an automatic cd into the checkout.
path: godot_openvr
- name: Create destination and populate addon resources
run: |
mkdir -p godot_openvr_plugin/addons
cp -r godot_openvr/demo/addons/godot-openvr godot_openvr_plugin/addons/
- name: Download per-platform binaries into addon
uses: actions/download-artifact@v4
with:
path: godot_openvr_plugin/addons/godot-openvr/bin/
- name: Calculate GIT short ref
run: |
cd godot_openvr
echo "GITHUB_SHA_SHORT=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
if: github.ref == 'refs/heads/master'
- name: Get tag name
run: |
cd godot_openvr
echo "GITHUB_SHA_SHORT=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags')
- name: Clean up extracted files
run: |
rm -rf godot_openvr
mv godot_openvr_plugin godot_openvr_${{ env.GITHUB_SHA_SHORT }}
- name: Zip asset
run: |
zip -qq -r godot-openvr.zip .
- name: Create and upload asset
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "godot-openvr.zip"
body: "A new release!"
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
if: startsWith(github.ref, 'refs/tags')
# TODO: Both create-release and upload-release-asset are abandonded, need to port to maintained replacements. Both suggest replacements in their README.
- name: Create release for asset
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
if: github.ref == 'refs/heads/master'
- name: Upload asset
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-openvr.zip
asset_name: godot-openvr.zip
asset_content_type: application/zip
if: github.ref == 'refs/heads/master'