forked from libuv/libuv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMake create release package, add GitHub Action CI
This will create an complete installer package for most platforms. Thereafter with `Findlibuv.cmake` in there directory and something like the following in there `CMakeLists.txt`. ``` find_package(libuv QUIET) if(NOT libuv_FOUND) FetchContent_Declare(libuv URL https://github.com/libuv/libuv/archive/refs/tags/v1.48.0.zip URL_MD5 67d0e50ac6e95de12b09b17ff8baed0f ) FetchContent_MakeAvailable(libuv) endif() ``` I think libuv#3194 should just be closed, it just doesn't actually automate any process, which was my initial use case, grab binary without me doing any building.
- Loading branch information
1 parent
4e310d0
commit 6344620
Showing
5 changed files
with
453 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
name: CI-release_package | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build-windows: | ||
name: Windows (${{ matrix.config.target }}) | ||
permissions: | ||
contents: write | ||
packages: write | ||
runs-on: windows-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
config: | ||
- {target: x64, build: win64 } | ||
- {target: Win32, build: win32 } | ||
steps: | ||
- uses: ilammy/msvc-dev-cmd@v1 | ||
with: | ||
arch: ${{ matrix.config.target }} | ||
- uses: actions/checkout@v4 | ||
- name: Configure | ||
run: | | ||
mkdir build | ||
cd build | ||
cmake .. -D LIBUV_BUILD_TESTS=OFF -A ${{ matrix.config.target }} | ||
- name: Build | ||
run: | | ||
cd build | ||
cmake --build . --config Release | ||
- name: Create NSIS Installer from Release | ||
run: | | ||
cd build | ||
cpack -G NSIS | ||
- name: Upload NSIS binary artifacts | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: built/Package/libuv-${{ github.event.release.tag_name }}-${{ matrix.config.build }}.exe | ||
asset_name: libuv-${{ github.event.release.tag_name }}-${{ matrix.config.build }}.exe | ||
tag: ${{ github.ref }} | ||
overwrite: true | ||
file_glob: true | ||
body: "Various platform library/package installers, includes libraries and needed header *.h files." | ||
|
||
build-linux: | ||
name: Linux ${{ matrix.config.target }} | ||
permissions: | ||
contents: write | ||
packages: write | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
config: | ||
- {target: amd64, flags: -m64 } | ||
# - {target: i386, flags: -m32 } | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Prepare | ||
run: | | ||
sudo dpkg --add-architecture i386 | ||
sudo apt-get update -q -y | ||
sudo apt-get install -y gcc-multilib g++-multilib valgrind libc6-dbg libc6-dbg:i386 | ||
- name: Configure & build | ||
run: | | ||
mkdir build | ||
cd build | ||
cmake .. -DCMAKE_BUILD_TYPE=Release -D LIBUV_BUILD_TESTS=OFF -DCMAKE_C_FLAGS=${{ matrix.config.flags }} | ||
cmake --build . | ||
- name: Create DEB Installer from Release | ||
run: | | ||
cd build | ||
cpack -G DEB | ||
- name: Upload DEB binary artifacts | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: built/Package/libuv_${{ github.event.release.tag_name }}_${{ matrix.config.target }}.deb | ||
asset_name: libuv_${{ github.event.release.tag_name }}_${{ matrix.config.target }}.deb | ||
tag: ${{ github.ref }} | ||
overwrite: true | ||
file_glob: true | ||
body: "Various platform library/package installers, includes libraries and needed header *.h files." | ||
|
||
build-centos: | ||
name: CentOS | ||
permissions: | ||
contents: write | ||
packages: write | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
container: quay.io/centos/centos:stream9 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Prepare | ||
run: | | ||
dnf install git make cmake gcc gcc-c++ binutils glibc-devel valgrind autoconf libtool bison automake libxml2-devel sudo which rpmdevtools rpmlint -y | ||
- name: Configure & build | ||
run: | | ||
mkdir build | ||
cd build | ||
cmake .. -DCMAKE_BUILD_TYPE=Release -D LIBUV_BUILD_TESTS=OFF | ||
cmake --build . | ||
- name: Create RPM Installer from Release | ||
run: | | ||
cd build | ||
cpack -G RPM | ||
- name: Upload RPM binary artifacts | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: built/Package/libuv-${{ github.event.release.tag_name }}-Linux.rpm | ||
asset_name: libuv-${{ github.event.release.tag_name }}-Linux.rpm | ||
tag: ${{ github.ref }} | ||
overwrite: true | ||
file_glob: true | ||
body: "Various platform library/package installers, includes libraries and needed header *.h files." | ||
|
||
build-macos: | ||
name: macOS | ||
permissions: | ||
contents: write | ||
packages: write | ||
runs-on: macos-12 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Envinfo | ||
run: npx envinfo | ||
- name: Setup | ||
run: | | ||
brew install ninja automake libtool | ||
- name: Configure & build | ||
run: | | ||
mkdir build | ||
cd build | ||
cmake .. -DCMAKE_BUILD_TYPE=Release -D LIBUV_BUILD_TESTS=OFF -G Ninja | ||
cmake --build . | ||
- name: Create DMG Installer from Release | ||
run: | | ||
cd build | ||
cpack -G DragNDrop | ||
- name: Upload DMG binary artifacts | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: built/Package/libuv-${{ github.event.release.tag_name }}-Darwin.dmg | ||
asset_name: libuv-${{ github.event.release.tag_name }}-Darwin.dmg | ||
tag: ${{ github.ref }} | ||
overwrite: true | ||
file_glob: true | ||
body: "Various platform library/package installers, includes libraries and needed header *.h files." | ||
|
||
build-qemu: | ||
name: ${{ matrix.target }} | ||
permissions: | ||
contents: write | ||
packages: write | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- target: armhf | ||
arch: armv7 | ||
- target: arm64 | ||
arch: aarch64 | ||
- target: ppc64el | ||
arch: ppc64le | ||
- target: riscv64 | ||
arch: riscv64 | ||
- target: s390x | ||
arch: s390x | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: uraimo/run-on-arch-action@v2 | ||
with: | ||
arch: ${{ matrix.arch }} | ||
distro: ubuntu_latest | ||
githubToken: ${{ github.token }} | ||
setup: | | ||
mkdir -p built/Package | ||
install: | | ||
apt-get update -q -y | ||
apt-get install -q -y --no-install-recommends cmake build-essential | ||
env: | | ||
# Valgrind on arm will fail if the stack size is larger than 8MB. | ||
# Set QEMUs stack size to 8MB since Github runners use 16MB default. | ||
QEMU_STACK_SIZE: 8388608 | ||
run: | | ||
mkdir build | ||
cd build | ||
cmake .. -DCMAKE_BUILD_TYPE=Release -D LIBUV_BUILD_TESTS=OFF | ||
cmake --build . | ||
cpack -G DEB | ||
- name: Upload ${{ matrix.arch }} DEB binary artifacts | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: built/Package/libuv_${{ github.event.release.tag_name }}_${{ matrix.target }}.deb | ||
asset_name: libuv_${{ github.event.release.tag_name }}_${{ matrix.target }}.deb | ||
tag: ${{ github.ref }} | ||
overwrite: true | ||
file_glob: true | ||
body: "Various platform library/package installers, includes libraries and needed header `*.h` files." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ Makefile | |
Makefile.in | ||
|
||
/build/ | ||
/built/ | ||
|
||
/test/.libs/ | ||
/test/run-tests | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -806,3 +806,99 @@ message(STATUS "summary of build options: | |
C compiler: ${CMAKE_C_COMPILER} (${CMAKE_C_COMPILER_ID}) | ||
CFLAGS: ${CMAKE_C_FLAGS_${_build_type}} ${CMAKE_C_FLAGS} | ||
") | ||
|
||
message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}") | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/built") | ||
set_target_properties(${LIB_SELECTED} PROPERTIES VERSION ${UV_VERSION_MAJOR}) | ||
set_target_properties(${LIB_SELECTED} PROPERTIES SOVERSION ${UV_VERSION_MAJOR}) | ||
|
||
set(_fmt TGZ) | ||
if(WIN32) | ||
set(_fmt ZIP) | ||
endif() | ||
|
||
set(CPACK_GENERATOR ${_fmt}) | ||
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) | ||
set(CPACK_DEB_COMPONENT_INSTALL ON) | ||
set(CPACK_RPM_COMPONENT_INSTALL ON) | ||
set(CPACK_NUGET_COMPONENT_INSTALL ON) | ||
set(CPACK_WIX_COMPONENT_INSTALL ON) | ||
set(CPACK_NSIS_MODIFY_PATH ON) | ||
set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1) | ||
set(CPACK_VERBATIM_VARIABLES YES) | ||
|
||
set(CPACK_SOURCE_IGNORE_FILES | ||
"~$" | ||
"\\\\.svn/" | ||
"/CMakeFiles/" | ||
"/CMakeCache*" | ||
"/cmake_install\\\\.cmake$" | ||
"/cmake_uninstall\\\\.cmake$" | ||
"^_CPack_.*/" | ||
"/CPack*" | ||
"\\\\.o$" | ||
"/m4/" | ||
"/build/" | ||
"/built/" | ||
) | ||
|
||
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} | ||
CACHE PATH "Location of header files" ) | ||
|
||
set(SYSCONFIG_INSTALL_DIR ${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME} | ||
CACHE PATH "Location of configuration files" ) | ||
|
||
configure_package_config_file(libuvConfig.cmake.in | ||
${CMAKE_CURRENT_BINARY_DIR}/libuvConfig.cmake | ||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} | ||
PATH_VARS INCLUDE_INSTALL_DIR SYSCONFIG_INSTALL_DIR) | ||
|
||
write_basic_package_version_file( | ||
${CMAKE_CURRENT_BINARY_DIR}/libuvConfigVersion.cmake | ||
VERSION ${PACKAGE_VERSION} | ||
COMPATIBILITY SameMajorVersion ) | ||
|
||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libuvConfig.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/libuvConfigVersion.cmake | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ) | ||
|
||
set(CMAKE_INSTALL_CONFIG_NAME ${CMAKE_BUILD_TYPE}) | ||
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/Package") | ||
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}) | ||
set(CPACK_PACKAGE_INSTALL_DIRECTORY libuv) | ||
|
||
set(CPACK_PACKAGE_CONTACT "[email protected]") | ||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Fixme Project Maintainers <${CPACK_PACKAGE_CONTACT}>") | ||
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) | ||
set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE) | ||
SET(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "multi-platform support library with a focus on asynchronous I/O.") | ||
|
||
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE) | ||
set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md) | ||
|
||
set(CPACK_PACKAGE_VENDOR "http://libuv.org/") | ||
set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION}) | ||
set(CPACK_PACKAGE_DESCRIPTION ${PROJECT_DESCRIPTION}) | ||
|
||
set(CPACK_RPM_PACKAGE_LICENSE "MIT") | ||
set(CPACK_RPM_PACKAGE_URL "http://libuv.org/") | ||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "noarch") | ||
|
||
set(CMAKE_INSTALL_CONFIG_NAME ${CMAKE_BUILD_TYPE}) | ||
install( | ||
TARGETS ${LIB_SELECTED} | ||
EXPORT "${PROJECT_NAME}Targets" | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
) | ||
|
||
install( | ||
EXPORT "${PROJECT_NAME}Targets" | ||
FILE "${PROJECT_NAME}Targets.cmake" | ||
NAMESPACE ${PROJECT_NAME}:: | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} | ||
) | ||
|
||
set(CPACK_INSTALL_CMAKE_CONFIGURATIONS Release) | ||
include(CPack) |
Oops, something went wrong.