Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incremental versioning #260

Merged
merged 6 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Release Versions:
- [2.0.0](#200)
- [1.0.0](#100)

## Upcoming changes (in development)

- Incremental versioning (#260)

## 5.0.0

Version 5.0.0 refactors the dynamical systems and controllers libraries with a
Expand Down
17 changes: 8 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ take several minutes.
3. Document the header files and public functions with doxygen comments, and update any relevant README.md
or documentation files with details of changes to the interface.
4. Update the [changelog](CHANGELOG.md) with your feature / fix / improvement in the "Upcoming changes" section.
5. Open a pull request into the `develop` branch. Write a meaningful title and description for the PR to make it
5. Update the version number using the [update_version.sh](./update_version.sh) script.
6. Open a pull request into the `develop` branch. Write a meaningful title and description for the PR to make it
clear what changes you have made, why you have made them, and how you have tested the changes.
6. You may merge the pull request into `develop` once you have the sign-off of one other developer and all CI tests pass.
7. You may merge the pull request into `develop` once you have the sign-off of one other developer and all CI tests pass.
Always use the "Squash and Merge" option to ensure your changes are contained within a single commit, maintaining
a linear git history. If unsure, you may request another reviewer to merge it for you.

Expand All @@ -94,19 +95,17 @@ The `develop` branch is always considered to be a "release candidate" that conta
code. If, at release time, there are features on `develop` that are considered unfinished or broken,
they can be marked as `EXPERIMENTAL` to exclude them from compilation.

At the time of release, a release branch should be made from development. In the release branch,
the project version number should be updated in the following locations:
- The [top-level CMakeLists](./source/CMakeLists.txt)
- The [python bindings setup.py](./python/setup.py)
- The [clproto bindings CMakeLists](./protocol/clproto_cpp/CMakeLists.txt)
- The PROJECT_NUMBER in the [doxygen config](./doxygen/doxygen.conf)
At the time of release, usually when there is minor or major version update,
a release branch should be made from development.

In addition, the release branch should be used to finalize the [changelog](CHANGELOG.md), which includes
The release branch should be used to finalize the [changelog](CHANGELOG.md), which includes
moving all content from the "Upcoming changes (in development)" header under a new header with the corresponding
release version.

Once the changes specific to the release have been approved, a linear GitFlow strategy is used to
merge this release branch into `main`, and then additionally squash and rebase the release branch back into `develop`.

The release on `main` should be tagged with the corresponding version as `vX.Y.Z`.

View and join the full discussion surrounding release workflow and strategy here: \
https://github.com/epfl-lasa/control-libraries/discussions/77
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5.0.1
3 changes: 1 addition & 2 deletions doxygen/doxygen.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ PROJECT_NAME = "Control Libraries"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 5.0.0
PROJECT_NUMBER = 4.1.0
PROJECT_NUMBER = 5.0.1

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion protocol/clproto_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.9)
project(clproto VERSION 5.0.0)
project(clproto VERSION 5.0.1)

set(CMAKE_CXX_STANDARD 17)

Expand Down
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import warnings
import os

__version__ = "5.0.0"
__version__ = "5.0.1"
__libraries__ = ['state_representation', 'clproto', 'dynamical_systems']
__include_dirs__ = ['include']

Expand Down
2 changes: 1 addition & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.9)

project(control-libraries VERSION 5.0.0)
project(control-libraries VERSION 5.0.1)

# Build options
option(BUILD_TESTING "Build all tests." OFF)
Expand Down
131 changes: 131 additions & 0 deletions update_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#!/bin/bash

VERSION=$(<VERSION)

DIFF_TYPE=''
DECREMENT=false
DRY_RUN=false
COMMIT=false

HELP_MESSAGE="Usage: ./update_version.sh [OPTIONS]

Update the project version number by one increment.
For the version number in the format \"major.minor.patch\",
the patch number will be incremented by default.

Supplying additional options to the script will change
the behaviour, either to set a specific version, update
the major or minor numbers, or to decrement instead.

This script modifies the version in the following files:
./source/CMakeLists.txt
./python/setup.py
./protocol/clproto_cpp/CMakeLists.txt
./doxygen/doxygen.conf

Options:
--major Update the major version number.
--minor Update the minor version number.

-v, --version <x.y.z> Set a specific version number.

-d, --downgrade Decrement instead of increment.

-c, --commit Automatically commit the change
to git source control.

-n, --dry-run Echo the new version but do not
write changes to any files.

-h, --help Show this help message."

while [ "$#" -gt 0 ]; do
case "$1" in
-v | --version) NEW_VERSION=$2; DIFF_TYPE=fixed; shift 2;;
--major) DIFF_TYPE=major; shift 1;;
--minor) DIFF_TYPE=minor; shift 1;;
-d | --downgrade) DECREMENT=true; shift 1;;
-c | --commit) COMMIT=true; shift 1;;
-n | --dry-run) DRY_RUN=true; shift 1;;
-h|--help) echo "${HELP_MESSAGE}"; exit 0;;

-*) echo "Unknown option: $1" >&2; echo "${HELP_MESSAGE}"; exit 1;;
esac
done

if [ "${COMMIT}" == true ]; then
STAGED_CHANGES=$(git diff --cached)
if [ "${STAGED_CHANGES}" ]; then
echo "Staged changes detected! Resolve to a clean working state before using the --commit option."
exit 1
fi
fi

function update_field() {
local FIELD=$1
if [ "${DECREMENT}" == true ]; then
if [ "${FIELD}" -ne "0" ]; then
FIELD=$(( FIELD - 1 ))
fi
else
FIELD=$(( FIELD + 1 ))
fi
echo "${FIELD}"
}

function update_version() {
# break down the version number into its components
regex="([0-9]+).([0-9]+).([0-9]+)"
if [[ "$VERSION" =~ ${regex} ]]; then
MAJOR="${BASH_REMATCH[1]}"
MINOR="${BASH_REMATCH[2]}"
BUILD="${BASH_REMATCH[3]}"
fi

# check parameter to see which number to increment
if [[ "${DIFF_TYPE}" == "major" ]]; then
MAJOR=$(update_field "${MAJOR}")
elif [[ "${DIFF_TYPE}" == "minor" ]]; then
MINOR=$(update_field "${MINOR}")
else
BUILD=$(update_field "${BUILD}")
fi

echo "${MAJOR}.${MINOR}.${BUILD}"
}

if [[ "${DIFF_TYPE}" != "fixed" ]]; then
NEW_VERSION=$(update_version)
fi

echo "Updating version from ${VERSION} to ${NEW_VERSION}"
if [ "${DRY_RUN}" == true ]; then
echo "Dry run complete. Exiting without changing any files"
exit 0
fi

SED_STR_VERSION="s/${VERSION}/${NEW_VERSION}/g"
SED_STR_SOURCE="s/project(control-libraries VERSION ${VERSION})/project(control-libraries VERSION ${NEW_VERSION})/g"
SED_STR_PYTHON="s/__version__ = \"${VERSION}\"/__version__ = \"${NEW_VERSION}\"/g"
SED_STR_CLPROTO="s/project(clproto VERSION ${VERSION})/project(clproto VERSION ${NEW_VERSION})/g"
SED_STR_DOXYGEN="s/PROJECT_NUMBER = ${VERSION}/PROJECT_NUMBER = ${NEW_VERSION}/g"

if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "${SED_STR_VERSION}" ./VERSION
sed -i '' "${SED_STR_SOURCE}" ./source/CMakeLists.txt
sed -i '' "${SED_STR_PYTHON}" ./python/setup.py
sed -i '' "${SED_STR_CLPROTO}" ./protocol/clproto_cpp/CMakeLists.txt
sed -i '' "${SED_STR_DOXYGEN}" ./doxygen/doxygen.conf
else
sed -i "${SED_STR_VERSION}" ./VERSION
sed -i "${SED_STR_SOURCE}" ./source/CMakeLists.txt
sed -i "${SED_STR_PYTHON}" ./python/setup.py
sed -i "${SED_STR_CLPROTO}" ./protocol/clproto_cpp/CMakeLists.txt
sed -i "${SED_STR_DOXYGEN}" ./doxygen/doxygen.conf
fi

if [ "${COMMIT}" == true ]; then
echo "Committing changes to source control"
git add VERSION ./source/CMakeLists.txt ./python/setup.py ./protocol/clproto_cpp/CMakeLists.txt ./doxygen/doxygen.conf
git commit -m "${VERSION} -> ${NEW_VERSION}"
fi