-
Notifications
You must be signed in to change notification settings - Fork 8
224 lines (188 loc) · 6.91 KB
/
ci.yml
File metadata and controls
224 lines (188 loc) · 6.91 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
name: CI
on:
push:
branches: ["*"]
tags: ["*"]
pull_request:
branches: ["*"]
permissions:
contents: read
issues: read
pull-requests: read
packages: read
jobs:
shellcheck:
name: ShellCheck
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # master
with:
scandir: "scripts"
static-analysis:
name: Static Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.x"
- name: Install PlatformIO
run: |
pip install 'click<8.1.0'
pip install platformio
- name: Run PlatformIO Check
run: |
pio check --fail-on-defect high
build:
name: Build with PlatformIO
needs: [shellcheck, static-analysis]
runs-on: ubuntu-latest
permissions:
contents: write
issues: read
pull-requests: read
packages: read
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.x"
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: "24"
- name: Install compatible click
run: pip install 'click<8.1.0' # prevendt conflicts with PlatformIO
- name: Install PlatformIO
run: pip install platformio
- name: Install semantic-release and plugins (dry-run)
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
run: npm install -g semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/github
- name: Compute next version and create local tag
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
DRY_RUN_OUTPUT="$(semantic-release --dry-run --no-ci 2>&1 || true)"
echo "$DRY_RUN_OUTPUT"
NEXT_VERSION="$(printf '%s\n' "$DRY_RUN_OUTPUT" | sed -nE 's/.*next release version is ([0-9]+\.[0-9]+\.[0-9]+).*/\1/p' | tail -n 1)"
if [ -n "$NEXT_VERSION" ]; then
git tag -f "v$NEXT_VERSION" "$GITHUB_SHA"
echo "Created local tag: v$NEXT_VERSION"
git describe --tags --always --dirty=-dev --broken=-dev --abbrev=2
else
echo "No next release version detected, fallback to existing tags"
fi
- name: Install dependencies
run: pio lib install
- name: Build firmware
run: pio run
- name: Upload firmware artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: build-firmware
path: |
.pio/build/esp12e/firmware.bin
.pio/build/project.checksum
include-hidden-files: true
- name: Build filesystem for HelloCubic
run: |
cp data/config-hellocubic.example data/config.json
pio run --target buildfs
mv .pio/build/esp12e/littlefs.bin .pio/build/esp12e/littlefs-hellocubic.bin
- name: Build filesystem for SmallTV Ultra
run: |
cp data/config-smartTV.example data/config.json
pio run --target buildfs
mv .pio/build/esp12e/littlefs.bin .pio/build/esp12e/littlefs-smartTV.bin
- name: Upload filesystem artifacts
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: build-filesystem
path: |
.pio/build/esp12e/littlefs-hellocubic.bin
.pio/build/esp12e/littlefs-smartTV.bin
include-hidden-files: true
package:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
issues: write
pull-requests: write
packages: read
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: "24"
- name: Download firmware artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: build-firmware
path: ./artifacts/firmware
merge-multiple: true
- name: Download filesystem artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: build-filesystem
path: ./artifacts/filesystem
merge-multiple: true
- name: Install semantic-release and plugins
run: npm install -g semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/github
- name: Run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: semantic-release
devcontainer:
name: Build and push devcontainer image
needs: package
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
- name: Login to GitHub Container Registry
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push devcontainer image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
with:
context: .devcontainer
file: .devcontainer/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/times-z/devcontainer:latest
ghcr.io/times-z/devcontainer:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max