name: Build Firmware on: pull_request: branches: - main paths: - 'ats-mini/**' - '.github/workflows/build.yml' push: # tags: # - 'v*' # branches: # - main paths: - 'ats-mini/**' - '.github/workflows/build.yml' workflow_dispatch: inputs: revision: description: "A tag to release, e.g. v1.00" type: string required: false jobs: build: runs-on: ubuntu-latest permissions: {} strategy: fail-fast: true outputs: slug: ${{ steps.slug.outputs.slug }} steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 fetch-tags: true ref: "${{ github.event.inputs.revision || github.ref }}" - name: Get version slug id: slug run: | echo "slug=$(git describe --tags --match 'v?.??' --always --dirty || echo v0.00)" >> $GITHUB_OUTPUT - name: Compile firmware uses: arduino/compile-sketches@v1 with: github-token: ${{ secrets.GITHUB_TOKEN }} sketch-paths: | - ats-mini fqbn: esp32:esp32:esp32s3 platforms: | - name: esp32:esp32 libraries: | - name: "PU2CLR SI4735" - name: TFT_eSPI cli-compile-flags: | - --export-binaries - --board-options - CDCOnBoot=cdc - --board-options - FlashSize=8M - --board-options - PSRAM=disabled - --board-options - CPUFreq=80 - --board-options - USBMode=hwcdc - --board-options - FlashMode=qio - --board-options - PartitionScheme=default_8MB - --board-options - DebugLevel=none - --warnings - none enable-deltas-report: true enable-warnings-report: true - name: Save sketches report artifact uses: actions/upload-artifact@v4 with: if-no-files-found: error path: sketches-reports name: sketches-report - name: Prepare compiled artifact run: | mkdir -p artifact/ats-mini mv ats-mini/build/esp32.esp32.esp32s3/*.ino.bin ats-mini/build/esp32.esp32.esp32s3/*.ino.*.bin artifact/ats-mini/ cp CHANGELOG.md artifact/ats-mini/ - name: Upload compiled artifact uses: actions/upload-artifact@v4 with: if-no-files-found: error name: ${{ github.event.repository.name }}-${{ steps.slug.outputs.slug }} path: artifact release: if: ${{ github.ref == 'refs/heads/main' && (github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))) }} needs: build runs-on: ubuntu-latest permissions: contents: write strategy: fail-fast: true steps: - name: Download the build artifact uses: actions/download-artifact@v4 with: name: ${{ github.event.repository.name }}-${{ needs.build.outputs.slug }} path: artifact - name: Archive the build artifact run: cd "artifact" && zip -9 -r "../${FILENAME}" * env: FILENAME: ${{ github.event.repository.name }}-${{ needs.build.outputs.slug }}.zip - name: Create release env: GITHUB_TOKEN: ${{ github.token }} SLUG: ${{ needs.build.outputs.slug }} run: >- cat artifact/ats-mini/CHANGELOG.md | python -c 'import os,re,sys; t=sys.stdin.read(); r=re.search(f"""(^## {os.environ["SLUG"][1:].replace(".", "\\.")} .*?)(?=^## \\d|\\Z)""", t, re.MULTILINE | re.DOTALL); print(r.group(0) if r else "")' | gh release create "$SLUG" --repo '${{ github.repository }}' --notes-file - - name: Upload release artifact env: GITHUB_TOKEN: ${{ github.token }} FILENAME: ${{ github.event.repository.name }}-${{ needs.build.outputs.slug }}.zip SLUG: ${{ needs.build.outputs.slug }} run: | gh release upload "$SLUG" "$FILENAME" --repo '${{ github.repository }}' --clobber