Skip to content
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
8 changes: 5 additions & 3 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ authors:
- given-names: Andrew
family-names: Nolan
orcid: 'https://orcid.org/0000-0002-9785-0196'
- given-names: Courtney
family-names: Shafer
orcid: 'https://orcid.org/0009-0001-3651-2812'
- family-names: Saenz
given-names: Juan
- given-names: Maciej
Expand All @@ -76,6 +79,5 @@ authors:
family-names: Smith
repository-code: 'https://github.com/MPAS-Dev/MPAS-Tools'
url: 'https://mpas-dev.github.io/MPAS-Tools/master/'
version: 1.2.2
date-released: '2025-06-15'

version: 1.3.0
date-released: '2025-08-15'
4 changes: 2 additions & 2 deletions conda_package/ci/linux_64_python3.10.____cpython.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ cxx_compiler:
cxx_compiler_version:
- '13'
docker_image:
- quay.io/condaforge/linux-anvil-cos7-x86_64
- quay.io/condaforge/linux-anvil-x86_64:alma9
fortran_compiler:
- gfortran
fortran_compiler_version:
- '13'
hdf5:
- 1.14.4
- 1.14.6
libnetcdf:
- 4.9.2
netcdf_fortran:
Expand Down
4 changes: 2 additions & 2 deletions conda_package/ci/linux_64_python3.11.____cpython.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ cxx_compiler:
cxx_compiler_version:
- '13'
docker_image:
- quay.io/condaforge/linux-anvil-cos7-x86_64
- quay.io/condaforge/linux-anvil-x86_64:alma9
fortran_compiler:
- gfortran
fortran_compiler_version:
- '13'
hdf5:
- 1.14.4
- 1.14.6
libnetcdf:
- 4.9.2
netcdf_fortran:
Expand Down
4 changes: 2 additions & 2 deletions conda_package/ci/linux_64_python3.12.____cpython.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ cxx_compiler:
cxx_compiler_version:
- '13'
docker_image:
- quay.io/condaforge/linux-anvil-cos7-x86_64
- quay.io/condaforge/linux-anvil-x86_64:alma9
fortran_compiler:
- gfortran
fortran_compiler_version:
- '13'
hdf5:
- 1.14.4
- 1.14.6
libnetcdf:
- 4.9.2
netcdf_fortran:
Expand Down
4 changes: 2 additions & 2 deletions conda_package/ci/linux_64_python3.13.____cpython.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ cxx_compiler:
cxx_compiler_version:
- '13'
docker_image:
- quay.io/condaforge/linux-anvil-cos7-x86_64
- quay.io/condaforge/linux-anvil-x86_64:alma9
fortran_compiler:
- gfortran
fortran_compiler_version:
- '13'
hdf5:
- 1.14.4
- 1.14.6
libnetcdf:
- 4.9.2
netcdf_fortran:
Expand Down
4 changes: 2 additions & 2 deletions conda_package/ci/linux_64_python3.9.____cpython.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ cxx_compiler:
cxx_compiler_version:
- '13'
docker_image:
- quay.io/condaforge/linux-anvil-cos7-x86_64
- quay.io/condaforge/linux-anvil-x86_64:alma9
fortran_compiler:
- gfortran
fortran_compiler_version:
- '13'
hdf5:
- 1.14.4
- 1.14.6
libnetcdf:
- 4.9.2
netcdf_fortran:
Expand Down
2 changes: 1 addition & 1 deletion conda_package/ci/osx_64_python3.10.____cpython.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fortran_compiler:
fortran_compiler_version:
- '13'
hdf5:
- 1.14.4
- 1.14.6
libnetcdf:
- 4.9.2
llvm_openmp:
Expand Down
2 changes: 1 addition & 1 deletion conda_package/ci/osx_64_python3.11.____cpython.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fortran_compiler:
fortran_compiler_version:
- '13'
hdf5:
- 1.14.4
- 1.14.6
libnetcdf:
- 4.9.2
llvm_openmp:
Expand Down
2 changes: 1 addition & 1 deletion conda_package/ci/osx_64_python3.12.____cpython.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fortran_compiler:
fortran_compiler_version:
- '13'
hdf5:
- 1.14.4
- 1.14.6
libnetcdf:
- 4.9.2
llvm_openmp:
Expand Down
2 changes: 1 addition & 1 deletion conda_package/ci/osx_64_python3.13.____cpython.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fortran_compiler:
fortran_compiler_version:
- '13'
hdf5:
- 1.14.4
- 1.14.6
libnetcdf:
- 4.9.2
llvm_openmp:
Expand Down
2 changes: 1 addition & 1 deletion conda_package/ci/osx_64_python3.9.____cpython.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fortran_compiler:
fortran_compiler_version:
- '13'
hdf5:
- 1.14.4
- 1.14.6
libnetcdf:
- 4.9.2
llvm_openmp:
Expand Down
12 changes: 7 additions & 5 deletions conda_package/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@
# General information about the project.
project = 'mpas_tools'
year = date.today().year
copyright = f'This software is open source software available under the BSD-3' \
f'license. Copyright (c) {year} Triad National Security, LLC. ' \
f'All rights reserved. Copyright (c) {year} Lawrence Livermore ' \
f'National Security, LLC. All rights reserved. Copyright (c) ' \
f'{year} UT-Battelle, LLC. All rights reserved.'
copyright = (
f'This software is open source software available under the BSD-3'
f'license. Copyright (c) {year} Triad National Security, LLC. '
f'All rights reserved. Copyright (c) {year} Lawrence Livermore '
f'National Security, LLC. All rights reserved. Copyright (c) '
f'{year} UT-Battelle, LLC. All rights reserved.'
)
author = 'MPAS-Tools development team'

# The version info for the project you're documenting, acts as replacement for
Expand Down
2 changes: 1 addition & 1 deletion conda_package/mpas_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version_info__ = (1, 2, 2)
__version_info__ = (1, 3, 0)
__version__ = '.'.join(str(vi) for vi in __version_info__)
2 changes: 1 addition & 1 deletion conda_package/recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "mpas_tools" %}
{% set version = "1.2.2" %}
{% set version = "1.3.0" %}

package:
name: {{ name|lower }}
Expand Down
149 changes: 149 additions & 0 deletions update_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
#! /usr/bin/env python
import argparse
import re
import sys
from datetime import date
from pathlib import Path


def parse_args():
parser = argparse.ArgumentParser(
description=(
"Bump version across files (CITATION.cff, __init__.py, meta.yaml)."
)
)
parser.add_argument(
"-v",
"--version",
required=True,
help="New version in the form X.Y.Z (e.g., 1.3.0)",
)
return parser.parse_args()


def ensure_semver(version: str):
m = re.fullmatch(r"(\d+)\.(\d+)\.(\d+)", version)
if not m:
sys.exit("Error: version must be in the form X.Y.Z (e.g., 1.3.0).")
return tuple(int(p) for p in m.groups())


def read_text(path: Path):
try:
return path.read_text(encoding="utf-8")
except FileNotFoundError:
return None


def write_text_if_changed(path: Path, content: str) -> bool:
old = read_text(path)
if old is None:
return False
if old != content:
path.write_text(content, encoding="utf-8")
return True
return False


def bump_citation(root: Path, version: str, today: str) -> bool:
path = root / "CITATION.cff"
content = read_text(path)
if content is None:
print(f"Skip (not found): {path}")
return False

# version: 1.2.1 -> version: 1.2.2
content_new = re.sub(
r"(?m)^(version:\s*)(.+)\s*$", rf"\g<1>{version}", content, count=1
)
# date-released: '2025-06-12' -> date-released: 'YYYY-MM-DD'
content_new = re.sub(
r"""(?m)^(date-released:\s*)['"]?\d{4}-\d{2}-\d{2}['"]?\s*$""",
rf"\g<1>'{today}'",
content_new,
count=1,
)
# Ensure a final newline at EOF
if not content_new.endswith("\n"):
content_new += "\n"

changed = write_text_if_changed(path, content_new)
if changed:
print(f"Updated: {path}")
else:
print(f"No changes: {path}")
return changed


def bump_init(pkg_dir: Path, version_tuple) -> bool:
path = pkg_dir / "mpas_tools" / "__init__.py"
content = read_text(path)
if content is None:
print(f"Skip (not found): {path}")
return False

major, minor, patch = version_tuple
content_new = re.sub(
r"(?m)^__version_info__\s*=\s*\(.+\)\s*$",
f"__version_info__ = ({major}, {minor}, {patch})",
content,
count=1,
)

changed = write_text_if_changed(path, content_new)
if changed:
print(f"Updated: {path}")
else:
print(f"No changes: {path}")
return changed


def bump_meta(recipe_dir: Path, version: str) -> bool:
path = recipe_dir / "meta.yaml"
content = read_text(path)
if content is None:
print(f"Skip (not found): {path}")
return False

# {% set version = "1.2.1" %} -> {% set version = "1.2.2" %}
content_new = re.sub(
r'(?m)^\{\%\s*set\s+version\s*=\s*["\']([^"\']+)["\']\s*\%\}',
f'{{% set version = "{version}" %}}',
content,
count=1,
)

changed = write_text_if_changed(path, content_new)
if changed:
print(f"Updated: {path}")
else:
print(f"No changes: {path}")
return changed


def main():
args = parse_args()
version = args.version.strip()
version_tuple = ensure_semver(version)
today = date.today().isoformat()

# Resolve repo layout relative to this script
script_dir = Path(__file__).resolve().parent
repo_root = script_dir
pkg_dir = script_dir / "conda_package"
recipe_dir = pkg_dir / "recipe"

changed = []
changed.append(bump_citation(repo_root, version, today))
changed.append(bump_init(pkg_dir, version_tuple))
changed.append(bump_meta(recipe_dir, version))

if not any(changed):
print("No files modified.")
return 0
print(f"Done. Bumped to {version} (date-released: {today}).")
return 0


if __name__ == "__main__":
raise SystemExit(main())
Loading