diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..b8914cc --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,181 @@ +on: + push: + branches: + - main + paths-ignore: + - '**/README.md' + - '**/LICENSE' + - '**/CHANGES.txt' + - '**/img/*' + pull_request: + branches: + - main + paths-ignore: + - '**/README.md' + - '**/LICENSE' + - '**/CHANGES.txt' + - '**/img/*' + workflow_dispatch: + paths-ignore: + - '**/README.md' + - '**/LICENSE' + - '**/CHANGES.txt' + - '**/img/*' + +env: + DOCKER_USER_OPTION: '$UID:$GID' + +name: Build +jobs: + generate: + runs-on: ubuntu-latest + name: Generate + steps: + - name: Checkout + uses: actions/checkout@v3.5.2 + - uses: xanantis/docker-file-ownership-fix@v1 + - name: Run build script + run: | + chmod +x build.sh + ./build.sh + shell: bash + - name: Persist PCB gerbers + uses: actions/upload-artifact@v3.1.2 + with: + name: One_pcb_gerbers + path: gerbers/pcb + - name: Persist case gerbers + uses: actions/upload-artifact@v3.1.2 + with: + name: One_case_gerbers + path: gerbers/case + - name: Persist images + uses: actions/upload-artifact@v3.1.2 + with: + name: One_images + path: images + + + image_matrix: + runs-on: ubuntu-latest + name: PCB image matrix + needs: generate + outputs: + matrix: ${{ steps.setmatrix.outputs.matrix }} + steps: + - uses: actions/download-artifact@master + with: + name: One_images + path: images + - id: setmatrix + run: | + matrixArray=$(find ./images -name 'pcb*.png' | xargs -n 1 -i echo {} {} | sed 's# .*/# #') # Creates array of all PCB image files + # Start Generate JSON String + echo "$matrixArray" | \ + jq --slurp --raw-input 'split("\n")[:-1] | map(split(" "))' | \ + jq "map({\"filepath\": (.[0]), \"basename\": .[1] })" | \ + jq -sc "{ \"include\": .[] }" > tmp + cat ./tmp + # End Generate JSON String + matrixStringifiedObject=$(cat ./tmp) # Use this as jq @sh wasn't cooperating + echo "matrix=$matrixStringifiedObject" >> $GITHUB_OUTPUT + + gerber_matrix: + runs-on: ubuntu-latest + name: Gerber matrix + needs: generate + outputs: + matrix: ${{ steps.setmatrix.outputs.matrix }} + steps: + - uses: actions/download-artifact@master + with: + name: One_pcb_gerbers + path: gerbers/pcb + - id: setmatrix + run: | + matrixArray=$(find ./gerbers/pcb -name '*.zip' | xargs -n 1 -i echo {} {} | sed 's# .*/# #') # Creates array of all PCB gerber files + # Start Generate JSON String + echo "$matrixArray" | \ + jq --slurp --raw-input 'split("\n")[:-1] | map(split(" "))' | \ + jq "map({\"filepath\": (.[0]), \"basename\": .[1] })" | \ + jq -sc "{ \"include\": .[] }" > tmp + cat ./tmp + # End Generate JSON String + matrixStringifiedObject=$(cat ./tmp) # Use this as jq @sh wasn't cooperating + echo "matrix=$matrixStringifiedObject" >> $GITHUB_OUTPUT + + upload_pcb_gerbers: + runs-on: ubuntu-latest + name: Upload PCB gerbers + needs: [generate, gerber_matrix] + strategy: + matrix: ${{fromJson(needs.gerber_matrix.outputs.matrix)}} + steps: + - uses: actions/download-artifact@master + with: + name: One_pcb_gerbers + path: gerbers/pcb + - name: Gets latest created release info + id: latest_release_info + uses: jossef/action-latest-release-info@v1.2.1 + env: + GITHUB_TOKEN: ${{ github.token }} + - name: Upload gerbers + uses: shogo82148/actions-upload-release-asset@v1.6.4 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + overwrite: true + upload_url: ${{ steps.latest_release_info.outputs.upload_url }} + asset_path: ${{ matrix.filepath }} + asset_name: ${{ matrix.basename }} + + upload_images: + runs-on: ubuntu-latest + name: Upload images + needs: [generate, image_matrix] + strategy: + matrix: ${{fromJson(needs.image_matrix.outputs.matrix)}} + steps: + - uses: actions/download-artifact@master + with: + name: One_images + path: images + - name: Gets latest created release info + id: latest_release_info + uses: jossef/action-latest-release-info@v1.2.1 + env: + GITHUB_TOKEN: ${{ github.token }} + - name: Upload images + uses: shogo82148/actions-upload-release-asset@v1.6.4 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + overwrite: true + upload_url: ${{ steps.latest_release_info.outputs.upload_url }} + asset_path: ${{ matrix.filepath }} + asset_name: ${{ matrix.basename }} + + upload_gerber_case_files: + runs-on: ubuntu-latest + name: Upload case gerber files + needs: generate + steps: + - uses: actions/download-artifact@master + with: + name: One_case_gerbers + path: gerbers/case + - name: Gets latest created release info + id: latest_release_info + uses: jossef/action-latest-release-info@v1.2.1 + env: + GITHUB_TOKEN: ${{ github.token }} + - name: Upload case files + uses: shogo82148/actions-upload-release-asset@v1.6.4 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + overwrite: true + upload_url: ${{ steps.latest_release_info.outputs.upload_url }} + asset_path: ./gerbers/case/gerber_case_files.zip + asset_name: gerber_case_files.zip diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9968674 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# Temporary files +*.000 +*.bak +*.bck +*.kicad_pcb-bak +*backups* +*~ +_autosave-* +*.tmp +*-rescue.lib +*-save.pro +*-save.kicad_pcb +fp-info-cache +*-bak + +# Build artifacts +gerbers/* +images/* + +# Unnecessary files +plate/*/*.kicad_prl +bottom/*/*.kicad_prl diff --git a/README.md b/README.md index 4707412..60716d1 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,14 @@ BOM and Build Guide can be found in [Ergonaut Keyboards Documentation Portal](ht Firmware can be found in [one-zmk-config](https://github.com/ergonautkb/one-zmk-config) repository. +## Gerbers + +| Front | Back | +| ------------------------------------------------ | ---------------------------------------------------- | +| ![front](../../releases/latest/download/pcb.png) | ![back](../../releases/latest/download/pcb_back.png) | + +* [JLCPCB](../../releases/latest/download/pcb-JLCPCB_gerbers.zip) +* [PCBWay](../../releases/latest/download/pcb-PCBWay_gerbers.zip) ## Contacts diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..02319a8 --- /dev/null +++ b/build.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +container_cmd="docker run -v=$(pwd):/kikit -w=/kikit --rm yaqwsx/kikit:v1.3.0-v7" +container_cmd_draw="docker run -v=$(pwd):/kikit -w=/kikit --rm --entrypoint pcbdraw yaqwsx/kikit:v1.3.0-v7" + +# Images +echo "Drawing image files" +mkdir -p images +for option in "pcb" "cases/fr4/bottom" "cases/fr4/plate" "cases/fr4/shield" +do + short_option="$(basename "$option")" + file="$(find $option -type f -name '*.kicad_pcb')" + ${container_cmd_draw} plot --style oshpark-purple "$file" images/"$short_option".png >> /dev/null + ${container_cmd_draw} plot --style oshpark-purple --side back "$file" images/"$short_option"_back.png >> /dev/null +done + +# Gerbers +echo "Generating gerbers" +mkdir -p gerbers +for option in "pcb" "cases/fr4/bottom" "cases/fr4/plate" "cases/fr4/shield" +do + prefix="case" + if [[ "$option" == "pcb" ]]; then + prefix="pcb" + fi + mkdir -p gerbers/"$prefix" + short_option="$(basename "$option")" + file="$(find $option -type f -name '*.kicad_pcb')" + ${container_cmd} fab jlcpcb --no-assembly "$file" gerbers/"$short_option-JLCPCB" --no-drc + mv gerbers/"$short_option-JLCPCB"/gerbers.zip gerbers/"$prefix"/"$short_option-JLCPCB"_gerbers.zip + rm -r gerbers/"$short_option-JLCPCB" + ${container_cmd} fab pcbway --no-assembly "$file" gerbers/"$short_option-PCBWay" --no-drc + mv gerbers/"$short_option-PCBWay"/gerbers.zip gerbers/"$prefix"/"$short_option-PCBWay"_gerbers.zip + rm -r gerbers/"$short_option-PCBWay" +done + +zip -jr gerbers/case/gerber_case_files gerbers/case/ diff --git a/gerbers/fr4-case/bottom-JLCPCB.zip b/gerbers/fr4-case/bottom-JLCPCB.zip deleted file mode 100644 index 91eb160..0000000 Binary files a/gerbers/fr4-case/bottom-JLCPCB.zip and /dev/null differ diff --git a/gerbers/fr4-case/bottom-PCBWay.zip b/gerbers/fr4-case/bottom-PCBWay.zip deleted file mode 100644 index e7d14c2..0000000 Binary files a/gerbers/fr4-case/bottom-PCBWay.zip and /dev/null differ diff --git a/gerbers/fr4-case/plate-JLCPCB.zip b/gerbers/fr4-case/plate-JLCPCB.zip deleted file mode 100644 index 262f44f..0000000 Binary files a/gerbers/fr4-case/plate-JLCPCB.zip and /dev/null differ diff --git a/gerbers/fr4-case/plate-PCBWay.zip b/gerbers/fr4-case/plate-PCBWay.zip deleted file mode 100644 index d4c4b3b..0000000 Binary files a/gerbers/fr4-case/plate-PCBWay.zip and /dev/null differ diff --git a/gerbers/fr4-case/shield-JLCPCB.zip b/gerbers/fr4-case/shield-JLCPCB.zip deleted file mode 100644 index 110195f..0000000 Binary files a/gerbers/fr4-case/shield-JLCPCB.zip and /dev/null differ diff --git a/gerbers/fr4-case/shield-PCBWay.zip b/gerbers/fr4-case/shield-PCBWay.zip deleted file mode 100644 index 49c3817..0000000 Binary files a/gerbers/fr4-case/shield-PCBWay.zip and /dev/null differ diff --git a/gerbers/pcb/pcb-JLCPCB.zip b/gerbers/pcb/pcb-JLCPCB.zip deleted file mode 100644 index 32888b9..0000000 Binary files a/gerbers/pcb/pcb-JLCPCB.zip and /dev/null differ diff --git a/gerbers/pcb/pcb-PCBWay.zip b/gerbers/pcb/pcb-PCBWay.zip deleted file mode 100644 index 140a21e..0000000 Binary files a/gerbers/pcb/pcb-PCBWay.zip and /dev/null differ