What’s the use case and why even to semantic versioning on pcbs?
Semantic versioning for PCBs maks ist simpler so track changes, compatibility, and revisions for a single product. This also maks it simpler to map a pcb revision to a software revision.
GitLab CiCd Setup
Versioning is mainly done in two jobs, one that checks if everything is set accordingly and a second one that generates the gerber files.
Job for validating if placeholder Tag is present
As a precaution to ensure later jobs can operate without any problems, the test in each commit ensure that the placeholder Tag is present and has no spelling error.
checkSemanticVersioning:
image: ubuntu:20.04
stage: testing
script:
- SEARCH_STRING="SemVrsTemp"
- |
found=false
for file in *.kicad_pcb; do
if grep -q "$SEARCH_STRING" "$file"; then
echo "placeholder found in $file"
found=true
fi
done
# Fail the pipeline if the string wasn't found in any file
if [ "$found" = false ]; then
echo "Versioning placeholder not found in any .kicad_pcb files"
exit 1
fi
Replacing tag and outputting gerber
For generating the gerber file KiBot is used. Before the KiBot is run to grate the final files, a simple find and replace operation is run, that searches the kicad pcb files and replaces all found placeholders with the Git Tag that triggered the pipeline job.
pcb_outputs:
image: $KICAD_VERSION
stage: gen_fab
script:
- FILE_PATH="*.kicad_pcb"
- SEARCH_STRING="SemVrsTemp"
- REPLACE_STRING=$CI_COMMIT_TAG
# Check if the string exists and replace it if found
- |
for file in $FILE_PATH; do
if grep -q "$SEARCH_STRING" "$file"; then
echo "Found '$SEARCH_STRING' in $file, replacing it with '$REPLACE_STRING'."
sed -i "s/$SEARCH_STRING/$REPLACE_STRING/g" "$file" # Replace the string
else
echo "String '$SEARCH_STRING' not found in $file."
fi
done
- "[ -f *.kicad_pcb ] && kibot -c output.kibot.yaml"
- echo BUILD_JOB_ID=$CI_JOB_ID >> CI_JOB_ID.env
only:
refs:
- tags
artifacts:
paths:
- Fabrication/
reports:
dotenv: CI_JOB_ID.env
Result
In the first screenshot you cna spot the placeholder tag in the bottom right corner.
The placeholder Tag has this size to accommodate for tags liker 1.0.0-alpha
or 1.0.0-bete
. even though
not recommend, to mey research this is a valid approach to do semantic versioning, so i wanted it to be supported, or
better not to cause problems.
The outputted gerber files (here visualized in the Aisler PCB explorer) shows the git that that
was used to generate this release and start the GitLab CiCd pipeline.