diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6fa4579d..5340215a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,10 +38,24 @@ jobs: RELEASE_VERSION=${{ env.RELEASE_VERSION }} if [[ -z ${RELEASE_VERSION} ]]; then git fetch --tags - RELEASE_VERSION=$(git tag --sort=v:refname -l v* | tail -1) + RELEASE_VERSION=$(git tag --sort=v:refname -l v* | tail -1) # v1.1.3 + version="${RELEASE_VERSION#v}" + + IFS='.' read -ra version_parts <<< "$version" + + major_version=${version_parts[0]} + minor_version=${version_parts[1]} + patch_version=${version_parts[2]} + + patch_version=$((patch_version + 1)) + + new_version="$major_version.$minor_version.$patch_version" + RELEASE_VERSION="${new_version}rc" #1.1.4rc fi RELEASE_VERSION=${RELEASE_VERSION#v} - echo "RELEASE_VERSION=${RELEASE_VERSION}" + RELEASE_NO="$(date +%Y%m%d).$(git rev-parse --short HEAD)" + + echo "RELEASE_VERSION=${RELEASE_VERSION} RELEASE_NO=${RELEASE_NO}" # parse BUILD_IMAGE and OS from IMAGE BUILD_IMAGE=${IMAGE/_/:} @@ -52,7 +66,8 @@ jobs: echo "BUILD_IMAGE=${BUILD_IMAGE}" echo "OS=${OS}" - docker buildx build --build-arg BUILD_IMAGE=${BUILD_IMAGE} --build-arg OS=${OS} --build-arg RELEASE_VERSION=${RELEASE_VERSION} -f .github/workflows/release/Dockerfile --platform=${{ matrix.platforms }} -o releases/ . + + docker buildx build --build-arg BUILD_IMAGE=${BUILD_IMAGE} --build-arg OS=${OS} --build-arg RELEASE_VERSION=${RELEASE_VERSION} --build-arg RELEASE_NO=${RELEASE_NO} -f .github/workflows/release/Dockerfile --platform=${{ matrix.platforms }} -o releases/ . # remove unused package if [[ "${OS}" =~ "ubuntu" ]]; then diff --git a/.github/workflows/release/Dockerfile b/.github/workflows/release/Dockerfile index e1644ab7..1f507600 100644 --- a/.github/workflows/release/Dockerfile +++ b/.github/workflows/release/Dockerfile @@ -18,7 +18,8 @@ WORKDIR /src COPY . . ARG OS ARG RELEASE_VERSION -RUN ls -l /src && chmod 755 .github/workflows/release/build.sh && .github/workflows/release/build.sh ${OS} ${RELEASE_VERSION} +ARG RELEASE_NO +RUN ls -l /src && chmod 755 .github/workflows/release/build.sh && .github/workflows/release/build.sh ${OS} ${RELEASE_VERSION} ${RELEASE_NO} FROM scratch AS release COPY --from=builder /src/build/overlaybd-*.* / diff --git a/.github/workflows/release/build.sh b/.github/workflows/release/build.sh index 608ed69f..c5b8a71a 100644 --- a/.github/workflows/release/build.sh +++ b/.github/workflows/release/build.sh @@ -17,6 +17,7 @@ OS=${1} PACKAGE_VERSION=${2} +RELEASE_NO=${3} ARCH=`uname -m` BUILD_TYPE="Release" COMPILER="" @@ -24,6 +25,7 @@ PACKAGE_RELEASE="" CMAKE="cmake" CPACK="cpack" + # Install Dependencies if [[ ${OS} =~ "ubuntu" ]]; then export DEBIAN_FRONTEND="noninteractive" @@ -33,20 +35,20 @@ if [[ ${OS} =~ "ubuntu" ]]; then apt-get install -y uuid-dev libjson-c-dev libkmod-dev libsystemd-dev autoconf automake libtool libpci-dev nasm libzstd-dev libext2fs-dev zlib1g-dev DISTRO=${OS/:/1~} - PACKAGE_RELEASE="-DPACKAGE_RELEASE=0${DISTRO}" + PACKAGE_RELEASE="-DPACKAGE_RELEASE=${RELEASE_NO}.${DISTRO}" elif [[ ${OS} =~ "centos" ]]; then if [[ ${OS} == "centos:7" ]]; then yum install -y centos-release-scl yum install -y devtoolset-7-gcc-c++ export PATH="/opt/rh/devtoolset-7/root/usr/bin:$PATH" - PACKAGE_RELEASE="-DPACKAGE_RELEASE=1.el7" + PACKAGE_RELEASE="-DPACKAGE_RELEASE=${RELEASE_NO}.el7" COMPILER="-DCMAKE_C_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/gcc -DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/g++" elif [[ ${OS} == "centos:8" ]]; then rm -rf /etc/yum.repos.d/* && curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo yum install -y gcc gcc-c++ - PACKAGE_RELEASE="-DPACKAGE_RELEASE=1.el8" + PACKAGE_RELEASE="-DPACKAGE_RELEASE=${RELEASE_NO}.el8" fi yum install -y epel-release libaio-devel libcurl-devel openssl-devel libnl3-devel e2fsprogs-devel @@ -57,7 +59,7 @@ elif [[ ${OS} =~ "mariner" ]]; then yum install -y rpm-build make git wget sudo tar gcc gcc-c++ autoconf automake libtool DISTRO=${OS/:/.} - PACKAGE_RELEASE="-DPACKAGE_RELEASE=1.${DISTRO}" + PACKAGE_RELEASE="-DPACKAGE_RELEASE=${RELEASE_NO}.${DISTRO}" fi if [[ ${ARCH} == "x86_64" ]]; then diff --git a/CMake/pack.cmake b/CMake/pack.cmake index 136be812..4ad3bfc9 100644 --- a/CMake/pack.cmake +++ b/CMake/pack.cmake @@ -13,9 +13,12 @@ set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}") set(CPACK_RPM_PACKAGE_LICENSE "Apache v2.0") +set(CPACK_RPM_PACKAGE_RELEASE ${PACKAGE_RELEASE}) set(CPACK_RPM_PACKAGE_SUMMARY "Overlaybd backtore for tcmu") set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_RPM_PACKAGE_SUMMARY}) +set(CPACK_DEBIAN_PACKAGE_VERSION "${PACKAGE_VERSION}-${PACKAGE_RELEASE}") + set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)