Skip to content

Commit

Permalink
Generate add-on in out/
Browse files Browse the repository at this point in the history
  • Loading branch information
ikappaki committed Nov 9, 2024
1 parent 0486fa1 commit 01efa75
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Build package
run: poetry build && python scripts/bb_addon_create.py
- name: Upload release artifacts
run: gh release upload ${{ github.event.release.tag_name }} dist/*.{tar.gz,whl} dist/nrepl_panel_addon*.py
run: gh release upload ${{ github.event.release.tag_name }} dist/*.{tar.gz,whl} out/nrepl_panel_addon*.py
env:
GH_TOKEN: ${{ github.token }}
- name: Publish package distributions to PyPI
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ __pycache__/

.bb-tmp
dist/
out/

\#*#
.#*
Expand Down
14 changes: 8 additions & 6 deletions scripts/bb_addon_create.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# This script should be invoked from the project root directory.
#
# Copies the nrepl_panel_addon.py file to dist adding the version
# Copies the nrepl_panel_addon.py file to out/ adding the version
# number as retrieved from `poetry version`.
import os
import re
import subprocess

Expand All @@ -11,15 +12,16 @@
result = subprocess.run(["poetry", "version"], capture_output=True, text=True)
_, version = result.stdout.split(" ")
major, minor, patch = version.split(".")
patch_int = int(re.match(r'^\d+', patch).group())
patch_int = int(re.match(r"^\d+", patch).group())

dist_path = f'dist/nrepl_panel_addon_{version.strip().replace(".", "_")}.py'
os.makedirs("out", exist_ok=True)
out_path = f'out/nrepl_panel_addon_{version.strip().replace(".", "_")}.py'

with open(src_path, 'r') as src:
with open(dist_path, 'w', newline="\n") as dst:
with open(src_path, "r") as src:
with open(out_path, "w", newline="\n") as dst:
dst.write(f"# Autogenerated from {src_path}\n")
for line in src.readlines():
if version_mark in line:
line = line.replace(version_mark, f"({major}, {minor}, {patch_int})")
dst.write(line)
print(f":bb_addon_create.py :created {dist_path}")
print(f":bb_addon_create.py :created {out_path}")

0 comments on commit 01efa75

Please sign in to comment.