diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 89aec5bdb4db0080f7c9a04fda28c7c31dd4c2ef..fcada46e5f6dd99be641559a6e2228020fae2ebb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -93,6 +93,69 @@ bundle-raspberrypi4-64: CI_ONIRO_BUILD_FLAVOUR: linux CI_ONIRO_RECIPE_NAME: oniro-bundle-base +publish-raspberrypi4-64: + # TODO: switch to zygoon/hawkbitctl + # blocked by https://gitlab.com/zygoon/go-hawkbit/-/issues/26 + image: golang:latest + stage: update + dependencies: [bundle-raspberrypi4-64] + needs: [bundle-raspberrypi4-64] + variables: + CI_ONIRO_HAWKBIT_SWMOD_NAME: oniro-bundle-base-raspberrypi4-64 + CI_ONIRO_HAWKBIT_DS_NAME: oniro-image-base-raspberrypi4-64 + CI_ONIRO_RAUC_BUNDLE_NAME: oniro-bundle-base + MACHINE: raspberrypi4-64 + script: | + - test -n "${HAWKBIT_URL:-}" || ( + echo "precondition failed - HAWKBIT_URL is not set" + && exit 1 ) + - test -n "${HAWKBIT_USERNAME:-}" || ( + echo "precondition failed - HAWKBIT_USERNAME is not set" + && exit 1 ) + - test -n "${HAWKBIT_PASSWORD:-}" || ( + echo "precondition failed - HAWKBIT_PASSWORD is not set (should be set with protected and masked variable)" + && exit 1 ) + # TODO: remove this when switching to the dedicated docker container. + - go install gitlab.com/zygoon/go-hawkbit/cmd/hawkbitctl@latest + - test -L "${CI_PROJECT_DIR}/artifacts/images/${MACHINE}/${CI_ONIRO_RAUC_BUNDLE_NAME}-${MACHINE}.raucb")" || ( + echo "precondition failed - bundle file missing or not a symbolic link" + && find "${CI_PROJECT_DIR}/artifacts" + && exit 1 ) + - BUNDLE_FILE="$(readlink "${CI_PROJECT_DIR}/artifacts/images/${MACHINE}/${CI_ONIRO_RAUC_BUNDLE_NAME}-${MACHINE}.raucb")" + - test -n "$BUNDLE_FILE" || ( + echo "BUNDLE_FILE is empty!" + && ls -l "${CI_PROJECT_DIR}/artifacts/images/${MACHINE}/${CI_ONIRO_RAUC_BUNDLE_NAME}-${MACHINE}.raucb" + && exit 1 ) + - BUNDLE_VERSION="$(echo "$CI_BUNDLE_FILE" | awk -e 'BEGIN { RS = "-" } /.*\.raucb/ { sub(".raucb", "", $NF); print $NF }')" + - test -n "$BUNDLE_VERSION" || ( + echo "BUNDLE_VERSION is empty!" + && echo "BUNDLE_FILE=$BUNDLE_FILE" + && exit 1 ) + # TODO: create or find sw mod type for SysOTA + RAUC bundle + - hawkbitctl create software-module \ + -name "$CI_ONIRO_HAWKBIT_SWMOD_NAME" \ + -version "$BUNDLE_VERSION" \ + -type os \ + -vendor Onrio \ + -description "Automatic build from Oniro CI" + # TODO: create or find ds type for Raspberry Pi 4 + Oniro + - hawkbitctl create distribution-set \ + -name "$CI_ONIRO_HAWKBIT_DS_NAME" \ + -version "$BUNDLE_VERSION" \ + -type os_only \ + -modules "$CI_ONIRO_HAWKBIT_SWMOD_NAME:$BUNDLE_VERSION" \ + -description "Automatic build from Oniro CI" + - hawkbitctl upload \ + -m "$CI_ONIRO_HAWKBIT_SWMOD_NAME:$CI_ONIRO_HAWKBIT_SWMOD_VERSION" \ + -a "$BUNDLE_FILE" + rules: + # For merge requests, the publishing is optional and can be triggered manually. + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + when: manual + allow_failure: true + # Publishing is done only for scheduled builds + - if: '$CI_PIPELINE_SOURCE == "schedule"' + .build-wic-image-daily: extends: .build-wic-image variables: