Skip to content

Commit

Permalink
Merge pull request #781 from ZettaScaleLabs/build-packages-cpack
Browse files Browse the repository at this point in the history
fix: change release workflow to build using cpack
  • Loading branch information
Mallets authored Oct 31, 2024
2 parents 48d7923 + 886cd22 commit eb52733
Show file tree
Hide file tree
Showing 15 changed files with 188 additions and 45 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ jobs:
run: |
sudo apt-get install -y musl-tools
sudo apt-get install -y gcc-arm-linux-gnueabi
sudo apt-get install -y gcc-arm-linux-gnueabihf
sudo apt-get install -y g++-arm-linux-gnueabi
sudo apt-get install -y g++-arm-linux-gnueabihf
sudo apt-get install -y mingw-w64
sudo apt-get install -y gcc-aarch64-linux-gnu
sudo apt-get install -y g++-aarch64-linux-gnu
Expand All @@ -181,6 +183,7 @@ jobs:
- name: Install rust toolchains
run: |
rustup target add arm-unknown-linux-gnueabi
rustup target add arm-unknown-linux-gnueabihf
rustup target add x86_64-pc-windows-gnu
rustup target add aarch64-unknown-linux-gnu
rustup target add aarch64-unknown-linux-musl
Expand All @@ -193,6 +196,13 @@ jobs:
cmake -DCMAKE_TOOLCHAIN_FILE="../ci/toolchains/TC-arm-unknown-linux-gnueabi.cmake" -DZENOHC_BUILD_WITH_SHARED_MEMORY=ON -DZENOHC_BUILD_WITH_UNSTABLE_API=ON ..
cmake --build . --target examples
- name: Cross compile for arm-unknown-linux-gnueabihf
run: |
rm -rf ./build
mkdir -p ./build && cd ./build
cmake -DCMAKE_TOOLCHAIN_FILE="../ci/toolchains/TC-arm-unknown-linux-gnueabihf.cmake" -DZENOHC_BUILD_WITH_SHARED_MEMORY=ON -DZENOHC_BUILD_WITH_UNSTABLE_API=ON ..
cmake --build . --target examples
- name: Cross compile for aarch64-unknown-linux-gnu
run: |
rm -rf ./build
Expand Down
159 changes: 134 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,33 +72,142 @@ jobs:
GIT_USER_NAME: eclipse-zenoh-bot
GIT_USER_EMAIL: [email protected]

build-debian:
name: Build Debian packages
build:
name: Build packages
runs-on: ${{ matrix.build.os }}
strategy:
fail-fast: false
matrix:
build:
- { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04 }
- { target: x86_64-unknown-linux-musl, os: ubuntu-20.04 }
- { target: arm-unknown-linux-gnueabi, os: ubuntu-20.04 }
- { target: arm-unknown-linux-gnueabihf, os: ubuntu-20.04 }
- { target: armv7-unknown-linux-gnueabihf, os: macos-14 }
- { target: aarch64-unknown-linux-gnu, os: ubuntu-20.04 }
- { target: aarch64-unknown-linux-musl, os: ubuntu-20.04 }
- { target: x86_64-apple-darwin, os: macos-14 }
- { target: aarch64-apple-darwin, os: macos-14 }
- { target: x86_64-pc-windows-msvc, os: windows-2019 }
- { target: x86_64-pc-windows-gnu, os: ubuntu-20.04 }
needs: tag
uses: eclipse-zenoh/ci/.github/workflows/build-crates-debian.yml@main
with:
repo: ${{ github.repository }}
version: ${{ needs.tag.outputs.version }}
branch: ${{ needs.tag.outputs.branch }}
secrets: inherit
steps:
- name: Checkout this repository
uses: actions/checkout@v4
with:
ref: ${{ needs.tag.outputs.branch }}
token: ${{ secrets.BOT_TOKEN_WORKFLOW }}

build-standalone:
name: Build executables and libraries
needs: tag
uses: eclipse-zenoh/ci/.github/workflows/build-crates-standalone.yml@main
with:
repo: ${{ github.repository }}
version: ${{ needs.tag.outputs.version }}
branch: ${{ needs.tag.outputs.branch }}
artifact-patterns: |
^libzenohc\.(dylib|so)$
^zenohc\.dll$
^include$
secrets: inherit
- name: Add rust toolchain
run: |
rustup target add ${{ matrix.build.target }}
- name: Install build deps
if: ${{ matrix.build.target == 'x86_64-unknown-linux-musl'}}
run: |
sudo apt-get install -y musl-tools
wget https://musl.cc/x86_64-linux-musl-cross.tgz
tar xvfz x86_64-linux-musl-cross.tgz
echo "$(readlink -f x86_64-linux-musl-cross)/bin" >> "$GITHUB_PATH"
- name: Install build deps
if: ${{ matrix.build.target == 'arm-unknown-linux-gnueabi'}}
run: sudo apt-get install -y gcc-arm-linux-gnueabi g++-arm-linux-gnueabi

- name: Install build deps
if: ${{ matrix.build.target == 'arm-unknown-linux-gnueabihf'}}
run: sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf

- name: Install build deps
if: ${{ matrix.build.target == 'armv7-unknown-linux-gnueabihf'}}
run: |
brew install -f messense/macos-cross-toolchains/armv7-unknown-linux-gnueabihf
brew install dpkg
brew install rpm
- name: Install build deps
if: ${{ matrix.build.target == 'aarch64-unknown-linux-gnu'}}
run: sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu

- name: Install build deps
if: ${{ matrix.build.target == 'aarch64-unknown-linux-musl'}}
run: |
wget https://musl.cc/aarch64-linux-musl-cross.tgz
tar xvfz aarch64-linux-musl-cross.tgz
echo "$(readlink -f aarch64-linux-musl-cross)/bin" >> "$GITHUB_PATH"
- name: Install build deps
if: ${{ matrix.build.target == 'x86_64-pc-windows-gnu'}}
run: |
sudo apt-get install -y mingw-w64
- name: Compute package name
id: compute-package-name
shell: bash
run: |
if [[ "${{ matrix.build.target }}" =~ "armv7" ]]; then
echo "value=zenohc-armv7" >> $GITHUB_OUTPUT
elif [[ "${{ matrix.build.target }}" =~ "musl" ]]; then
echo "value=zenohc-musl" >> $GITHUB_OUTPUT
else
echo "value=zenohc" >> $GITHUB_OUTPUT
fi
- name: Build standalone
id: build
shell: bash
run: |
toolchain_file=$(readlink -f ci/toolchains/TC-${{ matrix.build.target }}.cmake)
mkdir -p build && cd build
cmake .. -DCPACK_PACKAGE_NAME=${{ steps.compute-package-name.outputs.value }} -DZENOHC_CUSTOM_TARGET=${{ matrix.build.target }} -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}" -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DZENOHC_BUILD_WITH_UNSTABLE_API=ON -DZENOHC_BUILD_WITH_SHARED_MEMORY=ON
cmake --build . --config Release
cpack -C Release -G ZIP
- name: Build distro packages (DEB/RPM)
id: build-distro-packages
if: ${{ contains(matrix.build.target, 'linux') }}
run: |
cd build
cpack -G DEB
cpack -G RPM
- name: Prepare standalone archives
shell: bash
run: |
zip_filename=$(readlink -f ./build/packages/*.zip)
mv ${zip_filename} zenoh-c-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-standalone.zip
- name: Zip deb/rpm archives
shell: bash
if: ${{ contains(matrix.build.target, 'linux') }}
run: |
zip -9 -j libzenohc-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-debian.zip ./build/packages/*.deb
zip -9 -j libzenohc-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-rpm.zip ./build/packages/*.rpm
- name: Upload standalone archive
uses: actions/upload-artifact@v4
with:
# Publish the artifact with zenoh-c (repo name) so it can be used by homebrew action
name: zenoh-c-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-standalone.zip
path: zenoh-c-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-standalone.zip

- name: Upload DEB archive
if: ${{ contains(matrix.build.target, 'linux') }}
uses: actions/upload-artifact@v4
with:
name: libzenohc-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-debian.zip
path: libzenohc-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-debian.zip

- name: Upload RPM archive
if: ${{ contains(matrix.build.target, 'linux') }}
uses: actions/upload-artifact@v4
with:
name: libzenohc-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-rpm.zip
path: libzenohc-${{ inputs.version || '0.0.0' }}-${{ matrix.build.target }}-rpm.zip

debian:
name: Publish Debian packages
needs: [tag, build-debian]
needs: [tag, build]
uses: eclipse-zenoh/ci/.github/workflows/release-crates-debian.yml@main
with:
no-build: true
Expand All @@ -111,7 +220,7 @@ jobs:

homebrew:
name: Publish Homebrew formulae
needs: [tag, build-standalone]
needs: [tag, build]
uses: eclipse-zenoh/ci/.github/workflows/release-crates-homebrew.yml@main
with:
no-build: true
Expand All @@ -128,7 +237,7 @@ jobs:

eclipse:
name: Publish artifacts to Eclipse downloads
needs: [tag, build-standalone]
needs: [tag, build]
uses: eclipse-zenoh/ci/.github/workflows/release-crates-eclipse.yml@main
with:
no-build: true
Expand All @@ -145,7 +254,7 @@ jobs:

github:
name: Publish artifacts to GitHub Releases
needs: [tag, build-standalone]
needs: [tag, build]
uses: eclipse-zenoh/ci/.github/workflows/release-crates-github.yml@main
with:
no-build: true
Expand Down
3 changes: 3 additions & 0 deletions ci/toolchains/TC-aarch64-apple-darwin.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(CMAKE_SYSTEM_NAME Darwin)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(ZENOHC_CUSTOM_TARGET aarch64-apple-darwin)
3 changes: 2 additions & 1 deletion ci/toolchains/TC-aarch64-unknown-linux-gnu.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(DEBARCH arm64)
set(ZENOHC_CUSTOM_TARGET aarch64-unknown-linux-gnu)
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
3 changes: 2 additions & 1 deletion ci/toolchains/TC-aarch64-unknown-linux-musl.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(DEBARCH arm64)
set(ZENOHC_CUSTOM_TARGET aarch64-unknown-linux-musl)
set(CMAKE_C_COMPILER aarch64-linux-musl-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-musl-g++)
set(CMAKE_CXX_COMPILER aarch64-linux-musl-g++)
3 changes: 2 additions & 1 deletion ci/toolchains/TC-arm-unknown-linux-gnueabi.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(DEBARCH armel)
set(ZENOHC_CUSTOM_TARGET arm-unknown-linux-gnueabi)
set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++)
set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++)
6 changes: 6 additions & 0 deletions ci/toolchains/TC-arm-unknown-linux-gnueabihf.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR armhf)
set(DEBARCH armhf)
set(ZENOHC_CUSTOM_TARGET arm-unknown-linux-gnueabihf)
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
3 changes: 2 additions & 1 deletion ci/toolchains/TC-armv7-unknown-linux-gnueabihf.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR armv7)
set(DEBARCH armhf)
set(ZENOHC_CUSTOM_TARGET armv7-unknown-linux-gnueabihf)
set(CMAKE_C_COMPILER armv7-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER armv7-linux-gnueabihf-g++)
set(CMAKE_CXX_COMPILER armv7-linux-gnueabihf-g++)
3 changes: 3 additions & 0 deletions ci/toolchains/TC-x86_64-apple-darwin.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(CMAKE_SYSTEM_NAME Darwin)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(ZENOHC_CUSTOM_TARGET x86_64-apple-darwin)
2 changes: 1 addition & 1 deletion ci/toolchains/TC-x86_64-pc-windows-gnu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(ZENOHC_CUSTOM_TARGET x86_64-pc-windows-gnu)
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
3 changes: 3 additions & 0 deletions ci/toolchains/TC-x86_64-pc-windows-msvc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(ZENOHC_CUSTOM_TARGET x86_64-pc-windows-msvc)
5 changes: 3 additions & 2 deletions ci/toolchains/TC-x86_64-unknown-linux-gnu.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(DEBARCH amd64)
set(ZENOHC_CUSTOM_TARGET x86_64-unknown-linux-gnu)
set(CMAKE_C_COMPILER x86_64-unknown-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER x86_64-unknown-linux-gnu-g++)
set(CMAKE_C_COMPILER x86_64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER x86_64-linux-gnu-g++)
3 changes: 2 additions & 1 deletion ci/toolchains/TC-x86_64-unknown-linux-musl.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(DEBARCH amd64)
set(ZENOHC_CUSTOM_TARGET x86_64-unknown-linux-musl)
set(CMAKE_C_COMPILER x86_64-linux-musl-gcc)
set(CMAKE_CXX_COMPILER x86_64-linux-musl-g++)
set(CMAKE_CXX_COMPILER x86_64-linux-musl-g++)
20 changes: 14 additions & 6 deletions install/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function(install_zenohc_lib configurations property_postfix package_name)
get_target_property(staticlib_path zenohc::static IMPORTED_LOCATION_${property_postfix})
get_target_property(NATIVE_STATIC_LIBS zenohc::static INTERFACE_LINK_LIBRARIES)
get_filename_component(STATICLIB ${staticlib_path} NAME)
install(FILES ${staticlib_path} DESTINATION ${CMAKE_INSTALL_LIBDIR} CONFIGURATIONS ${configurations} COMPONENT lib)
install(FILES ${staticlib_path} DESTINATION ${CMAKE_INSTALL_LIBDIR} CONFIGURATIONS ${configurations} COMPONENT dev)

set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${package_name}")

Expand Down Expand Up @@ -98,18 +98,17 @@ set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_COMPONENT_LIB_DESCRIPTION "The C client library for Eclipse zenoh")
set(CPACK_COMPONENT_DEV_DESCRIPTION "${CPACK_COMPONENT_LIB_DESCRIPTION} - cmake files")
set(CPACK_COMPONENT_DEV_DESCRIPTION "${CPACK_COMPONENT_LIB_DESCRIPTION} - zenoh-c static lib and cmake files")
set(CPACK_COMPONENT_HEADERS_DESCRIPTION "${CPACK_COMPONENT_LIB_DESCRIPTION} - header files")
set(CPACK_COMPONENT_LIB_GROUP "lib")
set(CPACK_COMPONENT_HEADERS_GROUP "dev")
set(CPACK_COMPONENT_DEV_GROUP "dev")
set(CPACK_COMPONENT_HEADERS_DEPENDS lib)
set(CPACK_COMPONENT_DEV_DEPENDS lib)
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)

set(CPACK_GENERATOR ZIP)
# set package name to format <name>-<version>.<extension>
# platform name doesn't matter for header-only library
set(CPACK_PACKAGE_NAME zenohc)
set(CPACK_CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR})

if(NOT CPACK_PACKAGE_VERSION)
set(SEM_VER "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
Expand All @@ -124,7 +123,16 @@ endif()

set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")

set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
if(NOT DEBARCH)
set(DEBARCH ${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_SYSTEM_NAME})
endif()
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DEBARCH})

if(NOT RPMARCH)
set(RPMARCH ${CMAKE_SYSTEM_PROCESSOR})
endif()
set(CPACK_RPM_PACKAGE_ARCHITECTURE ${RPMARCH})

set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cpack_project_config.cmake")

include(CPack)
7 changes: 1 addition & 6 deletions install/cpack_project_config.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_CMAKE_SYSTEM_PROCESSOR}")
if(CPACK_GENERATOR MATCHES "DEB")
# DEB package
message(STATUS "Configure DEB packaging for Linux ${DEBARCH}")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "ZettaScale Zenoh Team, <[email protected]>")
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
Expand All @@ -14,11 +14,6 @@ if(CPACK_GENERATOR MATCHES "RPM")
# RPM package
# rpmbuild should be installed
# apt install rpm
if(NOT RPMARCH)
set(RPMARCH ${CMAKE_SYSTEM_PROCESSOR})
endif()
message(STATUS "Configure RPM packaging for Linux ${RPMARCH}")
set(CPACK_RPM_PACKAGE_ARCHITECTURE ${RPMARCH})
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_RPM_FILE_NAME RPM-DEFAULT)
set(CPACK_RPM_LIB_PACKAGE_NAME ${CPACK_PACKAGE_NAME}) # avoid "-lib" suffix for "lib" package
Expand Down

0 comments on commit eb52733

Please sign in to comment.