diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 278ef0d2..9107f661 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -1,6 +1,8 @@ FROM registry.suse.com/bci/golang:1.23 ARG DAPPER_HOST_ARCH +ARG SRC_BRANCH=main +ARG SRC_TAG ARG http_proxy ARG https_proxy @@ -11,6 +13,8 @@ ENV DAPPER_ENV TAG REPO DRONE_REPO DRONE_PULL_REQUEST DRONE_COMMIT_REF ENV DAPPER_OUTPUT bin coverage.out ENV DAPPER_RUN_ARGS --privileged -v /dev:/host/dev -v /proc:/host/proc ENV DAPPER_SOURCE /go/src/github.com/longhorn/longhorn-share-manager +ENV SRC_BRANCH ${SRC_BRANCH} +ENV SRC_TAG ${SRC_TAG} ENV GOLANGCI_LINT_VERSION="v1.60.3" diff --git a/Makefile b/Makefile index 78839b9b..973a11e4 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ TARGETS := $(shell ls scripts) +export SRC_BRANCH := $(shell bash -c 'wget -q "https://raw.githubusercontent.com/longhorn/dep-versions/main/scripts/common.sh" -O build-common.sh && source build-common.sh && get_branch') +export SRC_TAG := $(shell git tag --points-at HEAD | head -n 1) + .dapper: @echo Downloading dapper @curl -sL https://releases.rancher.com/dapper/latest/dapper-`uname -s`-`uname -m` > .dapper.tmp diff --git a/scripts/package b/scripts/package index fc21f872..a7c3ce1b 100755 --- a/scripts/package +++ b/scripts/package @@ -25,42 +25,11 @@ TAG=${TAG:-"v${APIVERSION}_`date -u +%Y%m%d`"} REPO=${REPO:-longhornio} IMAGE=${REPO}/${PROJECT}:${TAG} -function convert_version_to_major_minor_x() { - local version="$1" - if [[ "$version" =~ ^v([0-9]+)\.([0-9]+)\. ]]; then - echo "v${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.x" - else - echo "Invalid version format: $version" - fi -} - -function get_branch() { - local version_file="version" - if [[ ! -f $version_file ]]; then - echo "Error: Version file '$version_file' not found." - exit 1 - fi - - local version=$(cat "$version_file") - local branch=$(convert_version_to_major_minor_x "$version") - - # Fetch versions.json from the appropriate branch, fallback to main - wget -q "https://raw.githubusercontent.com/longhorn/dep-versions/${branch}/versions.json" -O /versions.json - if [ $? -eq 0 ]; then - echo "${branch}" - else - echo "main" - fi -} - -SRC_BRANCH=$(get_branch) -SRC_TAG=$(git tag --points-at HEAD | head -n 1) - # update base image to get latest changes BASE_IMAGE=`grep FROM package/Dockerfile | grep -v AS | awk '{print $2}'` docker pull ${BASE_IMAGE} -echo "Building image ${IMAGE} based on ${BASE_IMAGE}" +echo "Building image ${IMAGE} based on ${BASE_IMAGE} with ARCH=${ARCH} SRC_BRANCH=${SRC_BRANCH} SRC_TAG=${SRC_TAG}" buildx build \ --load \ --build-arg ARCH="${ARCH}" \