|
| 1 | +name: Build and Upload Firmware |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + build-and-upload: |
| 10 | + runs-on: ubuntu-22.04 |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout |
| 14 | + uses: actions/checkout@v4 |
| 15 | + with: |
| 16 | + path: makerville-badge |
| 17 | + persist-credentials: false |
| 18 | + |
| 19 | + - name: Set up Python |
| 20 | + uses: actions/setup-python@v5 |
| 21 | + with: |
| 22 | + python-version: 3.12 |
| 23 | + |
| 24 | + - name: Setup Zephyr project |
| 25 | + uses: zephyrproject-rtos/action-zephyr-setup@v1 |
| 26 | + with: |
| 27 | + app-path: makerville-badge |
| 28 | + toolchains: espressif |
| 29 | + |
| 30 | + - name: Build firmware for ESP32-C3 |
| 31 | + working-directory: makerville-badge |
| 32 | + shell: bash |
| 33 | + run: | |
| 34 | + west build -p always -b esp32c3_devkitm app -- -DBOARD_ROOT=. |
| 35 | +
|
| 36 | + - name: List build artifacts |
| 37 | + working-directory: makerville-badge |
| 38 | + run: | |
| 39 | + echo "Build artifacts:" |
| 40 | + ls -lh build/zephyr/*.bin build/zephyr/*.elf 2>/dev/null || echo "Binary files not found" |
| 41 | + ls -lh build/zephyr/ | head -20 |
| 42 | +
|
| 43 | + - name: Get branch name |
| 44 | + id: branch |
| 45 | + run: | |
| 46 | + # Extract branch name from ref |
| 47 | + BRANCH_NAME=${GITHUB_REF#refs/heads/} |
| 48 | + # Sanitize branch name for use in paths (replace / with -) |
| 49 | + BRANCH_NAME_SAFE=$(echo "$BRANCH_NAME" | sed 's/\//-/g') |
| 50 | + echo "name=$BRANCH_NAME_SAFE" >> $GITHUB_OUTPUT |
| 51 | + echo "Branch name: $BRANCH_NAME_SAFE" |
| 52 | +
|
| 53 | + - name: Rename binary with commit ID |
| 54 | + working-directory: makerville-badge/build/zephyr |
| 55 | + run: | |
| 56 | + cp zephyr.bin zephyr_${{ github.sha }}.bin |
| 57 | + ls -lh zephyr_${{ github.sha }}.bin |
| 58 | +
|
| 59 | + - name: Upload firmware to EmbedHub |
| 60 | + if: github.event_name == 'push' |
| 61 | + uses: Embed-Hub/EmbedHub-GitHub-Action@master |
| 62 | + with: |
| 63 | + api-key: ${{ secrets.EMBEDHUB_API_KEY }} |
| 64 | + organization: ${{ secrets.EMBEDHUB_ORG }} |
| 65 | + project: ${{ secrets.EMBEDHUB_PROJECT }} |
| 66 | + files: 'makerville-badge/build/zephyr/zephyr_${{ github.sha }}.bin' |
| 67 | + path: 'releases/${{ steps.branch.outputs.name }}/' |
| 68 | + working-directory: '.' |
| 69 | + |
| 70 | + - name: Archive build artifacts |
| 71 | + uses: actions/upload-artifact@v4 |
| 72 | + with: |
| 73 | + name: firmware-esp32c3-${{ steps.branch.outputs.name }}-${{ github.sha }} |
| 74 | + path: | |
| 75 | + makerville-badge/build/zephyr/zephyr.bin |
| 76 | + makerville-badge/build/zephyr/zephyr_${{ github.sha }}.bin |
| 77 | + makerville-badge/build/zephyr/zephyr.elf |
| 78 | + makerville-badge/build/zephyr/zephyr.map |
| 79 | + retention-days: 30 |
0 commit comments