Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 90 additions & 64 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,45 @@
name: Build ExpressLRS Backpack
on: [push, pull_request]

on:
push:
pull_request:
workflow_dispatch:

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Validate targets.json
run: python3 .github/targets_validator.py
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Validate targets.json
run: python3 .github/targets_validator.py

- name: Run CRWF offline protocol checks
run: python3 tools/crsf_wifi_client.py

targets:
needs: validate
runs-on: ubuntu-latest
outputs:
targets: ${{ steps.set-targets.outputs.targets }}
steps:
- name: Checkout
uses: actions/checkout@v7
- id: set-targets
run: echo "targets=[$(grep -r "\[env:" targets | sed 's/.*://' | sed s/.$// | egrep "UART" | tr '\n' ',' | sed 's/,$/"\n/' | sed 's/,/","/'g | sed 's/^/"/')]" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- id: set-targets
run: |
python3 -c "import glob, re, json; targets = [m.group(1) for f in sorted(glob.glob('targets/*.ini')) for line in open(f) for m in [re.match(r'^\s*\[env:([^\]]+)\]', line)] if m and re.search(r'UART|CRSF_WIFI', m.group(1)) and not m.group(1).startswith('DEBUG_')]; print('targets=' + json.dumps(targets))" >> $GITHUB_OUTPUT

build:
needs: targets
Expand All @@ -28,70 +49,69 @@ jobs:
target: ${{fromJSON(needs.targets.outputs.targets)}}
runs-on: ubuntu-latest
steps:
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4

- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4

- name: Checkout
uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.10'

- name: Cache pip
uses: actions/cache@v6
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.target }}

- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install platformio
pip install wheel

- name: Cache PlatformIO
uses: actions/cache@v6
with:
path: ~/.platformio
key: ${{ runner.os }}-platformio

- name: Run PlatformIO
run: |
platformio platform update
platformio platform install native
mkdir -p ~/artifacts/firmware
pio run -e ${{ matrix.target }}
mv .pio/build/${{ matrix.target }} ~/artifacts/firmware/`echo ${{ matrix.target }} | sed s/_via_UART//`
cp -r hardware ~/artifacts/firmware

- name: Store Artifacts
uses: actions/upload-artifact@v7
with:
name: temp-${{ matrix.target }}
path: |
~/artifacts/**/*.bin
~/artifacts/**/*.json
continue-on-error: true
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.target }}

- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install platformio wheel

- name: Cache PlatformIO
uses: actions/cache@v4
with:
path: ~/.platformio
key: ${{ runner.os }}-platformio

- name: Run PlatformIO
run: |
platformio platform update
platformio platform install native
mkdir -p ~/artifacts/firmware
pio run -e ${{ matrix.target }}
TARGET_DIR=$(echo "${{ matrix.target }}" | sed -e 's/_via_UART//' -e 's/_via_CRSF_WIFI/_CRSF_WIFI/')
mv .pio/build/${{ matrix.target }} ~/artifacts/firmware/$TARGET_DIR
cp -r hardware ~/artifacts/firmware

- name: Store Artifacts
uses: actions/upload-artifact@v4
with:
name: temp-${{ matrix.target }}
path: |
~/artifacts/**/*.bin
~/artifacts/**/*.json
continue-on-error: true

firmware:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v6
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Get firmware artifacts
uses: actions/download-artifact@v8
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
Expand All @@ -103,7 +123,7 @@ jobs:
shiv -c flash -o ../dist/firmware/flasher.pyz pyserial .

- name: Update firmware artifact
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v4
with:
name: firmware
path: dist/**/*
Expand All @@ -113,23 +133,29 @@ jobs:
cd dist
zip -r -9 ../firmware.zip .

- name: Upload firmware zip bundle
uses: actions/upload-artifact@v4
with:
name: firmware-bundle
path: firmware.zip

- name: Upload firmware bundle to ExpressLRS artifactory
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ENDPOINT_URL: ${{ secrets.AWS_ENDPOINT_URL }}
AWS_REGION: "auto"
run: |
if [[ -z $AWS_ACCESS_KEY_ID || -z $AWS_SECRET_ACCESS_KEY || -z $AWS_ENDPOINT_URL ]]; then
echo "Artifactory credentials are not defined. Most likely action is running from pull request or fork. Not a bug."
exit 0
fi

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.22.35.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --update
aws --version

if [[ -z $AWS_ACCESS_KEY_ID || -z $AWS_SECRET_ACCESS_KEY || -z $AWS_ENDPOINT_URL ]]; then
echo "Artifactory credentials are not defined. Most likely action is running from pull request. Not a bug."
exit 0
fi

echo "Uploading firmware to artifactory"
aws s3 cp --endpoint-url $AWS_ENDPOINT_URL firmware.zip s3://expresslrs/Backpack/$GITHUB_SHA/firmware.zip

Expand Down
Loading