diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 946b646d..601ba60b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,6 +17,13 @@ jobs: images: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, centos-7, centos-8] platforms: [linux/amd64, linux/arm64] steps: + - name: Set Release Version + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + shell: bash + run: | + releasever=${{ github.ref }} + releasever="${releasever#refs/tags/}" + echo "RELEASE_VERSION=${releasever}" >> $GITHUB_ENV - name: Checkout uses: actions/checkout@v3 with: @@ -28,9 +35,16 @@ jobs: - name: Build shell: bash run: | + RELEASE_VERSION=${{ env.RELEASE_VERSION }} + if [[ -z ${RELEASE_VERSION} ]]; then + git fetch --tags + RELEASE_VERSION=$(git tag -l v* | tail -1) + fi + RELEASE_VERSION=${RELEASE_VERSION#v} + echo "RELEASE_VERSION=${RELEASE_VERSION}" BASE_IMAGE=${IMAGE/-/:} echo ${BASE_IMAGE} - docker buildx build --build-arg BUILD_IMAGE=${BASE_IMAGE} -f .github/workflows/release/Dockerfile --platform=${{ matrix.platforms }} -o releases/ . + docker buildx build --build-arg BUILD_IMAGE=${BASE_IMAGE} --build-arg RELEASE_VERSION=${RELEASE_VERSION} -f .github/workflows/release/Dockerfile --platform=${{ matrix.platforms }} -o releases/ . # remove unused package if [[ "${IMAGE}" =~ "ubuntu" ]]; then rm -f releases/overlaybd-*.rpm diff --git a/.github/workflows/release/Dockerfile b/.github/workflows/release/Dockerfile index a8d0b636..a455fc36 100644 --- a/.github/workflows/release/Dockerfile +++ b/.github/workflows/release/Dockerfile @@ -17,7 +17,8 @@ FROM ${BUILD_IMAGE} AS builder WORKDIR /src COPY . . ARG BUILD_IMAGE -RUN ls -l /src && chmod 755 .github/workflows/release/build.sh && .github/workflows/release/build.sh ${BUILD_IMAGE} +ARG RELEASE_VERSION +RUN ls -l /src && chmod 755 .github/workflows/release/build.sh && .github/workflows/release/build.sh ${BUILD_IMAGE} ${RELEASE_VERSION} 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 5fc30b59..7978614f 100644 --- a/.github/workflows/release/build.sh +++ b/.github/workflows/release/build.sh @@ -16,6 +16,7 @@ OS=${1} +PACKAGE_VERSION=${2} ARCH=`uname -m` BUILD_TYPE="Release" COMPILER="" @@ -66,6 +67,6 @@ fi # Build mkdir build cd build -${CMAKE} .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_TESTING=0 -DENABLE_DSA=0 -DENABLE_ISAL=0 ${PACKAGE_RELEASE} ${COMPILER} +${CMAKE} .. -DPACKAGE_VERSION=${PACKAGE_VERSION} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_TESTING=0 -DENABLE_DSA=0 -DENABLE_ISAL=0 ${PACKAGE_RELEASE} ${COMPILER} make -j8 ${CPACK} --verbose diff --git a/CMake/pack.cmake b/CMake/pack.cmake index a3edba7a..136be812 100644 --- a/CMake/pack.cmake +++ b/CMake/pack.cmake @@ -1,4 +1,4 @@ -set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) +set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION}) set(CPACK_GENERATOR "RPM;DEB") set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) if (PACKAGE_RELEASE) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1df8f516..3e10d657 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.15) project( overlaybd - VERSION 0.6.1 LANGUAGES C CXX ) enable_language(C)