Skip to content

Commit c7d2409

Browse files
committed
Merge branch 'main' into develop
2 parents be8d67c + 4ec626b commit c7d2409

File tree

8 files changed

+89
-119
lines changed

8 files changed

+89
-119
lines changed

.bumpversion.cfg

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[bumpversion]
2+
current_version = 1.1.0
3+
commit = True
4+
tag = True
5+
6+
[bumpversion:file:pyproject.toml]
7+
search = version = "{current_version}"
8+
replace = version = "{new_version}"
9+
10+
[bumpversion:file:CHANGELOG.md]
11+
search = ## [Unreleased]
12+
replace = ## [Unreleased]\\n\\n## [{new_version}] - {now:%Y-%m-%d}

.github/workflows/release-package.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323

2424
- name: Install Python dependencies
2525
run: |
26-
pip install setuptools wheel toml bump2version
27-
pip install -e .
26+
pip install -e ".[dev]"
27+
pip install build
2828
2929
# TODO: Add a better way to determine type of version change
3030
- name: Determine Bump Type
@@ -40,8 +40,8 @@ jobs:
4040
run: |
4141
git config --local user.email "[email protected]"
4242
git config --local user.name "GitHub Action"
43-
python bump_version.py ${{ env.bump_type }}
44-
PACKAGE_VERSION=$(python -c 'import toml; print(toml.load("pyproject.toml")["project"]["version"])')
43+
python release.py ${{ env.bump_type }}
44+
PACKAGE_VERSION=$(sed -n 's/^version *= *"\(.*\)"/\1/p' pyproject.toml)
4545
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
4646
4747
- name: Build Package

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
dist/
22
assets/jsconfig.json
33

4+
dist/
45
# cache
56
**/__pycache__
67
# IDE specific

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ and this project adheres to
1010

1111
### Fixed
1212

13+
- Removed poetry from dependencies for building and releasing the package.
14+
- Consolidate the bumping of versions to better leverage `bump2version`.
15+
- `bump_version.py` script is now renamed `release.py`.
16+
- Removed `toml` as a dev dependency.
17+
18+
### Fixed
19+
1320
- Add back series in the `_index.md` when creating a new series and and remove
1421
the self-reference at the template level in hugo
1522

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ execute:
7575
1. Install the website package and its development dependencies, follow these
7676
steps:
7777
```bash
78-
uv pip install -e .[dev]
78+
uv pip install -e ".[dev]"
7979
```
8080
2. `website --help` should list the relevant output
8181

@@ -86,8 +86,10 @@ execute:
8686

8787
## Bumping package version and updating changelog
8888

89-
I'm maintaining a `CHANGELOG.md` for keeping track of changes made to the python
90-
package. The script `bump_version.py` in the project root provides the utilities
91-
needed for releasing a new tagged version to remote. The github action
92-
`.github/workflows/release-package.yaml` is using this script and is triggered
93-
via a manual dispatch.
89+
Using the script `release.py`, `bump2version` and the github action
90+
`.github/workflows/release-package.yaml` I'm automating my package release
91+
process.
92+
93+
Each new release has a section in the `CHANGELOG.md` under the `[Unreleased]`
94+
section for keeping track of changes made to the python package since the last
95+
release.

bump_version.py

Lines changed: 0 additions & 86 deletions
This file was deleted.

pyproject.toml

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,37 @@
11
[build-system]
2-
requires = ["setuptools >= 61.0"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "website"
7-
version = "1.0.6"
7+
version = "1.1.0"
88
description = "Automation and build tools for my website"
9-
authors = ["Rohail Taimour"]
10-
license = "MIT"
9+
authors = [
10+
{ name = "Rohail Taimour" }
11+
]
1112
packages = [
12-
{ include = "website" },
13+
{ include = "website" }
1314
]
15+
license = { text = "MIT License" }
1416
dependencies = [
1517
"typer>=0.12.3",
1618
]
19+
readme = "README.md"
1720
requires-python = ">=3.10"
1821

19-
[project.optional-dependencies.dev]
20-
black = ">=23.7.0"
21-
isort = ">=5.12.0"
22-
pre-commit = ">=3.3.3"
23-
flake8 = ">=6.1.0"
24-
bump2version = ">=1.0.1"
25-
toml = ">=0.10.2"
26-
22+
[project.optional-dependencies]
23+
dev = [
24+
"black>=23.7.0",
25+
"isort>=5.12.0",
26+
"pre-commit>=3.3.3",
27+
"flake8>=6.1.0",
28+
"bump2version>=1.0.1"
29+
]
2730
[project.scripts]
2831
website = "website.entrypoints:app"
2932
new-post = 'website.entrypoints:new_post'
3033
list-draft-posts = 'website.entrypoints:list_draft_posts'
3134

32-
[tool.bumpversion]
33-
commit = true
34-
tag = true
35-
36-
[[tool.bumpversion.file]]
37-
filename = "CHANGELOG.md"
38-
search = "## [Unreleased]"
39-
replace = "## [Unreleased]\n\n## [{new_version}] - {now:%Y-%m-%d}"
40-
4135
[tool.black]
4236
line-length = 88
4337
target-version = ['py310']

release.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import subprocess
2+
import sys
3+
4+
5+
def bump_version(bump_type):
6+
subprocess.run(["bump2version", bump_type], check=True)
7+
8+
# Extract the new version from bump2version's output
9+
result = subprocess.run(
10+
["bump2version", "--dry-run", "--list", bump_type],
11+
capture_output=True,
12+
text=True,
13+
)
14+
new_version = None
15+
for line in result.stdout.splitlines():
16+
if line.startswith("new_version="):
17+
new_version = line.split("=")[-1]
18+
19+
if not new_version:
20+
print("Error: Failed to determine the new version.")
21+
sys.exit(1)
22+
return new_version
23+
24+
25+
def main():
26+
bump_type = "patch"
27+
28+
if len(sys.argv) > 1:
29+
if sys.argv[1] not in ["patch", "minor", "major"]:
30+
print("Invalid bump type. Use 'patch', 'minor', or 'major'.")
31+
sys.exit(1)
32+
bump_type = sys.argv[1]
33+
34+
# Bump the version
35+
new_version = bump_version(bump_type)
36+
print(f"Bumped version to {new_version}")
37+
38+
39+
if __name__ == "__main__":
40+
main()

0 commit comments

Comments
 (0)