Skip to content

Commit a564e4e

Browse files
fix: fix extension semantic tag
In Slicer CI, the git repository is not initialized and querying the tag version fails with error code 128. fatal: not a git repository (or any of the parent directories): .git This fix makes semantic release update the CMake variable value directly.
1 parent 77aad48 commit a564e4e

File tree

3 files changed

+9
-22
lines changed

3 files changed

+9
-22
lines changed

.github/workflows/semantic-release.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ on: workflow_dispatch
55
jobs:
66
semantic-release:
77
runs-on: ubuntu-latest
8-
environment:
9-
name: pypi
10-
url: https://pypi.org/p/trame-slicer
118
permissions:
129
id-token: write # IMPORTANT: mandatory for trusted publishing
1310
contents: write # IMPORTANT: mandatory for making GitHub Releases
@@ -25,3 +22,4 @@ jobs:
2522
github_token: ${{ secrets.GITHUB_TOKEN }}
2623
changelog: true
2724
build: false # build is too complex to be handled by semantic release
25+
config_file: releaserc.toml

extension.cmake

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,10 @@ find_package(Slicer REQUIRED)
1313
include(${Slicer_USE_FILE})
1414

1515
#-----------------------------------------------------------------------------
16-
# Extension version
17-
find_program(GIT_EXECUTABLE NAMES git REQUIRED)
18-
execute_process(
19-
COMMAND "${GIT_EXECUTABLE}" "describe" "--tags" "--abbrev=0" "--match" "v[0-9]*"
20-
RESULT_VARIABLE git_code
21-
OUTPUT_VARIABLE git_stdout
22-
ERROR_VARIABLE git_stderr
23-
)
16+
# Extension version (auto updated by semantic version)
17+
set(LayerDM_VERSION "v0.0.0")
2418

25-
if(NOT git_code EQUAL 0)
26-
message(FATAL_ERROR "Failed to determined project version using Git.\n"
27-
"GIT_EXECUTABLE: ${GIT_EXECUTABLE}\n"
28-
"Return Code: ${git_code}\n"
29-
"Standard error:\n${git_stdout}\n"
30-
"Standard error:\n${git_stderr}\n"
31-
)
32-
endif()
33-
34-
string(STRIP "${git_stdout}" git_stdout) # git output will end with a newline
35-
string(SUBSTRING "${git_stdout}" 1 -1 LayerDM_VERSION) # remove first character
19+
string(SUBSTRING "${LayerDM_VERSION}" 1 -1 LayerDM_VERSION) # remove first character
3620
string(REPLACE "." ";" version_components "${LayerDM_VERSION}") # this creates a list
3721
list(GET version_components 0 LayerDM_VERSION_MAJOR)
3822
list(GET version_components 1 LayerDM_VERSION_MINOR)

releaserc.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[semantic_release]
2+
tag_format = "v{version}"
3+
version_variables = [
4+
"extension.cmake:LayerDM_VERSION:tf"
5+
]

0 commit comments

Comments
 (0)