-
Notifications
You must be signed in to change notification settings - Fork 124
143 lines (131 loc) · 5.06 KB
/
build.yml
File metadata and controls
143 lines (131 loc) · 5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Build Firmware
on:
pull_request:
branches:
- main
paths:
- 'ats-mini/**'
- 'changelog/**'
- 'CHANGELOG.md'
- '.github/workflows/build.yml'
- '.pre-commit-config.yaml'
push:
# tags:
# - 'v*'
# branches:
# - main
paths:
- 'ats-mini/**'
- 'changelog/**'
- 'CHANGELOG.md'
- '.github/workflows/build.yml'
- '.pre-commit-config.yaml'
workflow_dispatch:
inputs:
revision:
description: "A tag to release, e.g. v1.00"
type: string
required: false
jobs:
build:
name: build ${{ matrix.board.profile }}
runs-on: ubuntu-latest
permissions: {}
strategy:
fail-fast: true
matrix:
board:
- profile: esp32s3-ospi
# If you change this line, change it in sketch.yaml as well
fqbn: esp32:esp32:esp32s3:CDCOnBoot=cdc,FlashSize=8M,PSRAM=opi,CPUFreq=80,USBMode=hwcdc,FlashMode=qio,PartitionScheme=custom,DebugLevel=none
artifact-suffix: ospi
- profile: esp32s3-qspi
# If you change this line, change it in sketch.yaml as well
fqbn: esp32:esp32:esp32s3:CDCOnBoot=cdc,FlashSize=8M,PSRAM=enabled,CPUFreq=80,USBMode=hwcdc,FlashMode=qio,PartitionScheme=custom,DebugLevel=none
artifact-suffix: qspi
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: ${{ matrix.board.fqbn }}
cli-compile-flags: |
- --profile
- ${{ matrix.board.profile }}
- --export-binaries
# Disabled to prevent building artifact for a previous commit
enable-deltas-report: false
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-${{ matrix.board.artifact-suffix }}
- name: Install uv and python
uses: astral-sh/setup-uv@v5
with:
pyproject-file: "pyproject.toml"
enable-cache: true
cache-dependency-glob: "**/pyproject.toml"
- name: Compile the unreleased changelog
run: |
# shellcheck disable=SC2015
ls changelog/*.md && uv run towncrier build --keep --version Unreleased || true
- name: Prepare compiled artifact
run: |
mkdir -p artifact/ats-mini-${{ steps.slug.outputs.slug }}-${{ matrix.board.artifact-suffix }}
mv ats-mini/build/esp32.esp32.esp32s3/*.ino.bin ats-mini/build/esp32.esp32.esp32s3/*.ino.*.bin artifact/ats-mini-${{ steps.slug.outputs.slug }}-${{ matrix.board.artifact-suffix }}/
cp CHANGELOG.md artifact/ats-mini-${{ steps.slug.outputs.slug }}-${{ matrix.board.artifact-suffix }}/
- name: Upload compiled artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: ${{ github.event.repository.name }}-${{ steps.slug.outputs.slug }}-${{ matrix.board.artifact-suffix }}
path: artifact
release:
if: ${{ 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 artifacts
uses: actions/download-artifact@v4
with:
pattern: 'ats-mini-*'
merge-multiple: true
path: artifact
- name: Archive the build artifacts
run: cd "artifact" && find . -mindepth 1 -maxdepth 1 -type d -exec sh -c 'zip -r "../${1%/}.zip" "$1"' _ {} \;
- name: Create release
env:
GITHUB_TOKEN: ${{ github.token }}
SLUG: ${{ needs.build.outputs.slug }}
run: >-
python -c 'import os,re; t=open(f"""artifact/ats-mini-{os.environ["SLUG"]}-ospi/CHANGELOG.md""").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 artifacts
env:
GITHUB_TOKEN: ${{ github.token }}
FILENAMES: ${{ github.event.repository.name }}-${{ needs.build.outputs.slug }}-*.zip
SLUG: ${{ needs.build.outputs.slug }}
run: |
# shellcheck disable=SC2086
gh release upload "$SLUG" $FILENAMES --repo '${{ github.repository }}' --clobber