diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a3e2feace3e90808af5708185a9756e0139db4e8..816e4432992cb333fd7d2fe0cff10fad24a225f9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,6 @@ variables: stages: - build - - publish run_build: stage: build @@ -23,24 +22,4 @@ run_build: - cp build/tmp/deploy/images/raspberrypi4-64/update-image-raspberrypi4-64.rootfs.swu meta-pypcc/artifacts/ artifacts: paths: - - artifacts/* - - - -publish_to_hawkbit: - image: - name: alpine/curl - stage: build - when: manual - environment: - name: production - script: - - cd publish - - chmod +x *.sh - - ./create_software_module_with_distset.sh - - ./publish_to_hawkbit.sh - - - - - + - artifacts/* \ No newline at end of file diff --git a/publish/create_software_module_with_distset.sh b/publish/create_software_module_with_distset.sh deleted file mode 100644 index 2855538e69f1618699bd6b358a280488ef8a9134..0000000000000000000000000000000000000000 --- a/publish/create_software_module_with_distset.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/sh - -# Default server URL -DEFAULT_SERVER="https://ota.lofar.net" -SERVER="${1:-$DEFAULT_SERVER}" - -# Software module metadata -MODULE_NAME="Lofar CCD and APSCT Yocto Image" -MODULE_TYPE="os" -MODULE_VENDOR="LOFAR" -MODULE_DESC="Yocto image for Raspberry Pi" - -# Distribution set metadata -DISTSET_NAME="Lofar CCD and APSCT Yocto Image Distribution" -DISTSET_DESC="Distribution set for CCD APSCT Raspberry Pi Yocto images" -DISTSET_TYPE="os_app" # its a full os with apps :) - -# Determine version from GitLab CI or local commit -if [ -n "$CI_COMMIT_TAG" ]; then - MODULE_VERSION="$CI_COMMIT_TAG" -elif [ -n "$CI_COMMIT_SHORT_SHA" ]; then - MODULE_VERSION="dev-${CI_COMMIT_SHORT_SHA}" -else - MODULE_VERSION="dev-$(git rev-parse --short HEAD)" -fi - -echo "Using version: $MODULE_VERSION" - -# urlencode function using jq -urlencode() { - printf '%s' "$1" | jq -sRr @uri -} - -# 1. Check if software module exists and get its ID, using q filter -query_sm="name==\"$MODULE_NAME\";version==\"$MODULE_VERSION\"" -query_sm_enc=$(urlencode "$query_sm") - -modules=$(curl -s -u "$HAWKBITUSER:$HAWKBITPW" \ - "$SERVER/rest/v1/softwaremodules?q=$query_sm_enc&limit=1") - -module_id=$(echo "$modules" | jq -r '.content[0].id // empty') - -if [ -n "$module_id" ]; then - echo "➤ Software module \"$MODULE_NAME\" version \"$MODULE_VERSION\" already exists with ID $module_id." -else - echo "➤ Creating software module \"$MODULE_NAME\" version \"$MODULE_VERSION\"..." - - payload=$(jq -n \ - --arg name "$MODULE_NAME" \ - --arg version "$MODULE_VERSION" \ - --arg type "$MODULE_TYPE" \ - --arg vendor "$MODULE_VENDOR" \ - --arg desc "$MODULE_DESC" \ - '{ name: $name, version: $version, type: $type, vendor: $vendor, description: $desc, encrypted: false }') - - response=$(curl -s -u "$HAWKBITUSER:$HAWKBITPW" \ - -H "Content-Type: application/json" \ - -X POST "$SERVER/rest/v1/softwaremodules" \ - -d "[$payload]") - - module_id=$(echo "$response" | jq -r '.[0].id') - - if [ -z "$module_id" ] || [ "$module_id" = "null" ]; then - echo "❌ ERROR: Failed to create software module or parse module ID" - exit 1 - fi - - echo "➤ Created software module with ID: $module_id" -fi - -# 2. Check if distribution set exists and get its ID, using q filter -query_ds="name==\"$DISTSET_NAME\"" -query_ds_enc=$(urlencode "$query_ds") - -distsets=$(curl -s -u "$HAWKBITUSER:$HAWKBITPW" \ - "$SERVER/rest/v1/distributionsets?q=$query_ds_enc&limit=1") -#echo "$distsets" -distset_id=$(echo "$distsets" | jq -r '.content[0]?.id // empty') - -if [ -n "$distset_id" ]; then - echo "➤ Distribution set \"$DISTSET_NAME\" already exists with ID $distset_id." -else - echo "➤ Creating distribution set \"$DISTSET_NAME\"..." - - # Prepare modules array with module_id converted to number inside jq - modules_array=$(jq -n --arg id "$module_id" '[{id: ($id|tonumber)}]') - - distset_payload=$(jq -n \ - --arg name "$DISTSET_NAME" \ - --arg desc "$DISTSET_DESC" \ - --arg version "$MODULE_VERSION" \ - --arg type "$DISTSET_TYPE" \ - --argjson modules "$modules_array" \ - '{ - name: $name, - description: $desc, - version: $version, - locked: true, - requiredMigrationStep: false, - modules: $modules, - type: $type - }') -#echo "$distset_payload" | jq . - - response=$(curl -s -u "$HAWKBITUSER:$HAWKBITPW" \ - -H "Content-Type: application/json" \ - -X POST "$SERVER/rest/v1/distributionsets" \ - -d "[$distset_payload]") -echo "$response" -distset_id=$(echo "$response" | jq -r '.[0].id') - -if [ -z "$distset_id" ] || [ "$distset_id" = "null" ]; then - echo "❌ ERROR: Failed to create distribution set or parse ID" - exit 1 -fi - -echo "➤ Created distribution set with ID: $distset_id" -fi diff --git a/publish/publsh_to_hawkbit.sh b/publish/publsh_to_hawkbit.sh deleted file mode 100644 index 762b3dcf03a359116420e5fdd2eb619ba32f6674..0000000000000000000000000000000000000000 --- a/publish/publsh_to_hawkbit.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -echo "work in progress" \ No newline at end of file