Skip to content

Commit 3cf32b8

Browse files
authored
ci(cicd-wkflow): add version updater for documentation before release (python-semantic-release#1141)
* chore(config): adjust build command & doc version bump script implementation
1 parent 9bdd626 commit 3cf32b8

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

.github/workflows/cicd.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ jobs:
6767
needs: eval-changes
6868
with:
6969
python-versions-linux: '["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]'
70-
# Since the test suite takes ~4 minutes to complete on windows, and windows is billed higher
71-
# we are only going to run it on the oldest version of python we support. The older version
72-
# will be the most likely area to fail as newer minor versions maintain compatibility.
7370
python-versions-windows: '["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]'
7471
files-changed: ${{ needs.eval-changes.outputs.any-file-changes }}
7572
build-files-changed: ${{ needs.eval-changes.outputs.build-changes }}
@@ -116,6 +113,22 @@ jobs:
116113
name: ${{ needs.validate.outputs.distribution-artifacts }}
117114
path: dist
118115

116+
- name: Evaluate | Determine Next Version
117+
id: version
118+
uses: ./
119+
with:
120+
github_token: ${{ secrets.GITHUB_TOKEN }}
121+
root_options: "-v --noop"
122+
123+
- name: Release | Bump Version in Docs
124+
if: steps.version.outputs.released == 'true' && steps.version.outputs.is_prerelease == 'false'
125+
env:
126+
NEW_VERSION: ${{ steps.version.outputs.version }}
127+
NEW_RELEASE_TAG: ${{ steps.version.outputs.tag }}
128+
run: |
129+
python -m scripts.bump_version_in_docs
130+
git add docs/*
131+
119132
- name: Release | Python Semantic Release
120133
id: release
121134
uses: ./

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,6 @@ ignore_names = ["change_to_ex_proj_dir", "init_example_project"]
400400
logging_use_named_masks = true
401401
commit_parser = "angular"
402402
build_command = """
403-
python -m scripts.bump_version_in_docs
404-
git add docs/*
405403
python -m pip install -e .[build]
406404
python -m build .
407405
"""

scripts/bump_version_in_docs.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,38 @@
33

44
from os import getenv
55
from pathlib import Path
6-
from re import compile as RegExp # noqa: N812
6+
from re import compile as regexp
77

88
PROJ_DIR = Path(__file__).resolve().parent.parent
99
DOCS_DIR = PROJ_DIR / "docs"
1010

1111

12-
def update_github_actions_example(filepath: Path, new_version: str) -> None:
13-
psr_regex = RegExp(r"(uses:.*python-semantic-release)@v\d+\.\d+\.\d+")
12+
def update_github_actions_example(filepath: Path, release_tag: str) -> None:
13+
psr_regex = regexp(r"(uses: python-semantic-release/python-semantic-release)@\S+$")
14+
psr_publish_action_regex = regexp(
15+
r"(uses: python-semantic-release/publish-action)@\S+$"
16+
)
1417
file_content_lines: list[str] = filepath.read_text().splitlines()
1518

16-
for regex in [psr_regex]:
19+
for regex in [psr_regex, psr_publish_action_regex]:
1720
file_content_lines = list(
1821
map(
19-
lambda line, regex=regex: regex.sub(r"\1@v" + new_version, line), # type: ignore[misc]
22+
lambda line, regex=regex: regex.sub(r"\1@" + release_tag, line), # type: ignore[misc]
2023
file_content_lines,
2124
)
2225
)
2326

24-
print(f"Bumping version in {filepath} to", new_version)
27+
print(f"Bumping version in {filepath} to", release_tag)
2528
filepath.write_text(str.join("\n", file_content_lines) + "\n")
2629

2730

2831
if __name__ == "__main__":
29-
new_version = getenv("NEW_VERSION")
32+
new_release_tag = getenv("NEW_RELEASE_TAG")
3033

31-
if not new_version:
32-
print("NEW_VERSION environment variable is not set")
34+
if not new_release_tag:
35+
print("NEW_RELEASE_TAG environment variable is not set")
3336
exit(1)
3437

3538
update_github_actions_example(
36-
DOCS_DIR / "automatic-releases" / "github-actions.rst", new_version
39+
DOCS_DIR / "automatic-releases" / "github-actions.rst", new_release_tag
3740
)

0 commit comments

Comments
 (0)