Skip to content

Commit b74a559

Browse files
dudoslavihnorton
andauthored
Use CPack in release workflow (#4694)
This PR changes the default behavior of release workflow to use `cpack` commands to generate source and binary releases of TileDB library. The produced releases can be seen here: https://github.com/dudoslav/TileDB/actions/runs/7757551437 How release look: https://github.com/dudoslav/TileDB/releases/tag/t03 --- TYPE: BUILD DESC: CPack in Release Workflow --------- Co-authored-by: Isaiah Norton <[email protected]>
1 parent 22a71d4 commit b74a559

File tree

4 files changed

+80
-58
lines changed

4 files changed

+80
-58
lines changed

.github/workflows/release.yml

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,26 @@ on:
1010
workflow_dispatch:
1111

1212
jobs:
13-
Build-Release:
13+
Package-Source-Release:
14+
strategy:
15+
matrix:
16+
os: [ubuntu-20.04]
17+
runs-on: ${{ matrix.os }}
18+
steps:
19+
- name: Checkout TileDB
20+
uses: actions/checkout@v3
21+
- name: CMake Configure
22+
run: cmake -S . -B build -DTILEDB_CMAKE_IDE=ON
23+
- name: CPack Package Source
24+
run: cd build && cpack --config CPackSourceConfig.cmake
25+
- name: Upload Release Artifacts
26+
uses: actions/upload-artifact@v3
27+
with:
28+
name: release
29+
path: |
30+
build/tiledb-*.tar.gz*
31+
32+
Package-Binary-Release:
1433
strategy:
1534
fail-fast: false
1635
matrix:
@@ -88,44 +107,27 @@ jobs:
88107
${{ matrix.cmake_args }}
89108
shell: bash
90109
- name: Build TileDB
91-
run: cmake --build build --config Release
92-
- name: Install TileDB
93-
run: cmake --build build --config Release --target install-tiledb
94-
- name: Archive installed artifacts (non-Windows)
95-
if: ${{ !startsWith(matrix.platform, 'windows') }}
96-
run: |
97-
tar -czf ${{ steps.get-values.outputs.archive_name }}.tar.gz -C dist .
98-
- name: Archive installed artifacts (Windows)
99-
if: startsWith(matrix.platform, 'windows')
100-
run: |
101-
Compress-Archive -Path dist\* -DestinationPath ${{ steps.get-values.outputs.archive_name }}.zip
102-
shell: pwsh
110+
run: cmake --build build --config Release --target package
103111
- name: Upload release artifacts
104112
uses: actions/upload-artifact@v3
105113
with:
106-
name: tiledb-dist
107-
path: ${{ steps.get-values.outputs.archive_name }}.*
108-
- name: Archive build directory
109-
run: |
110-
tar -czf build-${{ matrix.platform }}.tar.gz -C build .
111-
- name: Upload build directory
112-
uses: actions/upload-artifact@v3
113-
with:
114-
name: tiledb-build
115-
path: build-${{ matrix.platform }}.tar.gz
114+
name: release
115+
path: |
116+
build/tiledb/tiledb-*.tar.gz*
117+
build/tiledb/tiledb-*.zip*
116118
- name: "Print log files (failed build only)"
117119
run: |
118120
source $GITHUB_WORKSPACE/scripts/ci/print_logs.sh
119121
if: failure() # only run this job if the build step failed
120122

121123
Test-Release-Artifacts:
122-
needs: Build-Release
124+
needs: Package-Binary-Release
123125
runs-on: ubuntu-latest
124126
steps:
125127
- name: Download release artifacts
126-
uses: actions/download-artifact@v2
128+
uses: actions/download-artifact@v3
127129
with:
128-
name: tiledb-dist
130+
name: release
129131
path: dist
130132
- name: Test names of release artifacts
131133
run: |
@@ -135,14 +137,16 @@ jobs:
135137
fi
136138
137139
Publish-Release:
138-
needs: Test-Release-Artifacts
140+
needs:
141+
- Test-Release-Artifacts
142+
- Package-Source-Release
139143
if: startsWith(github.ref, 'refs/tags/')
140144
runs-on: ubuntu-latest
141145
steps:
142146
- name: Download release artifacts
143-
uses: actions/download-artifact@v2
147+
uses: actions/download-artifact@v3
144148
with:
145-
name: tiledb-dist
149+
name: release
146150
path: dist
147151
- name: Publish release artifacts
148152
uses: actions/github-script@v6
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
set(CPACK_SOURCE_IGNORE_FILES ".*\\.git;.*build.*")
2-
31
set(CPACK_PACKAGE_VENDOR "TileDB Inc.")
42
set(CPACK_PACKAGE_VERSION "@TILEDB_VERSION@")
53

64
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
75

8-
# Append NOAVX2 if needed
9-
if(NOT ${COMPILER_SUPPORTS_AVX2})
10-
set(NOAVX2 "-noavx2")
11-
endif()
12-
13-
# Set output name
14-
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}${NOAVX2}-${CPACK_PACKAGE_VERSION}")
15-
string(TOLOWER ${CPACK_PACKAGE_FILE_NAME} CPACK_PACKAGE_FILE_NAME )
16-
176
# Enable HASH
18-
set(CPACK_PACKAGE_CHECKSUM "SHA256")
7+
set(CPACK_PACKAGE_CHECKSUM "SHA256")

cmake/package.cmake

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Packaging configuration
2+
configure_file ("${PROJECT_SOURCE_DIR}/cmake/inputs/CustomCPackOptions.cmake.in"
3+
"${PROJECT_BINARY_DIR}/CustomCPackOptions.cmake"
4+
@ONLY)
5+
set (CPACK_PROJECT_CONFIG_FILE
6+
"${PROJECT_BINARY_DIR}/CustomCPackOptions.cmake")
7+
8+
# Not all options can be set in CustomCPackOptions.cmake
9+
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
10+
set(CPACK_SOURCE_GENERATOR "ZIP")
11+
set(CPACK_GENERATOR "ZIP")
12+
else()
13+
set(CPACK_SOURCE_GENERATOR "TGZ")
14+
set(CPACK_GENERATOR "TGZ")
15+
endif()
16+
17+
# Package file name variables can not be in config file as well
18+
19+
# Append NOAVX2 if needed
20+
if(NOT ${COMPILER_SUPPORTS_AVX2})
21+
set(CPACK_NOAVX2 "-noavx2")
22+
endif()
23+
24+
# Properly set system name and architecture
25+
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
26+
set(CPACK_SYSTEM_NAME "MacOS")
27+
if(CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
28+
set(CPACK_SYSTEM_PROCESSOR ${CMAKE_OSX_ARCHITECTURES})
29+
else()
30+
set(CPACK_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR})
31+
endif()
32+
else()
33+
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
34+
set(CPACK_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR})
35+
endif()
36+
37+
set(CPACK_SOURCE_IGNORE_FILES ".*\.git;.*build.*/.*")
38+
39+
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-source-${TILEDB_VERSION}")
40+
string(TOLOWER ${CPACK_SOURCE_PACKAGE_FILE_NAME} CPACK_SOURCE_PACKAGE_FILE_NAME)
41+
42+
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_SYSTEM_NAME}-${CPACK_SYSTEM_PROCESSOR}${CPACK_NOAVX2}-${TILEDB_VERSION}")
43+
string(TOLOWER ${CPACK_PACKAGE_FILE_NAME} CPACK_PACKAGE_FILE_NAME)
44+
45+
include(CPack)

tiledb/CMakeLists.txt

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,20 +1056,4 @@ configure_file(
10561056
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tiledb.pc
10571057
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
10581058

1059-
# Packaging configuration
1060-
configure_file ("${PROJECT_SOURCE_DIR}/cmake/inputs/CustomCPackOptions.cmake.in"
1061-
"${PROJECT_BINARY_DIR}/CustomCPackOptions.cmake"
1062-
@ONLY)
1063-
set (CPACK_PROJECT_CONFIG_FILE
1064-
"${PROJECT_BINARY_DIR}/CustomCPackOptions.cmake")
1065-
1066-
# Not all options can be set in CustomCPackOptions.cmake
1067-
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
1068-
set(CPACK_SOURCE_GENERATOR "ZIP")
1069-
set(CPACK_GENERATOR "ZIP")
1070-
else()
1071-
set(CPACK_SOURCE_GENERATOR "TGZ")
1072-
set(CPACK_GENERATOR "TGZ")
1073-
endif()
1074-
1075-
include(CPack)
1059+
include(${CMAKE_SOURCE_DIR}/cmake/package.cmake)

0 commit comments

Comments
 (0)