Skip to content

Commit

Permalink
ci: remove code.json, update scripts, fix release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Jun 17, 2024
1 parent 006b6ba commit e5b0385
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 272 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ jobs:
pip install .
pip install ".[lint, test]"
- name: Make code.md
run: make-code-json
- name: Make metadata files
uses: nick-fields/retry@v3
with:
timeout_seconds: 10
max_attempts: 3
command: make-code-json

- name: Upload code.md
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -68,12 +72,16 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}
run: |
ver="${{ steps.version.outputs.version }}"
# remove metadata files
rm code.json
rm code.md
# commit and push changes
git config core.sharedRepository true
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add pymake
git add -A
git commit -m "ci(release): set version to ${{ steps.version.outputs.version }}"
git push origin "${{ github.ref_name }}"
Expand Down Expand Up @@ -118,7 +126,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
version=$(python scripts/update_version.py -g)
version=$(cat version.txt)
title="pymake $version"
notes=$(cat code.md)
gh release create "$version" \
Expand Down
233 changes: 0 additions & 233 deletions code.json

This file was deleted.

41 changes: 6 additions & 35 deletions scripts/update_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import argparse
import json
import re
import textwrap
from datetime import datetime
Expand All @@ -15,7 +14,6 @@

# file names and the path to the file relative to the repo root directory
file_paths_list = [
_project_root_path / "code.json",
_project_root_path / "README.md",
_project_root_path / "version.txt",
_project_root_path / "pymake" / "config.py",
Expand All @@ -28,7 +26,6 @@ def split_nonnumeric(s):
return [s[: match.start()], s[match.start() :]] if match else s


_initial_version = Version("0.0.1")
_current_version = Version(_version_txt_path.read_text().strip())


Expand Down Expand Up @@ -93,28 +90,6 @@ def update_readme_markdown(version: Version) -> None:
print(f"Updated {fpth} to version {version}")


def update_codejson(version: Version) -> None:
"""Update code.json
Parameters
----------
version : Version
version number
"""
# define json filename
json_fname = file_paths["code.json"]

# load and modify json file
data = json.loads(json_fname.read_text())

# rewrite the json file
with open(json_fname, "w", encoding="utf8") as f:
json.dump(data, f, indent=4)
f.write("\n")

print(f"Updated {json_fname} to version {version}")


def update_version(
timestamp: datetime = datetime.now(),
version: Version = None,
Expand Down Expand Up @@ -143,7 +118,6 @@ def update_version(
update_version_txt(version)
update_version_py(timestamp, version)
update_readme_markdown(version)
update_codejson(version)
finally:
try:
lock_path.unlink()
Expand All @@ -157,12 +131,11 @@ def update_version(
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=textwrap.dedent(
"""\
Update version information stored in version.txt in the project
root, as well as several other files in the repository. If
--version is not provided, the version number will not be
changed. A file lock is held to synchronize file access. The
version tag must comply with standard '<major>.<minor>.<patch>'
format conventions for semantic versioning.
Update version information stored in version.txt in the project root
and other files in the repository. If --version is not provided, the
version number will not be changed. The version tag must comply with
'<major>.<minor>.<patch>' format convention for semantic versioning.
To show the version without changing anything, use --get (short -g).
"""
),
)
Expand All @@ -183,9 +156,7 @@ def update_version(
args = parser.parse_args()

if args.get:
print(
Version((_project_root_path / "version.txt").read_text().strip())
)
print(_current_version)
else:
update_version(
timestamp=datetime.now(),
Expand Down

0 comments on commit e5b0385

Please sign in to comment.