Skip to content

CI: per-file artifacts, publish raw firmware on v* tags #3

CI: per-file artifacts, publish raw firmware on v* tags

CI: per-file artifacts, publish raw firmware on v* tags #3

Workflow file for this run

name: Build
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- environment: vehicle
name: heltec3-tracker
- environment: vehicle_v4
name: heltec4-tracker
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Cache PlatformIO
uses: actions/cache@v4
with:
path: |
~/.platformio
.pio
key: pio-${{ runner.os }}-${{ matrix.environment }}-${{ hashFiles('platformio.ini') }}
restore-keys: |
pio-${{ runner.os }}-${{ matrix.environment }}-
- name: Install PlatformIO
run: pip install platformio intelhex
- name: Build ${{ matrix.environment }}
run: pio run -e ${{ matrix.environment }}
# .bin is the app image (flash at 0x10000); .hex carries that offset in
# its records so hex-aware tools flash it to the right place
- name: Package firmware
run: |
mkdir -p artifacts
cp .pio/build/${{ matrix.environment }}/firmware.bin artifacts/${{ matrix.name }}.bin
python -c "from intelhex import IntelHex; ih = IntelHex(); ih.loadbin('.pio/build/${{ matrix.environment }}/firmware.bin', offset=0x10000); ih.write_hex_file('artifacts/${{ matrix.name }}.hex')"
- name: Upload .bin
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}.bin
path: artifacts/${{ matrix.name }}.bin
- name: Upload .hex
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}.hex
path: artifacts/${{ matrix.name }}.hex
# Tag pushes (v*) publish the firmware as raw release assets — unlike CI
# artifacts, these download as plain .bin/.hex files, not zips
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download firmware
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: dist/*
prerelease: ${{ contains(github.ref_name, '-') }}