-
-
Notifications
You must be signed in to change notification settings - Fork 115
277 lines (249 loc) · 9.42 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
on:
push:
tags:
- '*'
#branches:
#- '*'
pull_request:
branches:
- '*'
# repository_dispatch is a newer github-actions feature that will allow building from triggers other than code merge/PR
repository_dispatch:
types: [build]
name: Build EmuFlight
jobs:
build:
continue-on-error: false
timeout-minutes: 75
strategy:
max-parallel: 4
matrix:
targets: [targets-group-1, targets-group-2, targets-group-3, targets-group-rest]
outputs:
buildtag: ${{ steps.ids.outputs.buildtag }}
shortsha: ${{ steps.ids.outputs.shortsha }}
artifact: ${{ steps.ids.outputs.artifact }}
version: ${{ steps.ids.outputs.version }}
runs-on: ubuntu-latest
steps:
# curl, by default, may timeout easily
- name: curl fix
run: function curl () { command curl --connect-timeout 30 --retry 10 "$@" ; }
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache build toolchain
uses: actions/cache@v3
id: cache-toolchain
with:
path: tools
key: ${{ runner.os }}-${{ hashFiles('make/tools.mk') }}
- name: Download and install toolchain
if: steps.cache-toolchain.outputs.cache-hit != 'true'
run: make arm_sdk_install
- name: Take the trash out
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
docker rmi -f $(docker image ls -aq)
sync
df -h
continue-on-error: true
- name: Setup Python
uses: actions/setup-python@v2
# EmuFlight version
- name: Get code version
id: get_version
run: echo "VERSION=$(make version)" >> $GITHUB_ENV
# for Makefile interaction
- name: Get GitHub Build Number (ENV)
id: get_buildno
run: echo "GITHUBBUILDNUMBER=${{ github.run_number }}" >> $GITHUB_ENV
continue-on-error: true
- name: Get pull request number
id: get_pullno
run: echo "PULL_NUMBER=$(echo "$GITHUB_REF" | awk -F / '{print $3}')" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/pull/')
- name: Get revision tag
if: startsWith(github.ref, 'refs/tags/')
id: get_revtag
run: echo "REVISION_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: get short-sha
run: |
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
continue-on-error: true
- name: Make artifact name
id: make_artifactname
run: |
if [[ "${{ github.REPOSITORY }}" == "emuflight/EmuFlight" ]] ; then
ARTIFACT_NAME="EmuFlight-${{ env.VERSION }}-${{ github.run_number }}"
else
ARTIFACT_NAME="EmuFlight-${{ env.VERSION }}-${{ github.ACTOR }}-${{ github.run_number }}"
fi
echo "${ARTIFACT_NAME}"
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
- id: ids
name : set outputs
run: |
echo "::set-output name=buildtag::${{ env.REVISION_TAG }}"
echo "::set-output name=shortsha::${{ env.SHORT_SHA }}"
echo "::set-output name=artifact::${{ env.ARTIFACT_NAME }}"
echo "::set-output name=version::${{ env.VERSION }}"
continue-on-error: true
# for debugging
- name: Show Variables
id: show_vars
run: |
echo "Actor: ${{ github.ACTOR }}"
echo "Repo: ${{ github.REPOSITORY }}"
echo "Build: ${{ github.run_number }}"
echo "Firmware: ${{ env.VERSION }}"
echo "Commit: ${{ github.sha }}"
echo "ShortSHA: ${{ env.SHORT_SHA }}"
echo "Tag: ${{ env.REVISION_TAG}}"
echo "Artifact name: ${{ env.ARTIFACT_NAME }}"
echo "outputs.buildtag: ${{ steps.ids.outputs.buildtag }}"
echo "outputs.shortsha: ${{ steps.ids.outputs.shortsha }}"
echo "outputs.artifact: ${{ steps.ids.outputs.artifact }}"
echo "outputs.version: ${{ steps.ids.outputs.version }}"
continue-on-error: true
# Build HEX
- name: Compile Code
run: |
make ${{ matrix.targets }}
# Upload the Builds to ZIP file with existing SHA in .hex names
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}-${{ matrix.runs-on }}
path: obj/*.hex
releases:
if: startsWith(github.ref, 'refs/tags/')
needs: build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
timeout-minutes: 10
runs-on: ubuntu-latest
continue-on-error: false
steps:
# for debugging
- name: show variables
run: |
echo "Build: ${{ github.RUN_NUMBER }}"
echo "Commit: ${{ github.SHA }}"
echo "Ref: ${{ GITHUB.REF }}"
echo "Actor: ${{ github.ACTOR }}"
echo "Repo: ${{ github.REPOSITORY }}"
echo "outputs.buildtag: ${{ needs.build.outputs.buildtag }}"
echo "outputs.shortsha: ${{ needs.build.outputs.shortsha }}"
echo "outputs.artifact: ${{ needs.build.outputs.artifact }}"
echo "outputs.version: ${{ needs.build.outputs.version }}"
echo "NOW=$(date +'%Y%m%d.%H%M%S')" >> $GITHUB_ENV
continue-on-error: true
- name: download artifacts
uses: actions/download-artifact@v4
with:
name: ${{ needs.build.outputs.artifact }} #no name parameter will download all artifacts, but create separate subfolders
path: obj
pattern: ${{ needs.build.outputs.artifact }}-*
merge-multiple: true
continue-on-error: false
- name: list/find extractions
run: |
find ./ -name "*.hex"
# Draft Dev-Unstable releases via ncipollo/release-action
# softprops/action-gh-release fails to release on separate repo
- name: Draft Release Dev-Unstable repo
if: contains(github.ref, 'test') || contains(github.ref, 'unstab')
uses: ncipollo/release-action@v1
with:
repo: dev-unstable
owner: emuflight
token: ${{ secrets.NC_PAT_EMUF }}
tag: "${{ env.NOW }}-hex"
draft: true
prerelease: true
allowUpdates: true
artifacts: obj/*.hex
artifactContentType: raw
name: "DEV-UNSTABLE HEX / Build ${{ github.run_number }}"
body: |
## HEX BUILD for TESTING
### Build ${{ github.run_number }}
### Commit SHA: ${{ needs.build.outputs.shortsha }} (${{ github.sha }})
### BuildTag: ${{ needs.build.outputs.buildtag }}
### EmuFlight ${{ needs.build.outputs.version }} base plus test code
### What to Test/Feedback: (Feedback in EmuFlight's Discord or GitHub Discussions)
<details><summary>Changes in this Build:</summary>
<!-- require single blank line below -->
```
[insert commit history here]
```
</details>
continue-on-error: true
# Draft Dev-master releases via ncipollo/release-action
# softprops/action-gh-release fails to release on separate repo
- name: Draft Release Dev-Master repo
if: contains(github.ref, 'master')
uses: ncipollo/release-action@v1
with:
repo: dev-master
owner: emuflight
token: ${{ secrets.NC_PAT_EMUF }}
tag: "${{ env.NOW }}-hex"
draft: true
prerelease: true
allowUpdates: true
artifacts: obj/*.hex
artifactContentType: raw
name: "DEV-MASTER HEX / Build ${{ github.run_number }}"
body: |
## HEX BUILD of MASTER
### Build ${{ github.run_number }}
### Commit SHA: ${{ needs.build.outputs.shortsha }} (${{ github.sha }})
### BuildTag: ${{ needs.build.outputs.buildtag }}
### EmuFlight ${{ needs.build.outputs.version }} base plus committed code
### Feedback Welcome in EmuFlight's Discord or GitHub Discussions.
<details><summary>Changes in this Build:</summary>
<!-- require single blank line below -->
```
[insert commit history here]
```
</details>
continue-on-error: true
# Rename .hex for true Releases on main repo
- name: Rename Artifacts
if: startsWith(github.ref, 'refs/tags/')
run: |
sudo apt -y install rename
cd obj
rename 's/_Build_.*/.hex/' *.hex
#Draft Releases on main Repo
# could potentially change to ncipollo/release-action as well
- name: Draft Release Main Repo
if: contains(github.ref, 'releas')
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
draft: true
prerelease: true
allowUpdates: true
# tag: use the build Number, but we MUST manually change to version so that it creates a version-tag on release
tag: ${{ env.VERSION }}
artifacts: obj/*.hex
artifactContentType: raw
name: DRAFT / EmuFlight ${{ env.VERSION }} / GitHub Build ${{ github.run_number }}
body: |
## EmuFlight ${{ env.VERSION }}
### Build ${{ github.run_number }}
### Commit SHA: ${{ needs.build.outputs.shortsha }} (${{ github.sha }})
### BuildTag: ${{ needs.build.outputs.buildtag }}
<details><summary>Changes in this Build:</summary>
<!-- require single blank line below -->
```
[insert commit history here]
```
</details>
continue-on-error: false