Skip to content

Commit 52ee7c9

Browse files
authored
Fix new release script to use correct version and hash sum (#507)
* fix new release script to use correct version and hash sum * update logging behaviour
1 parent 699c7a0 commit 52ee7c9

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

.github/workflows/publish.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
- name: Set CPM version by tag
1616
run: |
1717
mkdir dist
18-
sed -e "s/1.0.0-development-version/${GITHUB_REF/refs\/tags\//v}/g" cmake/CPM.cmake > dist/CPM.cmake
19-
sed -e "s/1.0.0-development-version/${GITHUB_REF/refs\/tags\//v}/g" \
20-
-e "s/EMPTY_HASH_SUM/$(sha256sum cmake/CPM.cmake | cut -d' ' -f1)/" cmake/get_cpm.cmake > dist/get_cpm.cmake
18+
sed -e "s/1.0.0-development-version/${GITHUB_REF/refs\/tags\/v}/g" cmake/CPM.cmake > dist/CPM.cmake
19+
sed -e "s/1.0.0-development-version/${GITHUB_REF/refs\/tags\/v}/g" \
20+
-e "s/CPM_HASH_SUM_PLACEHOLDER/$(sha256sum dist/CPM.cmake | cut -d' ' -f1)/" cmake/get_cpm.cmake > dist/get_cpm.cmake
2121
2222
- name: Upload CPM.cmake to release
2323
uses: svenstaro/upload-release-action@v1-release

cmake/get_cpm.cmake

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
44

55
set(CPM_DOWNLOAD_VERSION 1.0.0-development-version)
6-
set(CPM_HASH_SUM "HASH_SUM_PLACEHOLDER")
6+
set(CPM_HASH_SUM "CPM_HASH_SUM_PLACEHOLDER")
77

88
if(CPM_SOURCE_CACHE)
99
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
@@ -16,20 +16,21 @@ endif()
1616
# Expand relative path. This is important if the provided path contains a tilde (~)
1717
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
1818

19-
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
19+
message(STATUS "Using CPM at ${CPM_DOWNLOAD_LOCATION}")
20+
2021
file(
2122
DOWNLOAD
2223
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
2324
${CPM_DOWNLOAD_LOCATION}
2425
STATUS CPM_DOWNLOAD_STATUS
2526
EXPECTED_HASH SHA256=${CPM_HASH_SUM}
2627
)
28+
2729
list(GET CPM_DOWNLOAD_STATUS 0 CPM_DOWNLOAD_STATUS_CODE)
28-
list(GET CPM_DOWNLOAD_STATUS 1 CPM_DOWNLOAD_ERROR_MESSAGE)
29-
if(${CPM_DOWNLOAD_STATUS_CODE} EQUAL 0)
30-
message(STATUS "CPM: Download completed successfully.")
31-
else()
32-
message(FATAL_ERROR "CPM: Error occurred during download: ${CPM_DOWNLOAD_ERROR_MESSAGE}")
30+
if(NOT ${CPM_DOWNLOAD_STATUS_CODE} EQUAL 0)
31+
# give a fatal error when download fails
32+
list(GET CPM_DOWNLOAD_STATUS 1 CPM_DOWNLOAD_ERROR_MESSAGE)
33+
message(FATAL_ERROR "Error occurred during download of CPM: ${CPM_DOWNLOAD_ERROR_MESSAGE}")
3334
endif()
3435

3536
include(${CPM_DOWNLOAD_LOCATION})

0 commit comments

Comments
 (0)