Skip to content

Commit e243809

Browse files
authored
Merge pull request #1 from ergonautkb/automation
Generate PCB images and production files via Actions
2 parents f235ce3 + 8cf21ce commit e243809

File tree

12 files changed

+248
-0
lines changed

12 files changed

+248
-0
lines changed

.github/workflows/main.yml

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
paths-ignore:
6+
- '**/README.md'
7+
- '**/LICENSE'
8+
- '**/CHANGES.txt'
9+
- '**/img/*'
10+
pull_request:
11+
branches:
12+
- main
13+
paths-ignore:
14+
- '**/README.md'
15+
- '**/LICENSE'
16+
- '**/CHANGES.txt'
17+
- '**/img/*'
18+
workflow_dispatch:
19+
paths-ignore:
20+
- '**/README.md'
21+
- '**/LICENSE'
22+
- '**/CHANGES.txt'
23+
- '**/img/*'
24+
25+
env:
26+
DOCKER_USER_OPTION: '$UID:$GID'
27+
28+
name: Build
29+
jobs:
30+
generate:
31+
runs-on: ubuntu-latest
32+
name: Generate
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v3.5.2
36+
- uses: xanantis/docker-file-ownership-fix@v1
37+
- name: Run build script
38+
run: |
39+
chmod +x build.sh
40+
./build.sh
41+
shell: bash
42+
- name: Persist PCB gerbers
43+
uses: actions/upload-artifact@v3.1.2
44+
with:
45+
name: One_pcb_gerbers
46+
path: gerbers/pcb
47+
- name: Persist case gerbers
48+
uses: actions/upload-artifact@v3.1.2
49+
with:
50+
name: One_case_gerbers
51+
path: gerbers/case
52+
- name: Persist images
53+
uses: actions/upload-artifact@v3.1.2
54+
with:
55+
name: One_images
56+
path: images
57+
58+
59+
image_matrix:
60+
runs-on: ubuntu-latest
61+
name: PCB image matrix
62+
needs: generate
63+
outputs:
64+
matrix: ${{ steps.setmatrix.outputs.matrix }}
65+
steps:
66+
- uses: actions/download-artifact@master
67+
with:
68+
name: One_images
69+
path: images
70+
- id: setmatrix
71+
run: |
72+
matrixArray=$(find ./images -name 'pcb*.png' | xargs -n 1 -i echo {} {} | sed 's# .*/# #') # Creates array of all PCB image files
73+
# Start Generate JSON String
74+
echo "$matrixArray" | \
75+
jq --slurp --raw-input 'split("\n")[:-1] | map(split(" "))' | \
76+
jq "map({\"filepath\": (.[0]), \"basename\": .[1] })" | \
77+
jq -sc "{ \"include\": .[] }" > tmp
78+
cat ./tmp
79+
# End Generate JSON String
80+
matrixStringifiedObject=$(cat ./tmp) # Use this as jq @sh wasn't cooperating
81+
echo "matrix=$matrixStringifiedObject" >> $GITHUB_OUTPUT
82+
83+
gerber_matrix:
84+
runs-on: ubuntu-latest
85+
name: Gerber matrix
86+
needs: generate
87+
outputs:
88+
matrix: ${{ steps.setmatrix.outputs.matrix }}
89+
steps:
90+
- uses: actions/download-artifact@master
91+
with:
92+
name: One_pcb_gerbers
93+
path: gerbers/pcb
94+
- id: setmatrix
95+
run: |
96+
matrixArray=$(find ./gerbers/pcb -name '*.zip' | xargs -n 1 -i echo {} {} | sed 's# .*/# #') # Creates array of all PCB gerber files
97+
# Start Generate JSON String
98+
echo "$matrixArray" | \
99+
jq --slurp --raw-input 'split("\n")[:-1] | map(split(" "))' | \
100+
jq "map({\"filepath\": (.[0]), \"basename\": .[1] })" | \
101+
jq -sc "{ \"include\": .[] }" > tmp
102+
cat ./tmp
103+
# End Generate JSON String
104+
matrixStringifiedObject=$(cat ./tmp) # Use this as jq @sh wasn't cooperating
105+
echo "matrix=$matrixStringifiedObject" >> $GITHUB_OUTPUT
106+
107+
upload_pcb_gerbers:
108+
runs-on: ubuntu-latest
109+
name: Upload PCB gerbers
110+
needs: [generate, gerber_matrix]
111+
strategy:
112+
matrix: ${{fromJson(needs.gerber_matrix.outputs.matrix)}}
113+
steps:
114+
- uses: actions/download-artifact@master
115+
with:
116+
name: One_pcb_gerbers
117+
path: gerbers/pcb
118+
- name: Gets latest created release info
119+
id: latest_release_info
120+
uses: jossef/action-latest-release-info@v1.2.1
121+
env:
122+
GITHUB_TOKEN: ${{ github.token }}
123+
- name: Upload gerbers
124+
uses: shogo82148/actions-upload-release-asset@v1.6.4
125+
env:
126+
GITHUB_TOKEN: ${{ github.token }}
127+
with:
128+
overwrite: true
129+
upload_url: ${{ steps.latest_release_info.outputs.upload_url }}
130+
asset_path: ${{ matrix.filepath }}
131+
asset_name: ${{ matrix.basename }}
132+
133+
upload_images:
134+
runs-on: ubuntu-latest
135+
name: Upload images
136+
needs: [generate, image_matrix]
137+
strategy:
138+
matrix: ${{fromJson(needs.image_matrix.outputs.matrix)}}
139+
steps:
140+
- uses: actions/download-artifact@master
141+
with:
142+
name: One_images
143+
path: images
144+
- name: Gets latest created release info
145+
id: latest_release_info
146+
uses: jossef/action-latest-release-info@v1.2.1
147+
env:
148+
GITHUB_TOKEN: ${{ github.token }}
149+
- name: Upload images
150+
uses: shogo82148/actions-upload-release-asset@v1.6.4
151+
env:
152+
GITHUB_TOKEN: ${{ github.token }}
153+
with:
154+
overwrite: true
155+
upload_url: ${{ steps.latest_release_info.outputs.upload_url }}
156+
asset_path: ${{ matrix.filepath }}
157+
asset_name: ${{ matrix.basename }}
158+
159+
upload_gerber_case_files:
160+
runs-on: ubuntu-latest
161+
name: Upload case gerber files
162+
needs: generate
163+
steps:
164+
- uses: actions/download-artifact@master
165+
with:
166+
name: One_case_gerbers
167+
path: gerbers/case
168+
- name: Gets latest created release info
169+
id: latest_release_info
170+
uses: jossef/action-latest-release-info@v1.2.1
171+
env:
172+
GITHUB_TOKEN: ${{ github.token }}
173+
- name: Upload case files
174+
uses: shogo82148/actions-upload-release-asset@v1.6.4
175+
env:
176+
GITHUB_TOKEN: ${{ github.token }}
177+
with:
178+
overwrite: true
179+
upload_url: ${{ steps.latest_release_info.outputs.upload_url }}
180+
asset_path: ./gerbers/case/gerber_case_files.zip
181+
asset_name: gerber_case_files.zip

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Temporary files
2+
*.000
3+
*.bak
4+
*.bck
5+
*.kicad_pcb-bak
6+
*backups*
7+
*~
8+
_autosave-*
9+
*.tmp
10+
*-rescue.lib
11+
*-save.pro
12+
*-save.kicad_pcb
13+
fp-info-cache
14+
*-bak
15+
16+
# Build artifacts
17+
gerbers/*
18+
images/*
19+
20+
# Unnecessary files
21+
plate/*/*.kicad_prl
22+
bottom/*/*.kicad_prl

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ BOM and Build Guide can be found in [Ergonaut Keyboards Documentation Portal](ht
4040

4141
Firmware can be found in [one-zmk-config](https://github.com/ergonautkb/one-zmk-config) repository.
4242

43+
## Gerbers
44+
45+
| Front | Back |
46+
| ------------------------------------------------ | ---------------------------------------------------- |
47+
| ![front](../../releases/latest/download/pcb.png) | ![back](../../releases/latest/download/pcb_back.png) |
48+
49+
* [JLCPCB](../../releases/latest/download/pcb-JLCPCB_gerbers.zip)
50+
* [PCBWay](../../releases/latest/download/pcb-PCBWay_gerbers.zip)
4351

4452
## Contacts
4553

build.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
container_cmd="docker run -v=$(pwd):/kikit -w=/kikit --rm yaqwsx/kikit:v1.3.0-v7"
4+
container_cmd_draw="docker run -v=$(pwd):/kikit -w=/kikit --rm --entrypoint pcbdraw yaqwsx/kikit:v1.3.0-v7"
5+
6+
# Images
7+
echo "Drawing image files"
8+
mkdir -p images
9+
for option in "pcb" "cases/fr4/bottom" "cases/fr4/plate" "cases/fr4/shield"
10+
do
11+
short_option="$(basename "$option")"
12+
file="$(find $option -type f -name '*.kicad_pcb')"
13+
${container_cmd_draw} plot --style oshpark-purple "$file" images/"$short_option".png >> /dev/null
14+
${container_cmd_draw} plot --style oshpark-purple --side back "$file" images/"$short_option"_back.png >> /dev/null
15+
done
16+
17+
# Gerbers
18+
echo "Generating gerbers"
19+
mkdir -p gerbers
20+
for option in "pcb" "cases/fr4/bottom" "cases/fr4/plate" "cases/fr4/shield"
21+
do
22+
prefix="case"
23+
if [[ "$option" == "pcb" ]]; then
24+
prefix="pcb"
25+
fi
26+
mkdir -p gerbers/"$prefix"
27+
short_option="$(basename "$option")"
28+
file="$(find $option -type f -name '*.kicad_pcb')"
29+
${container_cmd} fab jlcpcb --no-assembly "$file" gerbers/"$short_option-JLCPCB" --no-drc
30+
mv gerbers/"$short_option-JLCPCB"/gerbers.zip gerbers/"$prefix"/"$short_option-JLCPCB"_gerbers.zip
31+
rm -r gerbers/"$short_option-JLCPCB"
32+
${container_cmd} fab pcbway --no-assembly "$file" gerbers/"$short_option-PCBWay" --no-drc
33+
mv gerbers/"$short_option-PCBWay"/gerbers.zip gerbers/"$prefix"/"$short_option-PCBWay"_gerbers.zip
34+
rm -r gerbers/"$short_option-PCBWay"
35+
done
36+
37+
zip -jr gerbers/case/gerber_case_files gerbers/case/

gerbers/fr4-case/bottom-JLCPCB.zip

-308 KB
Binary file not shown.

gerbers/fr4-case/bottom-PCBWay.zip

-308 KB
Binary file not shown.

gerbers/fr4-case/plate-JLCPCB.zip

-133 KB
Binary file not shown.

gerbers/fr4-case/plate-PCBWay.zip

-133 KB
Binary file not shown.

gerbers/fr4-case/shield-JLCPCB.zip

-54.4 KB
Binary file not shown.

gerbers/fr4-case/shield-PCBWay.zip

-54.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)