diff --git a/.github/workflows/append-release-cmake.yml b/.github/workflows/append-release-cmake.yml new file mode 100644 index 00000000000..91a4e26e1c2 --- /dev/null +++ b/.github/workflows/append-release-cmake.yml @@ -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/github-full-release-data@v2.0.4 + 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 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bd5559d4469..8584e0d1870 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,6 @@ on: - 'release-*' tags: - '*' - workflow_dispatch: jobs: Package-Source-Release: @@ -175,6 +174,13 @@ jobs: }); } + Generate-Release-List: + needs: + - Publish-Release + uses: ./.github/workflows/append-release-cmake.yml + with: + ref: ${{ github.ref_name }} + Create-Issue-On-Fail: permissions: issues: write diff --git a/cmake/inputs/DownloadPrebuiltTileDB.cmake b/cmake/inputs/DownloadPrebuiltTileDB.cmake new file mode 100644 index 00000000000..608478abc34 --- /dev/null +++ b/cmake/inputs/DownloadPrebuiltTileDB.cmake @@ -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()