Skip to content

Commit

Permalink
Merge pull request #325 from BigVan/main
Browse files Browse the repository at this point in the history
[CI/CD] add 'release number' and 'pre-release' version
  • Loading branch information
yuchen0cc authored Apr 23, 2024
2 parents 512fe49 + 00cd32c commit 27b69e9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/_/:}
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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-*.* /
10 changes: 6 additions & 4 deletions .github/workflows/release/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@

OS=${1}
PACKAGE_VERSION=${2}
RELEASE_NO=${3}
ARCH=`uname -m`
BUILD_TYPE="Release"
COMPILER=""
PACKAGE_RELEASE=""
CMAKE="cmake"
CPACK="cpack"


# Install Dependencies
if [[ ${OS} =~ "ubuntu" ]]; then
export DEBIAN_FRONTEND="noninteractive"
Expand All @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions CMake/pack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 27b69e9

Please sign in to comment.