diff --git a/.gitmodules b/.gitmodules index 02916e8..61ed493 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,3 +2,7 @@ path = kicad-footprint-generator url = git@gitlab.com:acmelon/kicad-footprint-generator.git branch = offset_fix +[submodule ".scripts/ki-ntree"] + path = .scripts/ki-ntree + url = https://github.com/Andrew-Collins/Ki-nTree + branch = cli diff --git a/.scripts/ki-ntree b/.scripts/ki-ntree new file mode 160000 index 0000000..316a11d --- /dev/null +++ b/.scripts/ki-ntree @@ -0,0 +1 @@ +Subproject commit 316a11d0da0ca59095148f38f2c6fe77b4d71948 diff --git a/kibot-ci.yml b/kibot-ci.yml index 8c356ad..57686d4 100644 --- a/kibot-ci.yml +++ b/kibot-ci.yml @@ -15,6 +15,7 @@ variables: stages: - gen_mech - gen_fab + - inventree - upload - release @@ -33,6 +34,8 @@ image: - if: $CI_COMMIT_BRANCH == "dev" .commands: + get_tag: + - TAG=$(echo ${CI_COMMIT_MESSAGE} | tr -d \\n) get_files: - FILES=$(find . -name *$SEARCH -not -path "./.gitlab/*") get_dirs: @@ -124,12 +127,29 @@ image: python3 $CI_PROJECT_DIR/.gitlab/.scripts/neo.py $d done + boms: + - cd $CI_PROJECT_DIR/.gitlab/.scripts/ki-ntree/ + - poetry install + - cd $CI_PROJECT_DIR/Fabrication + - 'SEARCH="bom.csv"' + - !reference [.commands, get_tag] + - !reference [.commands, get_files] + - cd $CI_PROJECT_DIR/.gitlab/.scripts/ki-ntree/ + - | + for f in $FILES + do + echo $f + name=$(echo $f | cut -d'-' -f1)A + poetry run python -m kintree_cli -p $f --assembly "{'ipn': '$name', 'rev': '$TAG'}" --settings_inv $KINTREE_SETT_INV --settings_ipn $KINTREE_SETT_IPN + done + + git_tag: + - !reference [.commands, get_tag] - | if [[ $GITLAB_CI == 'true' && $CI_COMMIT_BRANCH == "main" ]]; then - TAG=$(echo ${CI_COMMIT_MESSAGE} | tr -d \\n) echo "running git tag" - git tag $CI_COMMIT_MESSAGE + git tag $TAG elif [[ $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" && "$CI_MERGE_REQUEST_TITLE" =~ [^a-zA-Z0-9.-_] ]]; then exit 1 fi @@ -230,6 +250,17 @@ outputs_all: - !reference [.commands, neo] - ls Fabrication/ +inventree_job: + stage: inventree + needs: + - job: outputs_all + artifacts: true + rules: + - if: $CI_COMMIT_TAG + when: never # Do not run this job when a tag is created manually + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when commits are pushed or merged to the default branch + script: + - !reference [.commands, boms] upload_job: stage: upload