Skip to content

Commit

Permalink
Merge branch 'release-2.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
AnsArn committed Dec 3, 2024
2 parents 8372cda + dedd444 commit 1bf0008
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 15 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@ build: --install-build-deps ## Build COSIPY package
$(PYTHON) -m build
@twine check dist/*

# .PHONY
# bump-version:
# @grep -Po '\bversion\s*=\s*"\K.*?(?=")' pyproject.toml
bump-version:
@bash bump_version.sh

.PHONY:
upload-pypi: # Private: upload COSIPY package
Expand Down
102 changes: 102 additions & 0 deletions bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/bash
# 2024 Nicolas Gampierakis.

# Applies semantic versioning across project

DIRECTORY=""
VERBOSE=0
BRANCH=""

DisplayHelp() {
intro_tag="$(basename "$0") [-h] -- semantic versioning tool"
options="OPTIONS
-h, --help Display help.
-d, --directory [path] Path to target directory, relative to current
working directory.
-v, --verbose Verbosity flag.
"
printf "\n%s\n\n%s\n" "$intro_tag" "$options"
}

#######################################
# Get project version number
#
# Arguments:
# Keyword for version number in file.
# File path.
#######################################
get_version_number() {
match_string="${1}"
file_name="${2}"
version_number=$(grep -oP '\b'"${match_string}"'\s*=\s*"\K.*?(?=")' "${file_name}")
}

#######################################
# Set project version number
#
# Arguments:
# Project root directory.
#######################################
set_version_number() {
toml_file="${1}pyproject.toml"
docs_file="${1}docs/source/conf.py"
version_number=""
get_version_number "version" "${toml_file}"
current_py_version="${version_number}"
get_version_number "release" "${docs_file}"
current_docs_version="${version_number}"
current_version="${current_py_version}"

new_version=${BRANCH#"release-"}
if [ "${new_version}" != "${current_version}" ]; then
printf "%s\n" "Current branch: ${BRANCH}" >&2
printf "%s\n" "Previous version number: ${current_version}" >&2
printf "%s\n" "New version number: ${new_version}" >&2
sed -i "s/${current_py_version}/${new_version}/g" "${toml_file}"
sed -i "s/${current_docs_version}/${new_version}/g" "${docs_file}"
git add "${toml_file}" "${docs_file}"
git commit -m "build: bump version number to ${new_version}"
else
printf "%s\n" "Current and new version numbers are identical: ${current_version}" >&2
fi
}

ARGS=$(getopt -o "hd:v" --long "help,directory:,verbose" -- "$@") || exit
eval "set -- $ARGS"
while true; do
case $1 in
-h | --help)
DisplayHelp
exit 0
;;
-d | --directory)
DIRECTORY=$2
shift 2
;;
-v | --verbose)
((VERBOSE++))
shift
;;
--)
shift
break
;;
*) exit 1 ;; # error
esac
done
remaining=("$@")

if [[ ! $DIRECTORY ]]; then
DIRECTORY="${PWD}/"
else
DIRECTORY="${PWD}/${DIRECTORY}"
fi
readonly DIRECTORY

BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [[ "$BRANCH" != *"release-"* ]]; then
echo "Please switch to a release branch."
exit 1
fi

set_version_number "${DIRECTORY}"
4 changes: 2 additions & 2 deletions cosipy/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ def conftest_hide_plot():


@pytest.fixture(name="conftest_rng_seed", scope="function", autouse=False)
def fixture_conftest_rng_seed() -> np.random.Generator:
def fixture_conftest_rng_seed():
"""Set seed for random number generator to 444.
Returns:
Random number generator with seed=444.
np.random.Generator: Random number generator with seed=444.
"""

random_generator = np.random.default_rng(seed=444)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
project = "COSIPY"
copyright = f"2019-{date.today().year}, COSIPY Contributors"
author = "COSIPY Contributors"
release = "2.0"
release = "2.0.2"

# -- General configuration ---------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
get\_user\_confirmation
=======================

.. currentmodule:: cosipy.utilities.setup_cosipy.setup_cosipy

.. autofunction:: get_user_confirmation
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
setup\_cosipy
setup\_cosipy
=============

.. currentmodule:: cosipy.utilities.setup_cosipy
Expand All @@ -21,8 +21,8 @@ setup\_cosipy
copy_file_to_target
get_sample_directory
get_user_arguments
get_user_confirmation
main
strtobool



Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "cosipymodel"
version = "2.0.1"
version = "2.0.2"
authors = [
{ name = "COSIPY Contributors", email = "" },
]
Expand Down

0 comments on commit 1bf0008

Please sign in to comment.