From 4ee393c3a26aa3a497e73840e7c714eb0591c0c2 Mon Sep 17 00:00:00 2001 From: Ben McLean Date: Fri, 4 Oct 2024 21:48:46 +1000 Subject: [PATCH 1/5] Add position file option --- .github/workflows/build.yml | 1 - .github/workflows/test.yml | 35 +++++++++++++++++++++++++++++++++++ README.md | 4 ++++ action.template.yml | 5 +++++ entrypoint.sh | 19 ++++++++++++++++--- 5 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 246c2bd..1246788 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: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0641fa8 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,35 @@ +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: action.template.yml + result_path: action.yml + vars: | + image: Dockerfile + - uses: ./ + with: + input-files: proj/src-kicad/icezum.kicad_pcb + output-directory: out + position-format: gerber + - uses: actions/upload-artifact@v4 + with: + name: test-gerber + path: out/ \ No newline at end of file diff --git a/README.md b/README.md index d582276..1c37036 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,10 @@ Generates gerber & drill files for a specified PCB and places them in a specifie The directory in which to place the gerber & drill files. Default "gerber". +### `position-format` + +The position format to use. Options are gerber, csv, ascii, and none. Default "none". + ## Example usage ``` uses: BenMMcLean/KicadGerber@v1 diff --git a/action.template.yml b/action.template.yml index 3e89c5a..f6b8805 100644 --- a/action.template.yml +++ b/action.template.yml @@ -9,12 +9,17 @@ inputs: description: 'The directory in which to place the output' required: false default: "gerber" + position-format: + description: 'The position format to use. Options are gerber, csv, ascii, and none' + required: false + default: "none" runs: using: 'docker' image: '{{ .image }}' args: - ${{`{{ inputs.input-file }}`}} - ${{`{{ inputs.output-directory }}`}} + - ${{`{{ inputs.position-format }}`}} branding: icon: 'cpu' color: 'green' \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index a424941..3c53bf2 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,18 @@ #!/bin/sh -l -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="$2" +input="$1" +placement_format="${3:-ascii}" + +filename=$(basename -- "$output") + +mkdir -p "$output" +kicad-cli pcb export drill -o "$output" "$input" +kicad-cli pcb export gerbers -o "$output" "$input" + +if [[ "$placement_format" == "ascii" || "$placement_format" == "csv" ]]; then + kicad-cli pcb export pos --format "$placement_format" -o "$output" "$input" +elif [[ "$placement_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 From d4041d367bc8fca2bfeb3dcd7d12c7df175bcee8 Mon Sep 17 00:00:00 2001 From: Ben McLean Date: Fri, 4 Oct 2024 21:51:45 +1000 Subject: [PATCH 2/5] Add back link to workspace --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 3c53bf2..dc08c81 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/sh -l -output="$2" -input="$1" +output="/github/workspace/$2" +input="/github/workspace/$1" placement_format="${3:-ascii}" filename=$(basename -- "$output") From 85407cc388fc1a020ac79d2a68bc1862f71a1dbb Mon Sep 17 00:00:00 2001 From: Ben McLean Date: Fri, 4 Oct 2024 21:54:29 +1000 Subject: [PATCH 3/5] Correct test --- .github/workflows/test.yml | 2 +- entrypoint.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0641fa8..5cb8d47 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: image: Dockerfile - uses: ./ with: - input-files: proj/src-kicad/icezum.kicad_pcb + input-file: proj/src-kicad/icezum.kicad_pcb output-directory: out position-format: gerber - uses: actions/upload-artifact@v4 diff --git a/entrypoint.sh b/entrypoint.sh index dc08c81..88f18ac 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/sh -l +#!/bin/bash output="/github/workspace/$2" input="/github/workspace/$1" From 1d70ae7a5a10dea7fd40bf25a01f6fa085f9070d Mon Sep 17 00:00:00 2001 From: Ben McLean Date: Fri, 4 Oct 2024 21:58:02 +1000 Subject: [PATCH 4/5] Use the input file for output file name --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 88f18ac..a26537f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,7 +4,7 @@ output="/github/workspace/$2" input="/github/workspace/$1" placement_format="${3:-ascii}" -filename=$(basename -- "$output") +filename=$(basename -- "$input") mkdir -p "$output" kicad-cli pcb export drill -o "$output" "$input" From a331fabf151fc93bd7f40661f3cd0e210617766b Mon Sep 17 00:00:00 2001 From: Ben McLean Date: Fri, 4 Oct 2024 22:03:20 +1000 Subject: [PATCH 5/5] Get just the filename part --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index a26537f..0c7cc23 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,7 +4,7 @@ output="/github/workspace/$2" input="/github/workspace/$1" placement_format="${3:-ascii}" -filename=$(basename -- "$input") +filename="$(basename -- "$input" .${input##*.})" mkdir -p "$output" kicad-cli pcb export drill -o "$output" "$input"