Skip to content

Commit

Permalink
Merge pull request #118 from xsuite/release/v0.5.9
Browse files Browse the repository at this point in the history
Release 0.5.9
  • Loading branch information
freddieknets authored Oct 28, 2024
2 parents d26142b + bdc6267 commit b88c6b0
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 484 deletions.
166 changes: 0 additions & 166 deletions gh.py

This file was deleted.

87 changes: 2 additions & 85 deletions make_release_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,91 +4,8 @@
# Copyright (c) CERN, 2024. #
# ######################################### #

import sys
import platform
from gh import *
from xaux.tools import dev_make_release_branch
# sys.tracebacklimit = 0

class VersionError(OSError):
pass


# Check necessary setup and installs
assert_git_repo()
assert_poetry_installed()


# Check the script arguments
if len(sys.argv) != 2:
raise ValueError("This script needs exactly one argument: the new version number or a bump. "
"The latter can be: patch, minor, major.")
bump = sys.argv[1]


# Check our working directory is clean
git_assert_working_tree_clean()
branch = git_current_branch()
if branch != "main":
raise GitError("This script needs to be ran on the main branch.")
git_push() # Sync with the remote to be sure we don't delete an incomplete branch later
git_pull()
expected_ver = poetry_get_expected_version(bump)


# Check that we are not accidentally bumping a major version
major_ver = int(expected_ver.split('.')[0])
if major_ver != 0:
raise VersionError("Bumping a major version! If this is really what you want, "
"then adapt make_release_branch.py manually.")


# Confirm version bump
branch = f"release/v{expected_ver}"
expected_ver = f"{expected_ver}rc0"
current_ver = poetry_get_version()
print(f"Bumping from {current_ver} to {expected_ver}.")
print("Type y to continue (or anything else to cancel):")
answer = input()
if answer not in ["y", "Y"]:
print("Cancelled.")
sys.exit(1)


# Create release branch
print("Creating release branch...")
git_switch(branch, create=True)


# Update version in the release branch
print("Poetry version bump...")
poetry_bump_version(expected_ver)
new_ver = poetry_get_version()
if new_ver != expected_ver:
raise VersionError(f"Fatal error: `poetry --dry-run` expected {expected_ver}, but result is {new_ver}..."
"Need to recover manually!")


# Adapt version files
for file, pattern in zip(["xcoll/general.py", "tests/test_version.py"],
["__version__ = ", " assert __version__ == "]):
file_adapted = False
with Path(file).open("r") as fid:
lines = fid.readlines()
with Path(file).open("w") as fid:
for line in lines:
if line.startswith(pattern):
fid.write(f"{pattern}'{new_ver}'\n")
file_adapted = True
else:
fid.write(line)
if not file_adapted:
raise VersionError(f"Fatal error: could not adapt {file}...")


# Commit and push
git_add(['pyproject.toml', 'xcoll/general.py', 'tests/test_version.py'])
git_commit(f"Created release branch release/v{new_ver}.", no_verify=True)
git_push(set_upstream=True)

print("All done!")

dev_make_release_branch("xcoll")
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "xcoll"
version = "0.5.8"
version = "0.5.9"
description = "Xsuite collimation package"
homepage = "https://github.com/xsuite/xcoll"
repository = "https://github.com/xsuite/xcoll"
Expand All @@ -25,14 +25,14 @@ python = ">=3.8"
ruamel-yaml = { version = "^0.17.31", optional = true }
numpy = ">=1.0"
pandas = ">=1.4"
xobjects = ">=0.2.6"
xdeps = ">=0.1.1"
xpart = ">=0.15.0"
xtrack = ">=0.36.5"
xfields = ">=0.12.1"
xobjects = ">=0.4.5"
xdeps = ">=0.7.3"
xpart = ">=0.19.1"
xtrack = ">=0.69.7"

[tool.poetry.dev-dependencies]
pytest = ">=7.3"
xaux = ">=0.2.1"

[tool.poetry.extras]
tests = ["pytest", "ruamel-yaml"]
Expand Down
Loading

0 comments on commit b88c6b0

Please sign in to comment.