-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Keep hash of kicad schematics to check for actual changes before …
…export to omit just changing timestamps.
- Loading branch information
Showing
2 changed files
with
28 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,45 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
EXPORT_ROOT_DIR="export" | ||
EXPORT_SVG_DIR="${EXPORT_ROOT_DIR}/svg" | ||
EXPORT_SVG_DIR="$EXPORT_ROOT_DIR/svg" | ||
HASH_FILE="$EXPORT_ROOT_DIR/.kicad_sch_hash" | ||
|
||
PROJECT_NAME=${1} | ||
KICAD_SCH="${PROJECT_NAME}.kicad_sch" | ||
PROJECT_NAME=$1 | ||
KICAD_SCH="$PROJECT_NAME.kicad_sch" | ||
|
||
echo "📄 Exporting $KICAD_SCH" | ||
|
||
echo "🔎 Checking schematic for changes..." | ||
OLD_HASH=$(test -f "$HASH_FILE" && cat "$HASH_FILE" || echo "0") | ||
NEW_HASH=$(find -type f -iname "*.kicad_sch" | sort | xargs sha256sum | sha256sum | head --bytes 64) | ||
|
||
if [ $OLD_HASH == $NEW_HASH ]; then | ||
echo "... no changes detected." | ||
echo "✅ Skipped export." | ||
exit 0 | ||
fi | ||
|
||
echo "📄 Exporting ${KICAD_SCH}" | ||
echo "⚠️ Old files will be removed first!" | ||
rm --force --recursive $EXPORT_ROOT_DIR | ||
mkdir --parent $EXPORT_ROOT_DIR | ||
|
||
rm --force --recursive ${EXPORT_ROOT_DIR} | ||
echo "🧮 Wriing new hash to file." | ||
echo "$NEW_HASH" > $HASH_FILE | ||
|
||
mkdir -p ${EXPORT_ROOT_DIR} | ||
echo "📃 Exporting to PDF." | ||
mkdir -p $EXPORT_ROOT_DIR | ||
eeschema_do export \ | ||
--all_pages \ | ||
--file_format pdf\ | ||
${KICAD_SCH} ${EXPORT_ROOT_DIR} | ||
$KICAD_SCH $EXPORT_ROOT_DIR | ||
|
||
mkdir -p ${EXPORT_SVG_DIR} | ||
echo "🖼️ Exporting to SVG." | ||
mkdir -p $EXPORT_SVG_DIR | ||
eeschema_do export \ | ||
--all_pages \ | ||
--file_format svg \ | ||
--background_color \ | ||
${KICAD_SCH} ${EXPORT_SVG_DIR} | ||
$KICAD_SCH $EXPORT_SVG_DIR | ||
|
||
echo "✅ Done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
f1dd10bfc7028ffe029f4f35cd2ee310f693cbd35de397462842279c374dfb57 |