Skip to content

Update compile.yml #203

Update compile.yml

Update compile.yml #203

Workflow file for this run

name: Compile
on:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: Compile
cancel-in-progress: true
jobs:
clear-file-for-saving-info:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: delete file # so that the matrix has a blank file to log info into
run: |
git config --global user.name 'gbg-with-joysticks'
git config --global user.email '[email protected]'
git pull # get the most recent state of the repo
[ -d "./hex" ] && git rm -r ./hex # only delete the directory if it exists
git commit . -m "BOT delete old files" --allow-empty
git push
compile-sketch:
needs: clear-file-for-saving-info #run second
strategy:
max-parallel: 1 # since the actions edit files in the repo, only run one at a time.
matrix:
# list of programs to compile (can have multiple programs for multiple boards)
# for additional-commands use | to separate multiple commands, to install library, use arduino-cli lib install <Library>
# board-upload must match a board type as defined by https://github.com/dbuezas/arduino-web-uploader
include:
- configName: "standard-nanoOld"
code-dir: gbg_program
arduino-platform: "arduino:avr"
fqbn: "arduino:avr:nano"
board-upload: "nanoOldBootloader"
niceBoardName: "old nano"
additional-commands: arduino-cli lib install Servo
- configName: "standard-nanoNew"
code-dir: gbg_program
arduino-platform: "arduino:avr"
fqbn: "arduino:avr:nano"
board-upload: "nano"
niceBoardName: "new nano or uno"
additional-commands: arduino-cli lib install Servo
# - configName: "standard-rpiPico"
# code-dir: gbg_program
# arduino-platform: "rp2040:rp2040 --additional-urls https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json"
# fqbn: "rp2040:rp2040:rpipico"
# board-upload: "nano"
# niceBoardName: "rpi pico"
# additional-commands: arduino-cli lib install Servo
- configName: "clear_eeprom-nanoOld"
code-dir: clear_eeprom
arduino-platform: "arduino:avr"
fqbn: "arduino:avr:nano"
board-upload: "nanoOldBootloader"
niceBoardName: "old nano"
- configName: "clear_eeprom-nanoNew"
code-dir: clear_eeprom
arduino-platform: "arduino:avr"
fqbn: "arduino:avr:nano"
board-upload: "nano"
niceBoardName: "new nano or uno"
- configName: "clear_eeprom-rpiPico"
code-dir: clear_eeprom
arduino-platform: "rp2040:rp2040 --additional-urls https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json"
fqbn: "rp2040:rp2040:rpipico"
board-upload: "nano"
niceBoardName: "rpi pico"
- configName: "blink-nanoOld"
code-dir: blink
arduino-platform: "arduino:avr"
fqbn: "arduino:avr:nano"
board-upload: "nanoOldBootloader"
niceBoardName: "old nano"
- configName: "blink-nanoNew"
code-dir: blink
arduino-platform: "arduino:avr"
fqbn: "arduino:avr:nano"
board-upload: "nano"
niceBoardName: "new nano or uno"
- configName: "blink-rpiPico"
code-dir: blink
arduino-platform: "rp2040:rp2040 --additional-urls https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json"
fqbn: "rp2040:rp2040:rpipico"
board-upload: "nano"
niceBoardName: "rpi pico"
runs-on: ubuntu-latest
steps:
- name: Setup Arduino CLI
uses: arduino/[email protected]
- name: Install Arduino platforms
run: |
arduino-cli core update-index
arduino-cli core install ${{ matrix.arduino-platform }} # install the arduino platform (avr, samd, etc) with the right platform for the current board
${{ matrix.additional-commands }}
- name: Checkout
uses: actions/checkout@v4
- name: Compile Sketch
run: |
git config --global user.name 'gbg-with-joysticks'
git config --global user.email '[email protected]'
git pull # get the most recent state of the repo
arduino-cli compile ${{ matrix.code-dir }} --fqbn ${{ matrix.fqbn }} --output-dir ./hex/${{ matrix.configName }} # compile code in selected directory for selected board and drop hex files in corresponding hex/directory
# delete files other than programName.ino.hex since others aren't needed
cd hex/${{ matrix.configName }}/${{ matrix.code-dir }}
ls
cd ../../..
pwd
rm hex/${{ matrix.configName }}/${{ matrix.code-dir }}.ino.eep
rm hex/${{ matrix.configName }}/${{ matrix.code-dir }}.ino.elf
rm hex/${{ matrix.configName }}/${{ matrix.code-dir }}.ino.with_bootloader.bin
rm hex/${{ matrix.configName }}/${{ matrix.code-dir }}.ino.with_bootloader.hex
- name: Commit compiled files
run: |
git status
echo "${{ matrix.configName }}, ${{ matrix.code-dir }}, ${{ matrix.board-upload }}, ${{ matrix.niceBoardName }}" >> hex/configurations-info.txt
git status
git add .
git commit --allow-empty -m "BOT update compiled files for ${{ matrix.configName }}" # --allow-empty is needed in case the hex file hasn't changed
git push
compile-complete: # this job passes if the whole matrix passes
needs: [ compile-sketch ]
runs-on: ubuntu-latest
steps:
- name: Compile Complete
run: |
echo complete!