-
Notifications
You must be signed in to change notification settings - Fork 18
264 lines (231 loc) · 8.73 KB
/
ci.yaml
File metadata and controls
264 lines (231 loc) · 8.73 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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
name: CI
on:
workflow_dispatch:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+' # Match semantic versioning tags
branches:
- main
- dev
paths-ignore:
- '*.md'
env:
kibot_config: kibot_yaml/kibot_main.yaml
# Used variant. We assume:
# DRAFT: only schematic in progress, will only generate schematic PDF, netlist and BoM
# PRELIMINARY: will generate both schematic and PCB documents, but no ERC/DRC
# CHECKED: will generate both schematic and PCB documents, with ERC/DRC
# RELEASED: similar to CHECKED, automatically selected when pushing a tag to main
kibot_variant: DRAFT
# Set the KiCad version to 9
kicad_version: 9
kibot_log: kibot_run.log
permissions:
contents: write
jobs:
release:
needs: generate_outputs
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Pull latest changes
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
git fetch
git pull origin main
- name: Release
uses: docker://antonyurchenko/git-release:v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: |
Schematic/*.pdf
Manufacturing/Assembly/*
Manufacturing/Fabrication/*.pdf
Manufacturing/Fabrication/*.zip
Manufacturing/Fabrication/*.txt
3D/*.step
Testing/Testpoints/*.csv
generate_outputs:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'Merge pull request') || github.ref_type == 'tag'"
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# Run these changelog update steps only on tag pushes
- name: Pull latest changes for changelog update
if: ${{ github.ref_type == 'tag' }}
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
git fetch
git pull origin main
- name: Extract release notes
if: ${{ github.ref_type == 'tag' }}
uses: ffurrer2/extract-release-notes@v2
id: extract-release-notes
with:
prerelease: true
- name: Update changelog
if: ${{ github.ref_type == 'tag' }}
uses: thomaseizinger/keep-a-changelog-new-release@v2
with:
tag: ${{ github.ref_name }}
- name: Commit updated CHANGELOG
if: ${{ github.ref_type == 'tag' }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: main
commit_message: Update CHANGELOG
file_pattern: CHANGELOG.md
push_options: '--force'
- name: Cache 3D models data
id: models-cache
uses: set-soft/cache@main
with:
path: ~/cache_3d
key: cache_3d
- name: Determine VERSION Argument and Override Variant if Tag
id: determine-version-and-args
run: |
last_tag=$(git describe --tags --abbrev=0 || echo "")
if [[ "${{ github.ref_type }}" == "tag" ]]; then
version_arg="-E REVISION='${last_tag}'"
echo "Overriding kibot_variant to 'RELEASED' for tag"
echo "kibot_variant=RELEASED" >> $GITHUB_ENV
else
version_arg="-E REVISION='${last_tag}+ (Unreleased)'"
echo "kibot_variant=${{ env.kibot_variant }}" >> $GITHUB_ENV
fi
# Decide which group to use depending on kicad_version
if [[ "${{ env.kicad_version }}" == "9" ]]; then
group_name="all_group_k9"
else
group_name="all_group"
fi
# Determine additional_args based on the variant
case "$kibot_variant" in
"DRAFT")
additional_args="--skip-pre draw_fancy_stackup,erc,drc ${version_arg} --log ${{ env.kibot_log }} draft_group"
;;
"PRELIMINARY")
additional_args="--skip-pre erc,drc ${version_arg} --log ${{ env.kibot_log }} ${group_name}"
;;
"CHECKED"|"RELEASED")
additional_args="${version_arg} --log ${{ env.kibot_log }} ${group_name}"
;;
*)
echo "Unknown variant: $kibot_variant"
exit 1
;;
esac
echo "version_arg=${version_arg}" >> $GITHUB_ENV
echo "additional_args=${additional_args}" >> $GITHUB_ENV
# Generate notes (skipped for DRAFT variant)
- name: Generate notes (KiCad 8)
if: ${{ env.kicad_version == '8' && env.kibot_variant != 'DRAFT' }}
uses: INTI-CMNB/KiBot@v2_dk8
with:
skip: all
variant: ${{ env.kibot_variant }}
config: ${{ env.kibot_config }}
additional_args: --log kibot_run_notes.log notes
- name: Generate notes (KiCad 9)
if: ${{ env.kicad_version == '9' && env.kibot_variant != 'DRAFT' }}
uses: INTI-CMNB/KiBot@v2_dk9
with:
skip: all
variant: ${{ env.kibot_variant }}
config: ${{ env.kibot_config }}
additional_args: --log kibot_run_notes.log notes
# Generate README only (only for DRAFT variant)
- name: Generate README only (KiCad 8)
if: ${{ env.kicad_version == '8' && env.kibot_variant == 'DRAFT' }}
uses: INTI-CMNB/KiBot@v2_dk8
with:
skip: draw_fancy_stackup,set_text_variables,erc,drc
variant: ${{ env.kibot_variant }}
config: ${{ env.kibot_config }}
additional_args: --log kibot_run_readme.log md_readme
- name: Generate README only (KiCad 9)
if: ${{ env.kicad_version == '9' && env.kibot_variant == 'DRAFT' }}
uses: INTI-CMNB/KiBot@v2_dk9
with:
skip: draw_fancy_stackup,set_text_variables,erc,drc
variant: ${{ env.kibot_variant }}
config: ${{ env.kibot_config }}
additional_args: --log kibot_run_readme.log md_readme
# Generate outputs
- name: Generate outputs (KiCad 8)
if: ${{ env.kicad_version == '8' }}
uses: INTI-CMNB/KiBot@v2_dk8
with:
additional_args: ${{ env.additional_args }}
variant: ${{ env.kibot_variant }}
config: ${{ env.kibot_config }}
cache3D: YES
- name: Generate outputs (KiCad 9)
if: ${{ env.kicad_version == '9' }}
uses: INTI-CMNB/KiBot@v2_dk9
with:
additional_args: ${{ env.additional_args }}
variant: ${{ env.kibot_variant }}
config: ${{ env.kibot_config }}
cache3D: YES
- name: Pull latest changes
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "Triggered by a tag, committing changes in detached HEAD state"
git add -A
git commit -m "Update Outputs (release)"
DETACHED_COMMIT=$(git rev-parse HEAD)
echo "Checking out the main branch"
git fetch origin main
git checkout main
echo "Merging detached HEAD commit into main"
git merge --no-ff $DETACHED_COMMIT -m "Merge outputs from tag-triggered workflow" -X theirs
echo "Pushing to main branch"
git push origin main
else
echo "Triggered by a branch, using the current branch"
git pull origin ${{ github.ref_name }} --tags --force
fi
- name: Discard changes to .kicad_pcb files and remove temp files
run: |
git checkout HEAD -- $(git ls-files "*.kicad_pcb")
git clean -f "*.kicad_pcb"
git clean -f "*.kicad_pro"
git clean -f "*.kicad_dru"
git clean -f "*.kicad_prl"
- name: Update Outputs
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: ${{ github.ref_name }}
commit_message: Update Outputs
- name: Store log
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: log_file
path: ${{ env.kibot_log }}
- name: Store notes log
if: ${{ always() && env.kibot_variant != 'DRAFT' }}
uses: actions/upload-artifact@v4
with:
name: log_file_notes
path: kibot_run_notes.log
- name: Store README log
if: ${{ always() && env.kibot_variant == 'DRAFT' }}
uses: actions/upload-artifact@v4
with:
name: log_file_readme
path: kibot_run_readme.log