From 05164b70ddede597f3c86348d27577b617c3789c Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Thu, 9 Nov 2023 19:11:42 +0100 Subject: [PATCH 1/2] release: update CHANGELOG.md --- release.cmake | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/release.cmake b/release.cmake index d4bfae5d9..8a43c7235 100644 --- a/release.cmake +++ b/release.cmake @@ -49,6 +49,7 @@ macro(RELEASE_SETUP) if(UNIX) find_program(GIT git) + string(TIMESTAMP TODAY "%Y-%m-%d") # Set LD_LIBRARY_PATH if(APPLE) @@ -86,6 +87,28 @@ macro(RELEASE_SETUP) echo "Updated pyproject.toml and committed") ; fi) + add_custom_target( + release_changelog + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + COMMENT "Update CHANGELOG.md for $$VERSION on ${TODAY}" + COMMAND + echo "Updating CHANGELOG.md to $$VERSION" && sed -i.back + "\"s|\#\# \\[Unreleased\\]|\#\# [Unreleased]\\n\\n\#\# [$$VERSION] - ${TODAY}|\"" + CHANGELOG.md && sed -i.back + "\"s|^\\[Unreleased]: \\(https://.*compare/\\)\\(v.*\\)...HEAD|[Unreleased]: \\1v$$VERSION...HEAD\\n[$$VERSION]: \\1\\2...v$$VERSION|\"" + CHANGELOG.md && if ! (git diff --quiet CHANGELOG.md) ; then + (${GIT} + add + CHANGELOG.md + && + ${GIT} + commit + -m + "release: Update CHANGELOG.md for $$VERSION" + && + echo + "Updated CHANGELOG.md and committed") ; fi) + add_custom_target( release WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} @@ -100,8 +123,11 @@ macro(RELEASE_SETUP) release_package_xml) ; fi # Update version in pyproject.toml if it exists && if [ -f "pyproject.toml" ]; then (make -C ${CMAKE_BINARY_DIR} - release_pyproject_toml) ; fi && - ${GIT} tag -s v$$VERSION -m "Release of version $$VERSION." && cd + release_pyproject_toml) ; fi + # Update CHANGELOG.md if it exists + && if [ -f "CHANGELOG.md" ]; then (make -C ${CMAKE_BINARY_DIR} + release_changelog) ; fi && ${GIT} + tag -s v$$VERSION -m "Release of version $$VERSION." && cd ${CMAKE_BINARY_DIR} && cmake ${PROJECT_SOURCE_DIR} && make distcheck || (echo "Please fix distcheck first." From d769b7c0f0837399c21381c24ab4e8fd9b3b7220 Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Fri, 10 Nov 2023 11:19:23 +0100 Subject: [PATCH 2/2] release: use comments --- release.cmake | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/release.cmake b/release.cmake index 8a43c7235..5960325ce 100644 --- a/release.cmake +++ b/release.cmake @@ -61,20 +61,20 @@ macro(RELEASE_SETUP) add_custom_target( release_package_xml WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + COMMENT "Update package.xml" COMMAND - echo "Updating package.xml to $$VERSION" && sed -i.back - \"s|.*|$$VERSION|g\" package.xml - && rm package.xml.back && ${GIT} add package.xml && ${GIT} commit -m - "release: Update package.xml version to $$VERSION" && echo + sed -i.back \"s|.*|$$VERSION|g\" + package.xml && rm package.xml.back && ${GIT} add package.xml && ${GIT} + commit -m "release: Update package.xml version to $$VERSION" && echo "Updated package.xml and committed") add_custom_target( release_pyproject_toml WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + COMMENT "Update pyproject.toml" COMMAND - echo "Updating pyproject.toml to $$VERSION" && ${PYTHON_EXECUTABLE} - ${PROJECT_JRL_CMAKE_MODULE_DIR}/pyproject.py $$VERSION && if ! - (git diff --quiet pyproject.toml) ; then + ${PYTHON_EXECUTABLE} ${PROJECT_JRL_CMAKE_MODULE_DIR}/pyproject.py + $$VERSION && if ! (git diff --quiet pyproject.toml) ; then (${GIT} add pyproject.toml @@ -90,9 +90,9 @@ macro(RELEASE_SETUP) add_custom_target( release_changelog WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMENT "Update CHANGELOG.md for $$VERSION on ${TODAY}" + COMMENT "Update CHANGELOG.md" COMMAND - echo "Updating CHANGELOG.md to $$VERSION" && sed -i.back + sed -i.back "\"s|\#\# \\[Unreleased\\]|\#\# [Unreleased]\\n\\n\#\# [$$VERSION] - ${TODAY}|\"" CHANGELOG.md && sed -i.back "\"s|^\\[Unreleased]: \\(https://.*compare/\\)\\(v.*\\)...HEAD|[Unreleased]: \\1v$$VERSION...HEAD\\n[$$VERSION]: \\1\\2...v$$VERSION|\"" @@ -112,6 +112,7 @@ macro(RELEASE_SETUP) add_custom_target( release WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + COMMENT "Create a new release" COMMAND export LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} && export ${LD_LIBRARY_PATH_VARIABLE_NAME}=$ENV{${LD_LIBRARY_PATH_VARIABLE_NAME}}