diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 336c564..7a6e585 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,6 @@ jobs: uses: gittools/actions/gitversion/execute@v0.9.6 with: useConfigFile: true - showConfig: true configFilePath: ./gitversion.yml - name: Display SemVer run: | @@ -98,12 +97,23 @@ jobs: id: render_template uses: chuhlomin/render-template@v1 with: - template: action.template.yml + template: templates/action.template.yml result_path: action.yml vars: | - image: ghcr.io/${{ env.REPOSITORY_LC }}:${{ needs.version.outputs.version }} + image: docker://ghcr.io/${{ env.REPOSITORY_LC }}:${{ needs.version.outputs.version }} + - name: Update README.md + uses: recih/template-render-action@v1.0.2 + env: + ACTION_REPO: ${{ github.repository }} + ACTION_VERSION: ${{ needs.version.outputs.version }} + with: + template-file: templates/README.template.md + output-file: README.md + engine: mustache - uses: stefanzweifel/git-auto-commit-action@v5 id: auto-commit + with: + commit_message: "Update metadata for ${{ github.event.commits[0].message }}" release-main: runs-on: ubuntu-latest needs: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..71ba468 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,51 @@ +name: Test + +on: + pull_request: + push: + branches: [ master, main, develop ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - uses: actions/checkout@v2 + with: + repository: FPGAwars/icezum + ref: dbad423670419b82018bf6e33c418fc35558c1be + path: proj + - name: Render template + id: render_template + uses: chuhlomin/render-template@v1 + with: + template: templates/action.template.yml + result_path: action.yml + vars: | + image: Dockerfile + - uses: ./ + with: + input-file: proj/src-kicad/icezum.kicad_pcb + output-directory: out + position-format: gerber + - uses: actions/upload-artifact@v4 + with: + name: test-gerber + path: out/ + test-readme-generation: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Update README.md + uses: recih/template-render-action@v1.0.2 + env: + ACTION_REPO: ${{ github.repository }} + ACTION_VERSION: v1.0.0 + with: + template-file: templates/README.template.md + output-file: README.md + engine: mustache + - name: Cat + run: cat README.md \ No newline at end of file diff --git a/README.md b/README.md index d582276..0c4f419 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,21 @@ -# KicadGerber Action +# kicad-gerber Action Generates gerber & drill files for a specified PCB and places them in a specified directory ## Inputs -### `input-file` - -**Required** The PCB to process - -### `output-directory` - -The directory in which to place the gerber & drill files. Default "gerber". +| Input | Required | Description | Default | +|-------------------- |---------- |------------------------------------------------------------------------------------------------------------------- |---------- | +| `input-file` | ✅ | The PCB to process | | +| `output-directory` | | The directory in which to place the gerber & drill files | gerber | +| `drill-format` | | The drill format to use. Options are gerber, excellon, and none | excellon | +| `drill-units` | | The units to use for the drill file. Options are in, and mm. Does nothing if drill format is none or gerber | mm | +| `position-format` | | The position format to use. Options are gerber, csv, ascii, and none | none | +| `position-units` | | The units to use for the position file. Options are in, and mm. Does nothing if position format is none or gerber | in | ## Example usage ``` -uses: BenMMcLean/KicadGerber@v1 +uses: emilymclean/kicad-gerber@v2.0.6 with: input-file: pcb.kicad_pcb ``` diff --git a/action.template.yml b/action.template.yml deleted file mode 100644 index 3e89c5a..0000000 --- a/action.template.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: 'KiCad Gerber' -author: 'Emily McLean' -description: 'Generates gerber & drill files for a specified KiCad PCB and places them in a specified directory' -inputs: - input-file: - description: 'The PCB file to process' - required: true - output-directory: - description: 'The directory in which to place the output' - required: false - default: "gerber" -runs: - using: 'docker' - image: '{{ .image }}' - args: - - ${{`{{ inputs.input-file }}`}} - - ${{`{{ inputs.output-directory }}`}} -branding: - icon: 'cpu' - color: 'green' \ No newline at end of file diff --git a/action.yml b/action.yml index 5961287..c401b3e 100644 --- a/action.yml +++ b/action.yml @@ -9,12 +9,32 @@ inputs: description: 'The directory in which to place the output' required: false default: "gerber" + drill-format: + description: 'The drill format to use. Options are gerber, excellon, and none.' + required: false + default: "excellon" + drill-units: + description: 'The units to use for the drill file. Options are in, and mm. Does nothing if drill format is none or gerber.' + required: false + default: "mm" + position-format: + description: 'The position format to use. Options are gerber, csv, ascii, and none' + required: false + default: "none" + position-units: + description: 'The units to use for the position file. Options are in, and mm. Does nothing if position format is none or gerber.' + required: false + default: "in" runs: using: 'docker' - image: 'ghcr.io/benmmclean/kicadgerber:1.1.0-alpha.30' + image: 'docker://ghcr.io/emilymclean/kicad-gerber:2.0.6' args: - ${{ inputs.input-file }} - ${{ inputs.output-directory }} + - ${{ inputs.drill-format }} + - ${{ inputs.drill-units }} + - ${{ inputs.position-format }} + - ${{ inputs.position-units }} branding: icon: 'cpu' color: 'green' \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index a424941..4f5f512 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,24 @@ -#!/bin/sh -l +#!/bin/bash -mkdir -p /github/workspace/$2 -kicad-cli pcb export drill -o /github/workspace/$2 /github/workspace/$1 -kicad-cli pcb export gerbers -o /github/workspace/$2 /github/workspace/$1 \ No newline at end of file +output="/github/workspace/$2" +input="/github/workspace/$1" +drill_format="${3:-excellon}" +drill_units="${4:-mm}" +position_format="${5:-ascii}" +position_units="${6:-in}" + +filename="$(basename -- "$input" .${input##*.})" + +mkdir -p "$output" +kicad-cli pcb export gerbers -o "$output" "$input" + +if [[ "$drill_format" == "excellon" || "$drill_format" == "gerber" ]]; then + kicad-cli pcb export drill --format "$drill_format" --excellon-units "$drill_units" -o "$output" "$input" +fi + +if [[ "$position_format" == "ascii" || "$position_format" == "csv" ]]; then + kicad-cli pcb export pos --format "$position_format" --units "$drill_units" -o "$output/$filename.pos" "$input" +elif [[ "$position_format" == "gerber" ]]; then + kicad-cli pcb export pos --format gerber --side front -o "$output/$filename.front.pos" "$input" + kicad-cli pcb export pos --format gerber --side back -o "$output/$filename.back.pos" "$input" +fi \ No newline at end of file diff --git a/templates/README.template.md b/templates/README.template.md new file mode 100644 index 0000000..2237299 --- /dev/null +++ b/templates/README.template.md @@ -0,0 +1,21 @@ +# kicad-gerber Action + +Generates gerber & drill files for a specified PCB and places them in a specified directory + +## Inputs + +| Input | Required | Description | Default | +|-------------------- |---------- |------------------------------------------------------------------------------------------------------------------- |---------- | +| `input-file` | ✅ | The PCB to process | | +| `output-directory` | | The directory in which to place the gerber & drill files | gerber | +| `drill-format` | | The drill format to use. Options are gerber, excellon, and none | excellon | +| `drill-units` | | The units to use for the drill file. Options are in, and mm. Does nothing if drill format is none or gerber | mm | +| `position-format` | | The position format to use. Options are gerber, csv, ascii, and none | none | +| `position-units` | | The units to use for the position file. Options are in, and mm. Does nothing if position format is none or gerber | in | + +## Example usage +``` +uses: {{{ env.ACTION_REPO }}}@v{{{ env.ACTION_VERSION }}} +with: + input-file: pcb.kicad_pcb +``` diff --git a/templates/action.template.yml b/templates/action.template.yml new file mode 100644 index 0000000..8b23074 --- /dev/null +++ b/templates/action.template.yml @@ -0,0 +1,40 @@ +name: 'KiCad Gerber' +author: 'Emily McLean' +description: 'Generates gerber & drill files for a specified KiCad PCB and places them in a specified directory' +inputs: + input-file: + description: 'The PCB file to process' + required: true + output-directory: + description: 'The directory in which to place the output' + required: false + default: "gerber" + drill-format: + description: 'The drill format to use. Options are gerber, excellon, and none.' + required: false + default: "excellon" + drill-units: + description: 'The units to use for the drill file. Options are in, and mm. Does nothing if drill format is none or gerber.' + required: false + default: "mm" + position-format: + description: 'The position format to use. Options are gerber, csv, ascii, and none' + required: false + default: "none" + position-units: + description: 'The units to use for the position file. Options are in, and mm. Does nothing if position format is none or gerber.' + required: false + default: "in" +runs: + using: 'docker' + image: '{{ .image }}' + args: + - ${{`{{ inputs.input-file }}`}} + - ${{`{{ inputs.output-directory }}`}} + - ${{`{{ inputs.drill-format }}`}} + - ${{`{{ inputs.drill-units }}`}} + - ${{`{{ inputs.position-format }}`}} + - ${{`{{ inputs.position-units }}`}} +branding: + icon: 'cpu' + color: 'green' \ No newline at end of file