Merge branch 'improve-versioning' into calamares
This commit is contained in:
commit
71dc9349ad
@ -40,13 +40,23 @@
|
|||||||
|
|
||||||
# TODO:3.3: Require CMake 3.12
|
# TODO:3.3: Require CMake 3.12
|
||||||
cmake_minimum_required( VERSION 3.3 FATAL_ERROR )
|
cmake_minimum_required( VERSION 3.3 FATAL_ERROR )
|
||||||
|
|
||||||
|
set( CALAMARES_VERSION 3.2.40 )
|
||||||
|
set( CALAMARES_RELEASE_MODE OFF )
|
||||||
|
|
||||||
|
if ( CMAKE_SCRIPT_MODE_FILE )
|
||||||
|
include( ${CMAKE_CURRENT_LIST_DIR}/CMakeModules/ExtendedVersion.cmake )
|
||||||
|
set( CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} )
|
||||||
|
extend_version( ${CALAMARES_VERSION} OFF _vshort _vlong )
|
||||||
|
message( "${_vlong}" )
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
project( CALAMARES
|
project( CALAMARES
|
||||||
VERSION 3.2.40
|
VERSION ${CALAMARES_VERSION}
|
||||||
LANGUAGES C CXX
|
LANGUAGES C CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
set( CALAMARES_VERSION_RC 1 ) # Set to 0 during release cycle, 1 during development
|
|
||||||
|
|
||||||
### OPTIONS
|
### OPTIONS
|
||||||
#
|
#
|
||||||
option( INSTALL_CONFIG "Install configuration files" OFF )
|
option( INSTALL_CONFIG "Install configuration files" OFF )
|
||||||
@ -180,6 +190,7 @@ include( FeatureSummary )
|
|||||||
|
|
||||||
# Calamares Modules
|
# Calamares Modules
|
||||||
include( CMakeColors )
|
include( CMakeColors )
|
||||||
|
include( ExtendedVersion )
|
||||||
|
|
||||||
### C++ SETUP
|
### C++ SETUP
|
||||||
#
|
#
|
||||||
@ -494,41 +505,21 @@ add_feature_info( ExampleDistro ${mksquashfs_FOUND} "Create example-distro targe
|
|||||||
|
|
||||||
### CALAMARES PROPER
|
### CALAMARES PROPER
|
||||||
#
|
#
|
||||||
set( CALAMARES_VERSION ${CALAMARES_VERSION_MAJOR}.${CALAMARES_VERSION_MINOR}.${CALAMARES_VERSION_PATCH} )
|
#
|
||||||
# In rare cases we have hotfix-releases with a tweak
|
extend_version( "${CALAMARES_VERSION}" ${CALAMARES_RELEASE_MODE} CALAMARES_VERSION_SHORT CALAMARES_VERSION )
|
||||||
if( CALAMARES_VERSION_TWEAK )
|
|
||||||
set( CALAMARES_VERSION "${CALAMARES_VERSION}.${CALAMARES_VERSION_TWEAK}" )
|
|
||||||
endif()
|
|
||||||
set( CALAMARES_VERSION_SHORT "${CALAMARES_VERSION}" )
|
|
||||||
if( CALAMARES_VERSION_RC )
|
|
||||||
set( CALAMARES_VERSION ${CALAMARES_VERSION}rc${CALAMARES_VERSION_RC} )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Additional info for non-release builds. The "extended" version information
|
# Special target for displaying the version. In RC (might-be-release)
|
||||||
# with date and git information (commit, dirty status) is used only
|
# builds, use the short version (3.x.y), otherwise show the long version.
|
||||||
# by CalamaresVersionX.h, which is included by consumers that need a full
|
if ( CALAMARES_RELEASE_MODE )
|
||||||
# version number with all that information; normal consumers can include
|
|
||||||
# CalamaresVersion.h with more stable numbers.
|
|
||||||
if( NOT BUILD_RELEASE AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git/" )
|
|
||||||
include( CMakeDateStamp )
|
|
||||||
set( CALAMARES_VERSION_DATE "${CMAKE_DATESTAMP_YEAR}${CMAKE_DATESTAMP_MONTH}${CMAKE_DATESTAMP_DAY}" )
|
|
||||||
if( CALAMARES_VERSION_DATE GREATER 0 )
|
|
||||||
set( CALAMARES_VERSION ${CALAMARES_VERSION}.${CALAMARES_VERSION_DATE} )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include( CMakeVersionSource )
|
|
||||||
if( CMAKE_VERSION_SOURCE )
|
|
||||||
set( CALAMARES_VERSION ${CALAMARES_VERSION}-${CMAKE_VERSION_SOURCE} )
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Special target for not-RC (e.g. might-be-release) builds.
|
|
||||||
# This is used by the release script to get the version.
|
|
||||||
if ( CALAMARES_VERSION_RC EQUAL 0 )
|
|
||||||
add_custom_target(show-version
|
add_custom_target(show-version
|
||||||
${CMAKE_COMMAND} -E echo CALAMARES_VERSION=${CALAMARES_VERSION_SHORT}
|
${CMAKE_COMMAND} -E echo CALAMARES_VERSION=${CALAMARES_VERSION_SHORT}
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
)
|
)
|
||||||
|
else()
|
||||||
|
add_custom_target(show-version
|
||||||
|
${CMAKE_COMMAND} -E echo CALAMARES_VERSION=${CALAMARES_VERSION}
|
||||||
|
USES_TERMINAL
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# enforce using constBegin, constEnd for const-iterators
|
# enforce using constBegin, constEnd for const-iterators
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
# === This file is part of Calamares - <https://calamares.io> ===
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause
|
|
||||||
#
|
|
||||||
###
|
|
||||||
#
|
|
||||||
# Find today's date, for versioning purposes.
|
|
||||||
find_program(DATE_EXECUTABLE NAMES date)
|
|
||||||
mark_as_advanced(DATE_EXECUTABLE)
|
|
||||||
|
|
||||||
if(DATE_EXECUTABLE)
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${DATE_EXECUTABLE} +%Y
|
|
||||||
OUTPUT_VARIABLE CMAKE_DATESTAMP_YEAR
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${DATE_EXECUTABLE} +%m
|
|
||||||
OUTPUT_VARIABLE CMAKE_DATESTAMP_MONTH
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${DATE_EXECUTABLE} +%d
|
|
||||||
OUTPUT_VARIABLE CMAKE_DATESTAMP_DAY
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
endif()
|
|
@ -1,52 +0,0 @@
|
|||||||
# === This file is part of Calamares - <https://calamares.io> ===
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause
|
|
||||||
#
|
|
||||||
###
|
|
||||||
#
|
|
||||||
# Try to identify the current development source version.
|
|
||||||
set(CMAKE_VERSION_SOURCE "")
|
|
||||||
if(EXISTS ${CMAKE_SOURCE_DIR}/.git/HEAD)
|
|
||||||
find_program(GIT_EXECUTABLE NAMES git git.cmd)
|
|
||||||
mark_as_advanced(GIT_EXECUTABLE)
|
|
||||||
if(GIT_EXECUTABLE)
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${GIT_EXECUTABLE} rev-parse --verify -q --short=7 HEAD
|
|
||||||
OUTPUT_VARIABLE head
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
if(head)
|
|
||||||
set(branch "")
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${GIT_EXECUTABLE} name-rev HEAD
|
|
||||||
OUTPUT_VARIABLE branch
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
string(REGEX REPLACE "HEAD " "" branch "${branch}")
|
|
||||||
set(CMAKE_VERSION_SOURCE "git-${branch}-${head}")
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${GIT_EXECUTABLE} update-index -q --refresh
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD --
|
|
||||||
OUTPUT_VARIABLE dirty
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
if(dirty)
|
|
||||||
set(CMAKE_VERSION_SOURCE "${CMAKE_VERSION_SOURCE}-dirty")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
elseif(EXISTS ${CMAKE_SOURCE_DIR}/CVS/Repository)
|
|
||||||
file(READ ${CMAKE_SOURCE_DIR}/CVS/Repository repo)
|
|
||||||
set(branch "")
|
|
||||||
if("${repo}" MATCHES "\\.git/")
|
|
||||||
string(REGEX REPLACE ".*\\.git/([^\r\n]*).*" "-\\1" branch "${repo}")
|
|
||||||
endif()
|
|
||||||
set(CMAKE_VERSION_SOURCE "cvs${branch}")
|
|
||||||
endif()
|
|
75
CMakeModules/ExtendedVersion.cmake
Normal file
75
CMakeModules/ExtendedVersion.cmake
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
# === This file is part of Calamares - <https://calamares.io> ===
|
||||||
|
#
|
||||||
|
# SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
|
||||||
|
# SPDX-FileCopyrightText: 2021 Adriaan de Groot <groot@kde.org>
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
#
|
||||||
|
###
|
||||||
|
#
|
||||||
|
# This file defines one function for extending a VERSION-like value
|
||||||
|
# with date and git information (if desired).
|
||||||
|
#
|
||||||
|
# - extend_version( version-string short_only short_var long_var )
|
||||||
|
# Calling this function will copy *version-string* (which would typically
|
||||||
|
# be a semver-style string, like "3.2.40") into the variable *short_var*.
|
||||||
|
# If *short_only* is true, then:
|
||||||
|
# - the short version is also copied into the variable *long_var*,
|
||||||
|
# If *short_only* is false, then:
|
||||||
|
# - the *version-string* plus date and git information, is copied
|
||||||
|
# into the varialbe *long_var*, in the format {version}-{date}-{hash}
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
function( get_git_version_info out_var )
|
||||||
|
set(CMAKE_VERSION_SOURCE "")
|
||||||
|
if(EXISTS ${CMAKE_SOURCE_DIR}/.git/HEAD)
|
||||||
|
find_program(GIT_EXECUTABLE NAMES git git.cmd)
|
||||||
|
mark_as_advanced(GIT_EXECUTABLE)
|
||||||
|
if(GIT_EXECUTABLE)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} rev-parse --verify -q --short=8 HEAD
|
||||||
|
OUTPUT_VARIABLE head
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
if(head)
|
||||||
|
set(CMAKE_VERSION_SOURCE "${head}")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} update-index -q --refresh
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD --
|
||||||
|
OUTPUT_VARIABLE dirty
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
if(dirty)
|
||||||
|
set(CMAKE_VERSION_SOURCE "${CMAKE_VERSION_SOURCE}-dirty")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
set( ${out_var} "${CMAKE_VERSION_SOURCE}" PARENT_SCOPE )
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function( extend_version version short_only short_var long_var )
|
||||||
|
set( ${short_var} "${version}" PARENT_SCOPE )
|
||||||
|
set( _v "${version}" )
|
||||||
|
if ( NOT short_only )
|
||||||
|
# Additional info for non-release builds which want "long" version info
|
||||||
|
# with date and git information (commit, dirty status). That is used only
|
||||||
|
# by CalamaresVersionX.h, which is included by consumers that need a full
|
||||||
|
# version number with all that information; normal consumers can include
|
||||||
|
# CalamaresVersion.h with more stable numbers.
|
||||||
|
string( TIMESTAMP CALAMARES_VERSION_DATE "%Y%m%d" )
|
||||||
|
if( CALAMARES_VERSION_DATE GREATER 0 )
|
||||||
|
set( _v ${_v}.${CALAMARES_VERSION_DATE} )
|
||||||
|
endif()
|
||||||
|
get_git_version_info( _gitv )
|
||||||
|
if( _gitv )
|
||||||
|
set( _v "${_v}-${_gitv}" )
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
set( ${long_var} "${_v}" PARENT_SCOPE )
|
||||||
|
endfunction()
|
@ -27,7 +27,8 @@
|
|||||||
|
|
||||||
## (1) Preparation
|
## (1) Preparation
|
||||||
|
|
||||||
* Drop the RC variable to 0 in `CMakeLists.txt`, *CALAMARES_VERSION_RC*.
|
* Double-check the *CALAMARES_VERSION* value at the top of `CMakeLists.txt`.
|
||||||
|
* Set *CALAMARES_RELEASE_MODE* to `ON` in `CMakeLists.txt`.
|
||||||
* Edit `CHANGES` and set the date of the release.
|
* Edit `CHANGES` and set the date of the release.
|
||||||
* Commit both. This is usually done with commit-message
|
* Commit both. This is usually done with commit-message
|
||||||
*Changes: pre-release housekeeping*.
|
*Changes: pre-release housekeeping*.
|
||||||
@ -78,8 +79,8 @@ Follow the instructions printed by the release script.
|
|||||||
|
|
||||||
## (4) Post-Release
|
## (4) Post-Release
|
||||||
|
|
||||||
* Bump the version number in `CMakeLists.txt` in the `project()` command.
|
* Bump the version number in `CMakeLists.txt` in *CALAMARES_VERSION*.
|
||||||
* Set *CALAMARES_VERSION_RC* back to 1.
|
* Set *CALAMARES_RELEASE_MODE* back to `OFF`.
|
||||||
* Add a placeholder entry for the next release in `CHANGES` with date
|
* Add a placeholder entry for the next release in `CHANGES` with date
|
||||||
text *not released yet*.
|
text *not released yet*.
|
||||||
* Commit and push that, usually with the message
|
* Commit and push that, usually with the message
|
||||||
|
Loading…
Reference in New Issue
Block a user