From 01efa75a06c562973e1a515a19f278e4a74ffe69 Mon Sep 17 00:00:00 2001 From: ikappaki Date: Sat, 9 Nov 2024 22:29:57 +0000 Subject: [PATCH] Generate add-on in out/ --- .github/workflows/release.yaml | 2 +- .gitignore | 1 + scripts/bb_addon_create.py | 14 ++++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 25ab035..a681a51 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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 diff --git a/.gitignore b/.gitignore index ae9093e..89570b8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ __pycache__/ .bb-tmp dist/ +out/ \#*# .#* diff --git a/scripts/bb_addon_create.py b/scripts/bb_addon_create.py index 95187a9..55172d7 100644 --- a/scripts/bb_addon_create.py +++ b/scripts/bb_addon_create.py @@ -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 @@ -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}")