-
Notifications
You must be signed in to change notification settings - Fork 9
244 lines (219 loc) · 8.78 KB
/
build-firmware-and-emulator.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
name: Build Firmware and Emulator
run-name: ${{ github.actor }} is building both firmware and emulator
on:
push:
branches:
- main
- midi-synth-platform-midi
pull_request:
branches:
- main
env:
FIRMWARE_ARTIFACT: swadge2024-firmware
EMULATOR_ARTIFACT: swadge2024-emulator
jobs:
Build-Firmware-And-Emulator:
strategy:
matrix:
os: [ windows, osx-arm, osx-intel, linux ]
include:
- os: windows
runner: windows-latest
family: windows
emulator: true
firmware: true
emu_artifacts:
- swadge_emulator.exe
- version.txt
# TODO: What variable can we use to not hardcode this???
idf_install: C:\Users\runneradmin\.espressif
- os: osx-arm
runner: macos-latest
family: osx
emulator: true
firmware: false
emu_artifacts:
- SwadgeEmulator.app
- version.txt
idf_install: ~/.espressif
- os: osx-intel
runner: macos-13
family: osx
emulator: true
firmware: false
emu_artifacts:
- SwadgeEmulator.app
- version.txt
idf_install: ~/.espressif
- os: linux
runner: ubuntu-latest
family: linux
emulator: true
firmware: false
emu_artifacts:
- swadge_emulator
- version.txt
idf_install: ~/.espressif
runs-on: ${{ matrix.runner }}
steps:
# - name: Debug print event
# run: echo '${{ toJSON(github.event) }}'
#### Basic Steps
- name: Check out repository code
uses: actions/[email protected]
with:
submodules: recursive
- name: Create a version file
run: |
printf "Commit: https://github.com/AEFeinstein/Super-2024-Swadge-FW/commit/$(git rev-parse HEAD) \nBuilt on ${{ matrix.os }} at: $(date)" >> version.txt
#### Platform-specific Dependencies
- name: Install homebrew packages
if: matrix.family == 'osx'
run: |
# Not installing graphviz here because we don't actually build the docs and brew has trouble with its dependnencies
brew install xquartz libxinerama clang-format cppcheck wget doxygen cmake dylibbundler
- name: Install apt packages
if: matrix.family == 'linux'
run: |
sudo apt install build-essential xorg-dev libx11-dev libxinerama-dev libxext-dev mesa-common-dev libglu1-mesa-dev libasound2-dev libpulse-dev git libasan8 cppcheck python3 python3-pip python3-venv cmake libusb-1.0-0-dev lcov gdb graphviz
## Firmware
- name: Restore IDF Cache
id: cache-esp-idf
if: matrix.firmware
uses: actions/cache@v3
with:
path: |
${{ matrix.idf_install }}
${{ runner.temp }}/esp-idf
key: esp-idf-cache-${{ matrix.os }}
- name: Set up the IDF
if: steps.cache-esp-idf.outputs.cache-hit != 'true' && matrix.firmware && matrix.family == 'windows'
run: |
git clone -b v5.3.1 --recurse-submodules https://github.com/espressif/esp-idf.git ${{ runner.temp }}/esp-idf -j2
${{ runner.temp }}/esp-idf/install.ps1
- name: Set up the IDF
if: steps.cache-esp-idf.outputs.cache-hit != 'true' && matrix.firmware && matrix.family != 'windows'
run: |
git clone -b v5.3.1 --recurse-submodules https://github.com/espressif/esp-idf.git ${{ runner.temp }}/esp-idf -j2
${{ runner.temp }}/esp-idf/install.sh
- name: Compile the firmware
if: matrix.firmware && matrix.family == 'windows'
run: |
$env:path = $env:path.Insert($env:path.ToLower().IndexOf("c:\windows\system32"), "C:\msys64\mingw64\bin;C:\msys64\usr\bin;")
${{ runner.temp }}/esp-idf/export.ps1
idf.py build dfu
- name: Compile the firmware
if: matrix.firmware && matrix.family != 'windows'
run: |
${{ runner.temp }}/esp-idf/export.sh
idf.py build dfu
- name: Add firmware, bootloader, partition table, version, and flasher files to firmware artifact
if: matrix.firmware
uses: actions/[email protected]
with:
name: ${{ env.FIRMWARE_ARTIFACT }}
path: |
build/swadge2024.elf
build/swadge2024.bin
build/storage.bin
build/dfu.bin
build/bootloader/bootloader.bin
build/partition_table/partition-table.bin
version.txt
tools/pyFlashGui/pyFlashGui.py
#### Platform-specific Emulator Builds
- name: Install msys64 packages
id: install-msys64
if: matrix.emulator && matrix.family == 'windows'
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
location: C:\msys64
install: >-
base-devel
gcc
gdb
zip
mingw-w64-x86_64-graphviz
mingw-w64-x86_64-cppcheck
doxygen
- name: Compile the Emulator
if: matrix.emulator && matrix.family == 'windows'
run: |
$env:path = $env:path.Insert($env:path.ToLower().IndexOf("c:\windows\system32"), "C:\msys64\mingw64\bin;C:\msys64\usr\bin;")
make -j2
- name: Compile the Emulator
if: matrix.emulator && matrix.family != 'windows'
run: |
make -j3
- name: Build OSX Bundle
if: matrix.emulator && matrix.family == 'osx'
run: |
make SwadgeEmulator.app
- name: Create Emulator zip
if: matrix.emulator && matrix.family != 'windows'
run: |
zip -r SwadgeEmulator.zip ${{ join(matrix.emu_artifacts, ' ') }}
- name: Create Emulator zip with 7zip
if: matrix.emulator && matrix.family == 'windows'
run: |
7z a -tzip SwadgeEmulator.zip ${{ join(matrix.emu_artifacts, ' ') }} -r
#### Generic Emulator Upload
- name: Upload Emulator Binary
if: matrix.emulator
uses: actions/[email protected]
with:
name: ${{ env.EMULATOR_ARTIFACT }}-${{ matrix.os }}
path: SwadgeEmulator.zip
Create-Snapshot-Release:
runs-on: ubuntu-latest
needs: Build-Firmware-And-Emulator
permissions:
contents: write
steps:
- name: Download all previous build artifacts
if: (github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true) || (github.event_name == 'push' && github.ref_name == 'main')
uses: actions/download-artifact@v4
with:
merge-multiple: false
- name: Rename artifacts
if: (github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true) || (github.event_name == 'push' && github.ref_name == 'main')
run: |
for os in osx-arm osx-intel linux windows ; do
mv ${{ env.EMULATOR_ARTIFACT }}-${os}/SwadgeEmulator.zip SwadgeEmulator-${os}.zip
done
mkdir firmware-zip
find ${{ env.FIRMWARE_ARTIFACT }}/ -type f -exec mv {} firmware-zip/ \;
cd firmware-zip
zip ../${{ env.FIRMWARE_ARTIFACT }}.zip *
- name: Create release for latest artifacts
if: (github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true) || (github.event_name == 'push' && github.ref_name == 'main')
uses: ncipollo/release-action@v1
with:
# Allow the release to be updated, since it's not a "final" release
prerelease: true
allowUpdates: true
replacesArtifacts: true
artifacts: "${{ env.FIRMWARE_ARTIFACT }}.zip,SwadgeEmulator-*"
commit: main
tag: snapshot
name: Snapshot
body: |
# Latest Development Snapshot
Post-Slack-Message:
runs-on: windows-latest
needs: Build-Firmware-And-Emulator
steps:
- name: Post to a Slack channel
if: (github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true) || (github.event_name == 'push' && github.ref_name == 'main')
id: slack
uses: slackapi/[email protected]
with:
# Slack channel id, channel name, or user id to post message.
# See also: https://api.slack.com/methods/chat.postMessage#channels
# You can pass in multiple channels to post to by providing a comma-delimited list of channel IDs.
channel-id: 'C6FNXU6KX'
# For posting a simple plain text message
slack-message: "*Build Result*: ${{ job.status }}\n*Author*: ${{ github.event.head_commit.author.username }}\n*Head Commit Message*:\n```\n${{ github.event.head_commit.message }}\n```\n*Comparison*: ${{ github.event.compare }}\n*Artifacts*: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}