Skip to content

Commit 742b79a

Browse files
committed
workflow: support multi-distro & multi-arch build
Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com>
1 parent d7635db commit 742b79a

9 files changed

Lines changed: 203 additions & 150 deletions

File tree

.github/workflows/dev-release.yml

Lines changed: 0 additions & 133 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "v*"
9+
10+
jobs:
11+
build:
12+
name: "Build Release"
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
images: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, centos-7, centos-8]
18+
platforms: [linux/amd64, linux/arm64]
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
with:
23+
submodules: true
24+
- name: Setup buildx instance
25+
uses: docker/setup-buildx-action@v2
26+
with:
27+
use: true
28+
- name: Build
29+
shell: bash
30+
run: |
31+
BASE_IMAGE=${IMAGE/-/:}
32+
echo ${BASE_IMAGE}
33+
docker buildx build --build-arg BUILD_IMAGE=${BASE_IMAGE} -f .github/workflows/release/Dockerfile --platform=${{ matrix.platforms }} -o releases/ .
34+
# remove unused package
35+
if [[ "${IMAGE}" =~ "ubuntu" ]]; then
36+
rm -f releases/overlaybd-*.rpm
37+
elif [[ "${IMAGE}" =~ "centos" ]]; then
38+
rm -f releases/overlaybd-*.deb
39+
fi
40+
ls -l releases/
41+
env:
42+
IMAGE: ${{ matrix.images }}
43+
- name: Upload
44+
uses: actions/upload-artifact@v3
45+
with:
46+
name: releases
47+
path: releases/overlaybd-*.*
48+
49+
dev-release:
50+
name: "Development Release"
51+
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/v')
52+
runs-on: ubuntu-latest
53+
needs: [build]
54+
steps:
55+
- name: Download builds and release notes
56+
uses: actions/download-artifact@v3
57+
- name: Display downloaded files
58+
shell: bash
59+
run: ls -l releases
60+
- name: Create Release
61+
uses: "marvinpinto/action-automatic-releases@latest"
62+
with:
63+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
64+
automatic_release_tag: "latest"
65+
prerelease: true
66+
title: "Development Build"
67+
files: |
68+
releases/overlaybd-*.*
69+
70+
release:
71+
name: "Tagged Release"
72+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
73+
runs-on: ubuntu-latest
74+
needs: [build]
75+
steps:
76+
- name: Download builds and release notes
77+
uses: actions/download-artifact@v3
78+
- name: Display downloaded files
79+
shell: bash
80+
run: ls -l releases
81+
- name: Create Release
82+
uses: "marvinpinto/action-automatic-releases@latest"
83+
with:
84+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
85+
prerelease: false
86+
files: |
87+
releases/overlaybd-*.*
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright The containerd Authors.
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ARG BUILD_IMAGE
16+
FROM ${BUILD_IMAGE} AS builder
17+
WORKDIR /src
18+
COPY . .
19+
ARG BUILD_IMAGE
20+
RUN ls -l /src && chmod 755 .github/workflows/release/build.sh && .github/workflows/release/build.sh ${BUILD_IMAGE}
21+
22+
FROM scratch AS release
23+
COPY --from=builder /src/build/overlaybd-*.* /

.github/workflows/release/build.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash -x
2+
3+
# Copyright The containerd Authors.
4+
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
OS=${1}
19+
ARCH=`uname -m`
20+
BUILD_TYPE="Release"
21+
COMPILER=""
22+
PACKAGE_RELEASE=""
23+
CMAKE="cmake"
24+
CPACK="cpack"
25+
26+
# Install Dependencies
27+
if [[ ${OS} =~ "ubuntu" ]]; then
28+
export DEBIAN_FRONTEND="noninteractive"
29+
export TZ="Etc/UTC"
30+
apt-get update -y
31+
apt-get install -y libgflags-dev libcurl4-openssl-dev libssl-dev libaio-dev libnl-3-dev libnl-genl-3-dev rpm wget make g++ git dpkg-dev sudo
32+
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
33+
34+
DISTRO=${OS/:/1~}
35+
PACKAGE_RELEASE="-DPACKAGE_RELEASE=0${DISTRO}"
36+
elif [[ ${OS} =~ "centos" ]]; then
37+
if [[ ${OS} == "centos:7" ]]; then
38+
yum install -y centos-release-scl
39+
yum install -y devtoolset-7-gcc-c++
40+
41+
export PATH="/opt/rh/devtoolset-7/root/usr/bin:$PATH"
42+
PACKAGE_RELEASE="-DPACKAGE_RELEASE=1.el7"
43+
COMPILER="-DCMAKE_C_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/gcc -DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/g++"
44+
elif [[ ${OS} == "centos:8" ]]; then
45+
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
46+
yum install -y gcc gcc-c++
47+
48+
PACKAGE_RELEASE="-DPACKAGE_RELEASE=1.el8"
49+
fi
50+
51+
yum install -y epel-release libaio-devel libcurl-devel openssl-devel libnl3-devel e2fsprogs-devel
52+
yum install -y rpm-build make git wget sudo
53+
yum install --skip-broken -y libzstd-static libzstd-devel
54+
fi
55+
56+
if [[ ${ARCH} == "x86_64" ]]; then
57+
wget https://cmake.org/files/v3.15/cmake-3.15.0-Linux-x86_64.tar.gz
58+
tar -zxf cmake-3.15.0-Linux-x86_64.tar.gz -C /usr/local/
59+
export PATH="/usr/local/cmake-3.15.0-Linux-x86_64/bin:$PATH"
60+
else
61+
wget https://cmake.org/files/v3.20/cmake-3.20.6-linux-aarch64.tar.gz
62+
tar -zxf cmake-3.20.6-linux-aarch64.tar.gz -C /usr/local/
63+
export PATH="/usr/local/cmake-3.20.6-linux-aarch64/bin:$PATH"
64+
fi
65+
66+
# Build
67+
mkdir build
68+
cd build
69+
${CMAKE} .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_TESTING=0 -DENABLE_DSA=0 -DENABLE_ISAL=0 ${PACKAGE_RELEASE} ${COMPILER}
70+
make -j8
71+
${CPACK} --verbose

CMake/Findext2fs.cmake

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
include(FetchContent)
22
set(FETCHCONTENT_QUIET false)
33

4-
if (${ARCH} STREQUAL x86_64)
5-
set(LIB_EXT2FS_URL "https://github.com/data-accelerator/e2fsprogs/releases/download/latest/libext2fs.tar.gz")
6-
elseif (${ARCH} STREQUAL aarch64)
7-
set(LIB_EXT2FS_URL "https://github.com/data-accelerator/e2fsprogs/releases/download/latest/libext2fs.aarch64.tar.gz")
8-
endif ()
9-
104
FetchContent_Declare(
11-
ext2fs
12-
URL ${LIB_EXT2FS_URL}
5+
e2fsprogs
6+
GIT_REPOSITORY https://github.com/data-accelerator/e2fsprogs.git
7+
GIT_TAG b4d19a0ec5cb535f13009d910833c62aa70d69a5
138
)
149

15-
FetchContent_GetProperties(ext2fs)
16-
if (NOT ext2fs_POPULATED)
17-
FetchContent_Populate(ext2fs)
18-
endif()
10+
FetchContent_MakeAvailable(e2fsprogs)
11+
12+
set(LIBEXT2FS_INSTALL_DIR ${e2fsprogs_SOURCE_DIR}/build/libext2fs)
13+
add_custom_command(
14+
OUTPUT ${LIBEXT2FS_INSTALL_DIR}/lib
15+
WORKING_DIRECTORY ${e2fsprogs_SOURCE_DIR}
16+
COMMAND chmod 755 build.sh && ./build.sh
17+
)
18+
add_custom_target(libext2fs ALL DEPENDS ${LIBEXT2FS_INSTALL_DIR}/lib)
1919

20-
set(EXT2FS_INCLUDE_DIR ${ext2fs_SOURCE_DIR}/include)
21-
find_library(EXT2FS_LIBRARY ext2fs HINTS ${ext2fs_SOURCE_DIR}/lib/)
20+
set(EXT2FS_INCLUDE_DIR ${LIBEXT2FS_INSTALL_DIR}/include)
21+
set(EXT2FS_LIBRARY ${LIBEXT2FS_INSTALL_DIR}/lib/libext2fs.so)

CMake/Findphoton.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(FETCHCONTENT_QUIET false)
44
FetchContent_Declare(
55
photon
66
GIT_REPOSITORY https://github.com/alibaba/PhotonLibOS.git
7-
GIT_TAG v0.5.6
7+
GIT_TAG v0.5.7
88
)
99

1010
if(BUILD_TESTING)

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
2121
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpic")
2222
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpic")
2323

24+
if (${ARCH} STREQUAL aarch64)
25+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char")
26+
endif ()
27+
2428
set(CMAKE_CXX_STANDARD_LIBRARIES "-static-libgcc ${CMAKE_CXX_STANDARD_LIBRARIES}")
2529
find_library(STATIC_LIBSTDC++ libstdc++.a PATHS /usr/lib/gcc/*/*)
2630
if(NOT ${STATIC_LIBSTDC++} STREQUAL "STATIC_LIBSTDC++-NOTFOUND")

src/overlaybd/extfs/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ add_library(extfs_lib STATIC ${SOURCE_TAR})
33

44
if(NOT ORIGIN_EXT2FS)
55
find_package(ext2fs REQUIRED)
6+
add_dependencies(extfs_lib libext2fs)
67
target_include_directories(extfs_lib PUBLIC ${EXT2FS_INCLUDE_DIR})
78
set(LIB_EXT2FS ${EXT2FS_LIBRARY})
89

9-
install(DIRECTORY ${ext2fs_SOURCE_DIR}/lib DESTINATION /opt/overlaybd/ USE_SOURCE_PERMISSIONS)
10+
install(DIRECTORY ${LIBEXT2FS_INSTALL_DIR}/lib DESTINATION /opt/overlaybd/ USE_SOURCE_PERMISSIONS)
1011
else()
1112
set(LIB_EXT2FS ext2fs)
1213
endif()

src/overlaybd/zfile/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ target_include_directories(crc32_lib PUBLIC
1717
if (${ARCH} STREQUAL x86_64)
1818
target_compile_options(crc32_lib PUBLIC -msse4.2 -mcrc32)
1919
else()
20-
target_compile_options(crc32_lib PUBLIC -march=native)
20+
target_compile_options(crc32_lib PUBLIC -march=native -mcpu=generic+crc)
2121
endif()
2222

2323
if(ENABLE_DSA OR ENABLE_ISAL)

0 commit comments

Comments
 (0)