Skip to content

AEFeinstein is building both firmware and emulator #796

AEFeinstein is building both firmware and emulator

AEFeinstein is building both firmware and emulator #796

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
- install.sh
- icon.png
- SwadgeEmulator.desktop
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 Linux FreeDesktop files
if: matrix.emulator && matrix.family == 'linux'
run: |
cp emulator/resources/install.sh .
cp emulator/resources/icon.png .
cp emulator/resources/SwadgeEmulator.desktop .
- 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 }}