-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Single release CMake file that contains all required links/hashes. (#…
…4631) This PR aims to autogenerate cmake file containing all required hash/url combinations so that other repositories can simply pull this file and forget about changing all url/hash occurences in their code. The output assets look like this now: https://github.com/dudoslav/TileDB/releases/tag/t01 Please let me know if the produced CMake file is ok, or should be changed to a different format. --- TYPE: BUILD DESC: Single release CMake file that contains all required links/hashes.
- Loading branch information
Showing
3 changed files
with
215 additions
and
1 deletion.
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,80 @@ | ||
name: Append Release CMake | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
ref: | ||
description: 'Ref to be used as release' | ||
default: 'latest' | ||
required: true | ||
type: string | ||
workflow_call: | ||
inputs: | ||
ref: | ||
description: 'Ref to be used as release' | ||
default: 'latest' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
generate_cmake_files: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout TileDB | ||
uses: actions/checkout@v3 | ||
|
||
- name: Make release and output directories | ||
run: | | ||
mkdir release output | ||
- name: Github release data | ||
id: release_data | ||
uses: KevinRohn/[email protected] | ||
with: | ||
# repository: 'TileDB-Inc/TileDB' | ||
version: ${{ inputs.ref }} | ||
asset-file: '*.zip,*.tar.gz' | ||
asset-output: './release/' | ||
|
||
- name: Render template | ||
run: | | ||
PATTERN="tiledb-([^-]+)-([^-]+)(-noavx2)?-([^-]+).(tar.gz|zip)$" | ||
RELLIST="output/releases.csv" | ||
MODULE="output/DownloadPrebuiltTileDB.cmake" | ||
cp cmake/inputs/DownloadPrebuiltTileDB.cmake $MODULE | ||
echo "platform,url,sha256" > $RELLIST | ||
for FILE in $(ls release) | ||
do | ||
if [[ $FILE =~ $PATTERN ]] | ||
then | ||
OS=${BASH_REMATCH[1]^^} | ||
ARCH=${BASH_REMATCH[2]^^} | ||
NOAVX2=${BASH_REMATCH[3]^^} | ||
PLATFORM=${OS}-${ARCH}${NOAVX2} | ||
URL="${{ github.server_url }}/${{ github.repository }}/releases/download/${{ inputs.ref }}/$FILE" | ||
HASH=$(cat release/$FILE.sha256 | cut -d \t -f 1) | ||
echo "${PLATFORM},${URL},${HASH}" >> $RELLIST | ||
fi | ||
done | ||
SOURCE_FILE_NAME=$(ls release/tiledb-source-*.tar.gz) | ||
URL_TILEDB_SOURCE="${{ github.server_url }}/${{ github.repository }}/releases/download/${{ inputs.ref }}/$(basename $SOURCE_FILE_NAME)" | ||
HASH_TILEDB_SOURCE=$(cat $SOURCE_FILE_NAME.sha256 | cut -d \t -f 1) | ||
echo "source,${URL_TILEDB_SOURCE},${HASH_TILEDB_SOURCE}" >> $RELLIST | ||
HASH=$(sha256sum $RELLIST | cut -d " " -f 1) | ||
echo $HASH > $RELLIST.sha256 | ||
cat $RELLIST | ||
- name: Upload template to release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
file: output/* | ||
tag: ${{ steps.release_data.outputs.tag_name }} | ||
overwrite: true | ||
file_glob: true |
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
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,128 @@ | ||
# | ||
# FindTileDB_EP.cmake | ||
# | ||
# | ||
# The MIT License | ||
# | ||
# Copyright (c) 2023 TileDB, Inc. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
|
||
include(FetchContent) | ||
|
||
function(fetch_tiledb_release_list VERSION EXPECTED_HASH) | ||
# Local constants | ||
set(UPSTREAM_URL "https://github.com/TileDB-Inc/TileDB/releases/download") | ||
|
||
if(NOT VERSION) | ||
set(VERSION latest) | ||
endif() | ||
|
||
if(${EXPECTED_HASH}) | ||
file(DOWNLOAD | ||
${UPSTREAM_URL}/${VERSION}/releases.csv | ||
releases.csv | ||
SHOW_PROGRESS | ||
EXPECTED_HASH ${EXPECTED_HASH} | ||
) | ||
else() | ||
message(WARNING "Downloading release list without SHA checksum!") | ||
file(DOWNLOAD | ||
${UPSTREAM_URL}/${VERSION}/releases.csv | ||
releases.csv | ||
SHOW_PROGRESS | ||
) | ||
endif() | ||
|
||
file(STRINGS | ||
${CMAKE_CURRENT_BINARY_DIR}/releases.csv | ||
RELLIST | ||
) | ||
|
||
# Remove csv table headers | ||
list(POP_FRONT RELLIST) | ||
|
||
foreach(LINE ${RELLIST}) | ||
string(REPLACE "," ";" LINE ${LINE}) | ||
list(LENGTH LINE LENGTH) | ||
|
||
list(GET LINE 0 PLATFORM) | ||
list(GET LINE 1 URL) | ||
list(GET LINE 2 SHA) | ||
|
||
set(RELEASE_VAR TILEDB_${PLATFORM}) | ||
set(URL_${RELEASE_VAR} ${URL} PARENT_SCOPE) | ||
set(HASH_${RELEASE_VAR} ${SHA} PARENT_SCOPE) | ||
endforeach() | ||
endfunction() | ||
|
||
function(detect_artifact_name OUT_VAR) | ||
if (WIN32) # Windows | ||
SET(${OUT_VAR} TILEDB_WINDOWS-X86_64 PARENT_SCOPE) | ||
elseif(APPLE) # OSX | ||
if (DEFINED CMAKE_OSX_ARCHITECTURES) | ||
set(ACTUAL_TARGET ${CMAKE_OSX_ARCHITECTURES}) | ||
else() | ||
set(ACTUAL_TARGET ${CMAKE_SYSTEM_PROCESSOR}) | ||
endif() | ||
|
||
|
||
if (ACTUAL_TARGET MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)") | ||
SET(${OUT_VAR} TILEDB_MACOS-X86_64 PARENT_SCOPE) | ||
elseif (ACTUAL_TARGET STREQUAL arm64 OR ACTUAL_TARGET MATCHES "^aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") | ||
SET(${OUT_VAR} TILEDB_MACOS-ARM64 PARENT_SCOPE) | ||
endif() | ||
else() # Linux | ||
SET(${OUT_VAR} TILEDB_LINUX-X86_64 PARENT_SCOPE) | ||
endif() | ||
endfunction() | ||
|
||
function(fetch_prebuilt_tiledb) | ||
# Arguments | ||
set(options RELLIST_HASH) | ||
set(oneValueArgs VERSION ARTIFACT_NAME) | ||
set(multiValueArgs) | ||
cmake_parse_arguments( | ||
FETCH_PREBUILT_TILEDB | ||
"${options}" | ||
"${oneValueArgs}" | ||
"${multiValueArgs}" | ||
${ARGN} | ||
) | ||
|
||
fetch_tiledb_release_list(${FETCH_PREBUILT_TILEDB_VERSION} ${FETCH_PREBUILT_TILEDB_RELLIST_HASH}) | ||
|
||
if(NOT FETCH_PREBUILT_TILEDB_ARTIFACT_NAME) | ||
detect_artifact_name(FETCH_PREBUILT_TILEDB_ARTIFACT_NAME) | ||
endif() | ||
|
||
string(STRIP ${HASH_${FETCH_PREBUILT_TILEDB_ARTIFACT_NAME}} HASH_${FETCH_PREBUILT_TILEDB_ARTIFACT_NAME}) | ||
FetchContent_Declare( | ||
tiledb-prebuilt | ||
URL ${URL_${FETCH_PREBUILT_TILEDB_ARTIFACT_NAME}} | ||
URL_HASH SHA256=${HASH_${FETCH_PREBUILT_TILEDB_ARTIFACT_NAME}} | ||
DOWNLOAD_EXTRACT_TIMESTAMP FALSE | ||
) | ||
|
||
FetchContent_MakeAvailable( | ||
tiledb-prebuilt | ||
) | ||
|
||
set(TileDB_DIR "${tiledb-prebuilt_SOURCE_DIR}/lib/cmake/TileDB" PARENT_SCOPE) | ||
endfunction() |