Skip to content

Commit 78d3ee4

Browse files
authored
Merge pull request #1252 from PyThaiNLP/copilot/update-version-and-docs
Complete bump-my-version integration: add automated version and date updates for CITATION.cff/codemeta.json
2 parents fbe0ced + 56be1a2 commit 78d3ee4

3 files changed

Lines changed: 147 additions & 33 deletions

File tree

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,13 @@ This will create distribution packages in the `dist/` directory.
175175
#current_version = 2.3.3
176176

177177
bump-my-version bump patch
178-
#current_version = 2.3.6-dev0
178+
#current_version = 2.3.4-dev0
179179

180180
bump-my-version bump minor
181-
#current_version = 2.3.1-dev0
181+
#current_version = 2.4.0-dev0
182182

183183
bump-my-version bump build
184-
#current_version = 2.3.1-dev1
184+
#current_version = 2.4.0-dev1
185185

186186
bump-my-version bump major
187187
#current_version = 3.0.0-dev0

pyproject.toml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ dependencies = [
7070
# Development and testing dependencies
7171
dev = [
7272
"black>=25.11.0",
73-
"bump-my-version>=1.2.6 ",
73+
"build>=1.0.0",
74+
"bump-my-version>=1.2.6",
7475
"coverage>=7.10.7",
7576
"flake8>=7.3.0",
7677
"ruff>=0.14.14",
@@ -275,6 +276,28 @@ filename = "pythainlp/__init__.py"
275276
search = '__version__ = "{current_version}"'
276277
replace = '__version__ = "{new_version}"'
277278

279+
[[tool.bumpversion.files]]
280+
filename = "CITATION.cff"
281+
search = 'version: {current_version}'
282+
replace = 'version: {new_version}'
283+
284+
[[tool.bumpversion.files]]
285+
filename = "CITATION.cff"
286+
regex = true
287+
search = 'date-released: \d{{4}}-\d{{2}}-\d{{2}}'
288+
replace = 'date-released: {now:%Y-%m-%d}'
289+
290+
[[tool.bumpversion.files]]
291+
filename = "codemeta.json"
292+
search = '"version": "{current_version}"'
293+
replace = '"version": "{new_version}"'
294+
295+
[[tool.bumpversion.files]]
296+
filename = "codemeta.json"
297+
regex = true
298+
search = '"dateModified": "\d{{4}}-\d{{2}}-\d{{2}}"'
299+
replace = '"dateModified": "{now:%Y-%m-%d}"'
300+
278301
[tool.bumpversion.parts.release]
279302
optional_value = "prod"
280303
first_value = "dev"

release.md

Lines changed: 120 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,130 @@ SPDX-License-Identifier: CC0-1.0
66

77
# How to cut a new release
88

9-
0. Check if the package can be built properly.
10-
Include "[cd build]" in the commit message to trigger wheel building.
11-
1. Update `CHANGELOG.md` with a short summary of important changes since
12-
the previous stable release.
13-
For example, deprecation or termination of support.
14-
2. This project follows [semantic versioning][semver].
15-
Ensure the version and release date fields in these files
16-
have been updated to the version of the new planned release:
17-
- `codemeta.json`
18-
- `pyproject.toml`
19-
- `CHANGELOG.md`
20-
- `CITATION.cff` (will auto-generated from `codemeta.json`)
21-
- `README.md`
22-
- `README.TH.md`
23-
4. Navigate to the [releases page][releases] and click the
9+
This project follows [semantic versioning][semver].
10+
11+
## Prerequisites
12+
13+
Install development dependencies including `bump-my-version`:
14+
15+
```sh
16+
pip install -e ".[dev]"
17+
```
18+
19+
## Release Process
20+
21+
1. **Check if the package can be built properly**
22+
23+
Build the package locally to ensure there are no build errors:
24+
25+
```sh
26+
python -m build
27+
```
28+
29+
You can also include `[cd build]` in a commit message to trigger wheel
30+
building in CI.
31+
32+
2. **Update CHANGELOG.md**
33+
34+
Update `CHANGELOG.md` with a short summary of important changes since
35+
the previous stable release. For example, deprecation or termination
36+
of support. Follow the [Keep a Changelog][keepachangelog] format.
37+
38+
3. **Update version using bump-my-version**
39+
40+
We use [`bump-my-version`][bump-my-version] to manage version numbers.
41+
The configuration is in `pyproject.toml` under `[tool.bumpversion]`.
42+
43+
Version format: `MAJOR.MINOR.PATCH[-RELEASE][BUILD]`
44+
where RELEASE can be `dev`, `beta`, or omitted (production).
45+
46+
**To bump the version:**
47+
48+
```sh
49+
# For a patch release (e.g., 5.2.0 -> 5.2.1-dev0)
50+
bump-my-version bump patch
51+
52+
# For a minor release (e.g., 5.2.0 -> 5.3.0-dev0)
53+
bump-my-version bump minor
54+
55+
# For a major release (e.g., 5.2.0 -> 6.0.0-dev0)
56+
bump-my-version bump major
57+
58+
# To move from dev to beta (e.g., 5.2.1-dev0 -> 5.2.1-beta0)
59+
bump-my-version bump release
60+
61+
# To move from beta to production (e.g., 5.2.1-beta0 -> 5.2.1)
62+
bump-my-version bump release
63+
64+
# To increment build number (e.g., 5.2.1-dev0 -> 5.2.1-dev1)
65+
bump-my-version bump build
66+
```
67+
68+
This command will automatically update version numbers and release dates in:
69+
- `pyproject.toml` - version number
70+
- `pythainlp/__init__.py` - version number
71+
- `CITATION.cff` - version number and `date-released` field
72+
- `codemeta.json` - version number and `dateModified` field
73+
74+
The release dates are automatically set to the current date when you run
75+
the bump command.
76+
77+
It will also create a git commit and tag by default.
78+
79+
4. **Update README files if needed**
80+
81+
If the release introduces significant changes, update:
82+
- `README.md`
83+
- `README_TH.md`
84+
85+
5. **Push changes and tag**
86+
87+
```sh
88+
git push origin dev
89+
git push origin --tags
90+
```
91+
92+
6. **Create GitHub Release**
93+
94+
Navigate to the [releases page][releases] and click the
2495
"Draft a new release" button.
2596
Only project maintainers are able to perform this step.
26-
5. Then enter the new tag in the "Choose a tag" box.
27-
The tag should begin with "v", as in, for instance, `v5.0.1`.
28-
6. The release title should be the same as the new version tag.
29-
For instance, the title could be `v5.0.1`.
30-
7. Add a short summary of important changes since the previous stable
31-
release.
32-
_This should be similar to what has been logged in `CHANGELOG.md`._
33-
Then click the "Generate release notes" button.
34-
8. You can optionally include any particular thank-yous to contributors or
35-
reviewers in a note at the bottom of the release.
36-
9. You can then click "Publish release" button.
37-
10. If [the CI][ci] run is [successful][actions],
38-
then the release will be published on both
39-
the GitHub release page and the [Python Package Index][pypi].
97+
98+
7. **Select the tag**
99+
100+
In the "Choose a tag" dropdown, select the tag that was created by
101+
`bump-my-version` (e.g., `v5.2.1`). Tags follow the format `vMAJOR.MINOR.PATCH`.
102+
103+
8. **Set release title**
104+
105+
The release title should be the same as the version tag
106+
(e.g., `v5.2.1`).
107+
108+
9. **Add release notes**
109+
110+
Add a short summary of important changes since the previous stable
111+
release. This should be similar to what has been logged in `CHANGELOG.md`.
112+
Then click the "Generate release notes" button to auto-generate
113+
contributor information.
114+
115+
10. **Optional: Thank contributors**
116+
117+
You can optionally include any particular thank-yous to contributors or
118+
reviewers in a note at the bottom of the release.
119+
120+
11. **Publish the release**
121+
122+
Click the "Publish release" button.
123+
124+
12. **Verify CI/CD**
125+
126+
If [the CI][ci] run is [successful][actions],
127+
then the release will be published on both
128+
the GitHub release page and the [Python Package Index][pypi].
40129

41130
[semver]: https://semver.org/
131+
[keepachangelog]: https://keepachangelog.com/en/1.0.0/
132+
[bump-my-version]: https://github.com/callowayproject/bump-my-version
42133
[releases]: https://github.com/PyThaiNLP/pythainlp/releases
43134
[ci]: https://github.com/PyThaiNLP/pythainlp/blob/dev/.github/workflows/pypi-publish.yml
44135
[actions]: https://github.com/PyThaiNLP/pythainlp/actions/workflows/pypi-publish.yml

0 commit comments

Comments
 (0)