Skip to content

Commit

Permalink
use tag as release version
Browse files Browse the repository at this point in the history
Signed-off-by: yuchen.cc <[email protected]>
  • Loading branch information
yuchen0cc committed Apr 20, 2023
1 parent 95bc903 commit 20a707d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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-*.* /
3 changes: 2 additions & 1 deletion .github/workflows/release/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@


OS=${1}
PACKAGE_VERSION=${2}
ARCH=`uname -m`
BUILD_TYPE="Release"
COMPILER=""
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion CMake/pack.cmake
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.15)

project(
overlaybd
VERSION 0.6.1
LANGUAGES C CXX
)
enable_language(C)
Expand Down

0 comments on commit 20a707d

Please sign in to comment.