|
6 | 6 | - 'v*' |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - verify: |
10 | | - runs-on: ubuntu-latest |
11 | | - steps: |
12 | | - - name: Checkout |
13 | | - uses: actions/checkout@v4 |
14 | | - |
15 | | - - name: Configure CMake |
16 | | - run: cmake -S . -B build |
17 | | - |
18 | | - - name: Build tests |
19 | | - run: cmake --build build |
20 | | - |
21 | | - - name: Run tests |
22 | | - run: ctest --test-dir build --output-on-failure |
23 | | - |
24 | | - platformio-build: |
25 | | - runs-on: ubuntu-latest |
26 | | - needs: verify |
27 | | - strategy: |
28 | | - fail-fast: false |
29 | | - matrix: |
30 | | - board: [esp32dev, esp32-s3-devkitc-1, esp32-c3-devkitm-1] |
31 | | - steps: |
32 | | - - name: Checkout |
33 | | - uses: actions/checkout@v4 |
34 | | - |
35 | | - - name: Set up Python |
36 | | - uses: actions/setup-python@v5 |
37 | | - with: |
38 | | - python-version: '3.x' |
39 | | - |
40 | | - - name: Cache PlatformIO |
41 | | - uses: actions/cache@v4 |
42 | | - with: |
43 | | - path: ~/.platformio |
44 | | - key: ${{ runner.os }}-platformio-${{ hashFiles('**/library.json') }} |
45 | | - restore-keys: | |
46 | | - ${{ runner.os }}-platformio- |
47 | | -
|
48 | | - - name: Install PlatformIO |
49 | | - run: pip install --upgrade platformio |
50 | | - |
51 | | - - name: Build library examples (ESP32 Arduino) |
52 | | - run: | |
53 | | - set -e |
54 | | - for d in examples/*; do |
55 | | - if [ -d "$d" ]; then |
56 | | - echo "Building $d on ${{ matrix.board }} via PlatformIO CI" |
57 | | - pio ci "$d" \ |
58 | | - --board ${{ matrix.board }} \ |
59 | | - --lib="." \ |
60 | | - --project-option "build_unflags=-std=gnu++11" \ |
61 | | - --project-option "build_flags=-std=gnu++17" |
62 | | - fi |
63 | | - done |
64 | | -
|
65 | | - arduino-cli: |
66 | | - runs-on: ubuntu-latest |
67 | | - needs: verify |
68 | | - strategy: |
69 | | - fail-fast: false |
70 | | - matrix: |
71 | | - board: |
72 | | - - fqbn: esp32:esp32:esp32 |
73 | | - name: esp32dev |
74 | | - - fqbn: esp32:esp32:esp32s3 |
75 | | - name: esp32-s3-devkitc-1 |
76 | | - - fqbn: esp32:esp32:esp32c3 |
77 | | - name: esp32-c3-devkitm-1 |
78 | | - steps: |
79 | | - - name: Checkout |
80 | | - uses: actions/checkout@v4 |
81 | | - |
82 | | - - name: Set up Arduino CLI |
83 | | - uses: arduino/setup-arduino-cli@v1 |
84 | | - |
85 | | - - name: Install ESP32 core |
86 | | - run: | |
87 | | - arduino-cli core update-index |
88 | | - arduino-cli core install esp32:esp32 |
89 | | -
|
90 | | - - name: Install libraries |
91 | | - run: | |
92 | | - arduino-cli lib update-index |
93 | | - arduino-cli lib install "ArduinoJson" "StreamUtils" |
94 | | -
|
95 | | - - name: Add local library to sketchbook |
96 | | - run: | |
97 | | - set -e |
98 | | - SKETCHBOOK_DIR="${HOME}/Arduino" |
99 | | - mkdir -p "$SKETCHBOOK_DIR/libraries/ESPJsonDB" |
100 | | - rsync -a --delete --exclude ".git" ./ "$SKETCHBOOK_DIR/libraries/ESPJsonDB/" |
101 | | -
|
102 | | - - name: Build examples (${{ matrix.board.name }}) |
103 | | - env: |
104 | | - FQBN: ${{ matrix.board.fqbn }} |
105 | | - run: | |
106 | | - set -e |
107 | | - for d in examples/*; do |
108 | | - if [ -d "$d" ]; then |
109 | | - echo "Compiling $d" |
110 | | - arduino-cli compile --fqbn "$FQBN" "$d" |
111 | | - fi |
112 | | - done |
113 | | -
|
114 | 9 | create-release: |
115 | 10 | runs-on: ubuntu-latest |
116 | | - needs: |
117 | | - - verify |
118 | | - - platformio-build |
119 | | - - arduino-cli |
120 | 11 | permissions: |
121 | 12 | contents: write |
122 | 13 | steps: |
123 | 14 | - name: Checkout |
124 | 15 | uses: actions/checkout@v4 |
125 | 16 |
|
| 17 | + - name: Extract changelog entry |
| 18 | + id: changelog |
| 19 | + uses: actions/github-script@v7 |
| 20 | + with: |
| 21 | + result-encoding: string |
| 22 | + script: | |
| 23 | + const tag = process.env.GITHUB_REF_NAME || ''; |
| 24 | + const version = tag.startsWith('v') ? tag.slice(1) : tag; |
| 25 | + const fs = require('node:fs'); |
| 26 | + const changelog = fs.readFileSync('CHANGELOG.md', 'utf8'); |
| 27 | + const heading = `## [${version}]`; |
| 28 | + const start = changelog.indexOf(heading); |
| 29 | + let entry; |
| 30 | + if (start === -1) { |
| 31 | + entry = `No changelog entry found for version ${version}.`; |
| 32 | + } else { |
| 33 | + const afterHeading = start + heading.length; |
| 34 | + const nextHeader = changelog.indexOf('\n## [', afterHeading); |
| 35 | + const sliceEnd = nextHeader === -1 ? changelog.length : nextHeader; |
| 36 | + entry = changelog.slice(start, sliceEnd).trim(); |
| 37 | + } |
| 38 | + return entry; |
| 39 | +
|
126 | 40 | - name: Create GitHub Release |
127 | 41 | uses: softprops/action-gh-release@v2 |
128 | 42 | with: |
129 | | - generate_release_notes: true |
130 | 43 | draft: false |
131 | 44 | prerelease: false |
| 45 | + generate_release_notes: false |
| 46 | + body: ${{ steps.changelog.outputs.result }} |
132 | 47 | env: |
133 | 48 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments