Add script that updates the version in the README (#39)
This commit is contained in:
parent
14b59ee3b1
commit
56d5440fd2
7
.github/workflows/main.yml
vendored
7
.github/workflows/main.yml
vendored
@ -4,7 +4,7 @@ on:
|
|||||||
- cron: "0 */4 * * *"
|
- cron: "0 */4 * * *"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
repository_dispatch:
|
repository_dispatch:
|
||||||
types: [pypi_release]
|
types: [ pypi_release ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -30,3 +30,8 @@ jobs:
|
|||||||
- run: pre-commit-mirror --language python --package-name ruff --entry 'ruff check --force-exclude' --id ruff --types-or python --types-or pyi --require-serial --description "Run 'ruff' for extremely fast Python linting" .
|
- run: pre-commit-mirror --language python --package-name ruff --entry 'ruff check --force-exclude' --id ruff --types-or python --types-or pyi --require-serial --description "Run 'ruff' for extremely fast Python linting" .
|
||||||
|
|
||||||
- run: git push origin HEAD:refs/heads/main --tags
|
- run: git push origin HEAD:refs/heads/main --tags
|
||||||
|
|
||||||
|
- name: "Update version in README.md"
|
||||||
|
run: python update_version.py
|
||||||
|
|
||||||
|
- run: git push origin HEAD:refs/heads/main
|
||||||
|
24
update_version.py
Normal file
24
update_version.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
"""Updates the version in the readme and git commit."""
|
||||||
|
|
||||||
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
from subprocess import check_call, check_output
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
readme_md = Path("README.md")
|
||||||
|
readme = readme_md.read_text()
|
||||||
|
rev = Path(".version").read_text().strip()
|
||||||
|
readme = re.sub("rev: .*", f"rev: v{rev}", readme)
|
||||||
|
readme_md.write_text(readme)
|
||||||
|
# Only commit on change
|
||||||
|
# https://stackoverflow.com/a/9393642/3549270
|
||||||
|
if check_output(["git", "status", "-s"]).strip():
|
||||||
|
check_call(["git", "add", readme_md])
|
||||||
|
check_call(["git", "commit", "-m", f"Bump README.md version to {rev}"])
|
||||||
|
else:
|
||||||
|
print("No change")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user