2 on: [push, pull_request]
8 - name: Inject slug/short variables
9 uses: rlespinasse/github-slug-action@v4
12 uses: actions/checkout@v4
15 uses: actions/setup-python@v5
17 python-version: '3.10'
20 uses: actions/cache@v4
23 key: ${{ runner.os }}-pip-${{ matrix.target }}
25 - name: Install PlatformIO
27 python -m pip install --upgrade pip
28 pip install platformio
31 - name: Cache PlatformIO
32 uses: actions/cache@v4
35 key: ${{ runner.os }}-platformio
37 - name: Run PlatformIO Tests
40 platformio pkg install --platform native
42 PLATFORMIO_BUILD_FLAGS="-DRegulatory_Domain_ISM_2400" pio test -e native
45 runs-on: ubuntu-latest
47 targets: ${{ steps.set-targets.outputs.targets }}
50 uses: actions/checkout@v4
52 run: echo "targets=[$( (grep '\[env:.*UART\]' src/targets/unified.ini ; grep -r '\[env:.*STLINK\]' src/targets/) | sed 's/.*://' | sed s/.$// | egrep "(STLINK|UART)" | grep -v DEPRECATED | tr '\n' ',' | sed 's/,$/"\n/' | sed 's/,/","/'g | sed 's/^/"/')]" >> $GITHUB_OUTPUT
59 target: ${{fromJSON(needs.targets.outputs.targets)}}
60 runs-on: ubuntu-latest
63 - name: Inject slug/short variables
64 uses: rlespinasse/github-slug-action@v4
67 uses: actions/checkout@v4
70 uses: actions/setup-python@v5
72 python-version: '3.10'
75 uses: actions/cache@v4
78 key: ${{ runner.os }}-pip-${{ matrix.target }}
80 - name: Install PlatformIO
82 python -m pip install --upgrade pip
83 pip install platformio
86 - name: Cache PlatformIO
87 uses: actions/cache@v4
90 key: ${{ runner.os }}-platformio
92 - name: Run PlatformIO
94 mkdir -p ~/artifacts/firmware
96 platformio pkg install --platform native
98 case ${{matrix.target}} in
101 PLATFORMIO_BUILD_FLAGS="-DRegulatory_Domain_EU_CE_2400" pio run -e ${{ matrix.target }}
102 OUTDIR=~/artifacts/firmware/LBT/`echo ${{ matrix.target }} | sed s/_via.*//`
104 mv .pio/build/${{ matrix.target }}/*.{elrs,bin} $OUTDIR >& /dev/null || :
106 PLATFORMIO_BUILD_FLAGS="-DRegulatory_Domain_ISM_2400" pio run -e ${{ matrix.target }}
107 OUTDIR=~/artifacts/firmware/FCC/`echo ${{ matrix.target }} | sed s/_via.*//`
109 mv .pio/build/${{ matrix.target }}/*.{elrs,bin} $OUTDIR >& /dev/null || :
113 PLATFORMIO_BUILD_FLAGS="-DRegulatory_Domain_FCC_915" pio run -e ${{ matrix.target }}
114 OUTDIR=~/artifacts/firmware/FCC/`echo ${{ matrix.target }} | sed s/_via.*//`
116 mv .pio/build/${{ matrix.target }}/*.{elrs,bin} $OUTDIR >& /dev/null || :
120 - name: Store Artifacts
121 uses: actions/upload-artifact@v4
123 name: temp-${{ matrix.target }}
124 path: ~/artifacts/**/*
126 continue-on-error: true
130 runs-on: ubuntu-latest
132 - name: Checkout code
133 uses: actions/checkout@v4
137 - name: Checkout targets repo
138 uses: actions/checkout@v4
140 repository: ExpressLRS/targets
143 - name: Get firmware artifacts
144 uses: actions/download-artifact@v4
149 - name: Copy hardware files to firmware folder
151 cp -r src/hardware dist/firmware
152 jq 'del(.generic)' src/hardware/targets.json > dist/firmware/hardware/targets.json
154 - name: Copy Lua to to firmware folder
156 mkdir -p dist/firmware/lua
157 cp -r src/lua/elrsV3.lua dist/firmware/lua
159 - name: Copy bootloader files to firmware folder
160 run: cd src ; find bootloader -name \*.bin -o -name \*.frk | grep -v src/ | cpio -pdm ../dist/firmware
162 - name: Set up Python
163 uses: actions/setup-python@v5
165 python-version: '3.10'
167 - name: Build flasher "binary" with shiv
170 pip install shiv==1.0.6
171 shiv -c flash -o ../../dist/firmware/flasher.pyz pyserial .
173 - name: Update firmware artifact
174 uses: actions/upload-artifact@v4
179 - name: Create firmware zip bundle
182 zip -r -9 ../firmware.zip ./firmware
184 - name: Upload firmware bundle to ExpressLRS artifactory
186 AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
187 AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
188 AWS_ENDPOINT_URL: ${{ secrets.AWS_ENDPOINT_URL }}
191 if [[ -z $AWS_ACCESS_KEY_ID || -z $AWS_SECRET_ACCESS_KEY || -z $AWS_ENDPOINT_URL ]]; then
192 echo "Artifactory credentials are not defined. Most likely action is running from pull request. Not a bug."
196 aws s3api head-object --endpoint-url $AWS_ENDPOINT_URL --bucket expresslrs --key ExpressLRS/$GITHUB_SHA/firmware.zip > /dev/null || ALLOW_UPLOAD=true
197 git describe --tags --exact-match HEAD && ALLOW_UPLOAD=true
198 if [ $ALLOW_UPLOAD ]; then
199 echo "Uploading firmware to artifactory"
200 aws s3 cp --endpoint-url $AWS_ENDPOINT_URL firmware.zip s3://expresslrs/ExpressLRS/$GITHUB_SHA/firmware.zip
202 echo "Generating artifact index"
203 aws s3 ls --endpoint-url $AWS_ENDPOINT_URL s3://expresslrs/ExpressLRS/ | awk '{print $2}' | sed s/\\/// > /tmp/hashes
204 echo '{' > index.json
205 echo '"branches": {' >> index.json
206 git branch --list --remotes --format '"%(refname:short)": "%(objectname)",' | grep origin/ | sed s/origin.// | grep -f /tmp/hashes | head -c-2 >> index.json
207 echo '' >> index.json
208 echo '},' >> index.json
209 echo '"tags": {' >> index.json
210 git tag --list --format '"%(refname:short)": "%(objectname)",' | grep -f /tmp/hashes | head -c-2 >> index.json
211 echo '' >> index.json
212 echo '}' >> index.json
213 echo '}' >> index.json
215 echo "Uploading artifact index"
216 aws s3 cp --endpoint-url $AWS_ENDPOINT_URL index.json s3://expresslrs/ExpressLRS/index.json
218 echo "Not overwriting already existing artifact at $GITHUB_SHA"