|
| 1 | +name: Create Firmware Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + paths: |
| 7 | + - 'resources/BISCUIT/CURRENT/**' |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + release: |
| 14 | + name: Create Firmware Release |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Extract Version and Build Release Notes |
| 21 | + id: info |
| 22 | + run: | |
| 23 | + MANIFEST="resources/BISCUIT/CURRENT/manifest.json" |
| 24 | +
|
| 25 | + # Extract version info from manifest |
| 26 | + python3 << 'PYEOF' |
| 27 | + import json, os |
| 28 | +
|
| 29 | + with open("resources/BISCUIT/CURRENT/manifest.json") as f: |
| 30 | + m = json.load(f) |
| 31 | +
|
| 32 | + devices = m["devices"] |
| 33 | +
|
| 34 | + # Use the first DIY device version as the primary release version |
| 35 | + primary_version = devices[0]["version"] |
| 36 | +
|
| 37 | + # Build release body |
| 38 | + lines = [] |
| 39 | + lines.append("## Firmware Files\n") |
| 40 | + lines.append("| Device | Chip | Version | Bootloader | Partitions | Firmware |") |
| 41 | + lines.append("|--------|------|---------|------------|------------|----------|") |
| 42 | +
|
| 43 | + for d in devices: |
| 44 | + offsets = d["offsets"] |
| 45 | + lines.append( |
| 46 | + f"| {d['name']} | {d['chip']} | {d['version']} " |
| 47 | + f"| `0x{offsets[0]:04X}` | `0x{offsets[1]:04X}` | `0x{offsets[2]:05X}` |" |
| 48 | + ) |
| 49 | +
|
| 50 | + lines.append("") |
| 51 | + lines.append("## Flash Offsets\n") |
| 52 | + lines.append("| Component | Offset (hex) | Offset (dec) |") |
| 53 | + lines.append("|-----------|-------------|--------------|") |
| 54 | + lines.append("| Bootloader | `0x2000` | 8192 |") |
| 55 | + lines.append("| Partition Table | `0x8000` | 32768 |") |
| 56 | + lines.append("| Application | `0x10000` | 65536 |") |
| 57 | +
|
| 58 | + lines.append("") |
| 59 | + lines.append("## Included Binaries\n") |
| 60 | + for d in devices: |
| 61 | + lines.append(f"**{d['name']}** — v{d['version']}") |
| 62 | + for ftype, fpath in d["files"].items(): |
| 63 | + fname = fpath.split("/")[-1] |
| 64 | + lines.append(f"- `{fname}` ({ftype})") |
| 65 | + lines.append("") |
| 66 | +
|
| 67 | + lines.append("---") |
| 68 | + lines.append("Flash using the [Biscuit WebFlasher](https://codehedge.github.io/Adafruit_WebSerial_ESPTool/).") |
| 69 | +
|
| 70 | + body = "\n".join(lines) |
| 71 | +
|
| 72 | + with open("release_body.md", "w") as f: |
| 73 | + f.write(body) |
| 74 | +
|
| 75 | + # Write outputs |
| 76 | + with open(os.environ["GITHUB_OUTPUT"], "a") as f: |
| 77 | + f.write(f"version={primary_version}\n") |
| 78 | + PYEOF |
| 79 | +
|
| 80 | + - name: Collect Firmware Binaries |
| 81 | + run: | |
| 82 | + mkdir -p release_assets |
| 83 | + cp resources/BISCUIT/CURRENT/*.bin release_assets/ |
| 84 | +
|
| 85 | + - name: Delete Existing Release (if same version) |
| 86 | + run: | |
| 87 | + TAG="v${{ steps.info.outputs.version }}" |
| 88 | + gh release delete "$TAG" --yes 2>/dev/null || true |
| 89 | + git push origin --delete "refs/tags/$TAG" 2>/dev/null || true |
| 90 | + env: |
| 91 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 92 | + |
| 93 | + - name: Create Release |
| 94 | + uses: softprops/action-gh-release@v2 |
| 95 | + with: |
| 96 | + tag_name: v${{ steps.info.outputs.version }} |
| 97 | + name: Biscuit Firmware v${{ steps.info.outputs.version }} |
| 98 | + body_path: release_body.md |
| 99 | + draft: false |
| 100 | + prerelease: false |
| 101 | + files: release_assets/*.bin |
| 102 | + make_latest: true |
| 103 | + env: |
| 104 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments