Skip to content

Commit

Permalink
Updated to qcio 0.10.2. Added release.py script.
Browse files Browse the repository at this point in the history
  • Loading branch information
coltonbh committed Jul 13, 2024
1 parent 067afe3 commit d598c59
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repos:
hooks:
- id: mypy
additional_dependencies:
[pydantic>=2.0.0, types-paramiko, qcio>=0.10.1]
[pydantic>=2.0.0, types-paramiko, qcio>=0.10.1, types-toml]
- repo: local
hooks:
- id: tests
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [unreleased]

### Added

- `release.py` script for automated releases.

### Changed

- Upgraded to `qcio 0.10.2` which reverts back to the default of `Structure.identifiers` instead of `Structure.ids`.
- Fix depreciated call to `qcparse.parse_results` for the TeraChem adapter.

## [0.7.2] - 2024-07-12

### Added
Expand Down
19 changes: 15 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ description = "A package for operating Quantum Chemistry programs using qcio sta
authors = ["Colton Hicks <github@coltonhicks.com>"]
license = "MIT"
readme = "README.md"
repository = "https://github.com/coltonbh/qcop"
homepage = "https://github.com/coltonbh/qcop"

[tool.poetry.dependencies]
python = "^3.8"
qcparse = "^0.6.0"
qcio = "^0.10.1"
qcio = "^0.10.2"

# A list of all of the optional dependencies, some of which are included in the below
# `extras`. They can be opted into by apps.
Expand All @@ -36,6 +37,7 @@ geometric = "^1.0.1"
qcelemental = "^0.26.0"
qcengine = "^0.27.0"
xtb = "^22.1"
types-toml = "^0.10.8.20240310"

[build-system]
requires = ["poetry-core"]
Expand Down
2 changes: 1 addition & 1 deletion qcop/adapters/terachem.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def compute_results(
stdout = execute_subprocess(
self.program, [input_filename], update_func, update_interval
)
parsed_output = qcparse.parse_results(stdout, self.program, "stdout")
parsed_output = qcparse.parse(stdout, self.program, "stdout")
return parsed_output, stdout

def collect_wfn(self) -> Dict[str, Union[str, bytes]]:
Expand Down
83 changes: 83 additions & 0 deletions scripts/release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import subprocess
import sys
from datetime import datetime

import toml


def get_repo_url():
"""Get the repository URL from pyproject.toml or ask the user for it."""
try:
with open("pyproject.toml", "r") as file:
pyproject = toml.load(file)
repo_url = pyproject["tool"]["poetry"]["repository"]
return repo_url
except KeyError:
return input("Enter the repository URL (e.g., https://github.com/user/repo): ")


def update_version_with_poetry(version):
"""Update the version in pyproject.toml using Poetry."""
print("Updating version in pyproject.toml...")
subprocess.run(["poetry", "version", version], check=True)


def update_changelog(version, repo_url):
"""Update the CHANGELOG.md file with the new version and today's date."""
print("Updating CHANGELOG.md...")
with open("CHANGELOG.md", "r") as file:
lines = file.readlines()

today = datetime.today().strftime("%Y-%m-%d")
new_entry = f"\n## [{version}] - {today}\n"

# Insert the new entry after the ## [unreleased] section
for i, line in enumerate(lines):
if line.startswith("## [unreleased]"):
lines.insert(i + 1, new_entry)
break

# Update links at the bottom
unreleased_link = f"[unreleased]: {repo_url}/compare/{version}...HEAD\n"
new_version_link = f"[{version}]: {repo_url}/releases/tag/{version}\n"

# Ensure the new version link is added right after the [unreleased] link
for i, line in enumerate(lines):
if line.startswith("[unreleased]:"):
lines[i] = unreleased_link
lines.insert(i + 1, new_version_link)
break

with open("CHANGELOG.md", "w") as file:
file.writelines(lines)


def run_git_commands(version):
"""Run the git commands to commit the changes, create a new tag, and push."""
print("Running git commands...")
subprocess.run(["git", "add", "."], check=True)
subprocess.run(
["git", "commit", "-m", f"Bumped version to {version}. Updated CHANGELOG."],
check=True,
)
subprocess.run(["git", "tag", version], check=True)
subprocess.run(["git", "push", "--tags"], check=True)
subprocess.run(["git", "push"], check=True)


def main():
"""Main entry point for the script."""
if len(sys.argv) != 2:
print("Usage: release.py <version>")
sys.exit(1)

version = sys.argv[1]

repo_url = get_repo_url()
update_version_with_poetry(version)
update_changelog(version, repo_url)
run_git_commands(version)


if __name__ == "__main__":
main()

0 comments on commit d598c59

Please sign in to comment.