Skip to content

Commit 35b60ad

Browse files
authored
Merge pull request #202 from yuchen0cc/main
use tag as release version
2 parents 95bc903 + 20a707d commit 35b60ad

5 files changed

Lines changed: 20 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ jobs:
1717
images: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, centos-7, centos-8]
1818
platforms: [linux/amd64, linux/arm64]
1919
steps:
20+
- name: Set Release Version
21+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
22+
shell: bash
23+
run: |
24+
releasever=${{ github.ref }}
25+
releasever="${releasever#refs/tags/}"
26+
echo "RELEASE_VERSION=${releasever}" >> $GITHUB_ENV
2027
- name: Checkout
2128
uses: actions/checkout@v3
2229
with:
@@ -28,9 +35,16 @@ jobs:
2835
- name: Build
2936
shell: bash
3037
run: |
38+
RELEASE_VERSION=${{ env.RELEASE_VERSION }}
39+
if [[ -z ${RELEASE_VERSION} ]]; then
40+
git fetch --tags
41+
RELEASE_VERSION=$(git tag -l v* | tail -1)
42+
fi
43+
RELEASE_VERSION=${RELEASE_VERSION#v}
44+
echo "RELEASE_VERSION=${RELEASE_VERSION}"
3145
BASE_IMAGE=${IMAGE/-/:}
3246
echo ${BASE_IMAGE}
33-
docker buildx build --build-arg BUILD_IMAGE=${BASE_IMAGE} -f .github/workflows/release/Dockerfile --platform=${{ matrix.platforms }} -o releases/ .
47+
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/ .
3448
# remove unused package
3549
if [[ "${IMAGE}" =~ "ubuntu" ]]; then
3650
rm -f releases/overlaybd-*.rpm

.github/workflows/release/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ FROM ${BUILD_IMAGE} AS builder
1717
WORKDIR /src
1818
COPY . .
1919
ARG BUILD_IMAGE
20-
RUN ls -l /src && chmod 755 .github/workflows/release/build.sh && .github/workflows/release/build.sh ${BUILD_IMAGE}
20+
ARG RELEASE_VERSION
21+
RUN ls -l /src && chmod 755 .github/workflows/release/build.sh && .github/workflows/release/build.sh ${BUILD_IMAGE} ${RELEASE_VERSION}
2122

2223
FROM scratch AS release
2324
COPY --from=builder /src/build/overlaybd-*.* /

.github/workflows/release/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717

1818
OS=${1}
19+
PACKAGE_VERSION=${2}
1920
ARCH=`uname -m`
2021
BUILD_TYPE="Release"
2122
COMPILER=""
@@ -66,6 +67,6 @@ fi
6667
# Build
6768
mkdir build
6869
cd build
69-
${CMAKE} .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_TESTING=0 -DENABLE_DSA=0 -DENABLE_ISAL=0 ${PACKAGE_RELEASE} ${COMPILER}
70+
${CMAKE} .. -DPACKAGE_VERSION=${PACKAGE_VERSION} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_TESTING=0 -DENABLE_DSA=0 -DENABLE_ISAL=0 ${PACKAGE_RELEASE} ${COMPILER}
7071
make -j8
7172
${CPACK} --verbose

CMake/pack.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
1+
set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION})
22
set(CPACK_GENERATOR "RPM;DEB")
33
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
44
if (PACKAGE_RELEASE)

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.15)
22

33
project(
44
overlaybd
5-
VERSION 0.6.1
65
LANGUAGES C CXX
76
)
87
enable_language(C)

0 commit comments

Comments
 (0)