Skip to content

Commit

Permalink
ends
Browse files Browse the repository at this point in the history
  • Loading branch information
masqu3rad3 committed Dec 17, 2024
1 parent aa4cf3d commit b034bba
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ jobs:
if not exist "package\build\TikManager4_v${{ env.VERSION }}.exe" exit 1
shell: cmd

- name: Read Sanitized Release Notes
id: read_release_notes
run: |
sanitized_notes_file="package/build/ReleaseNotes_v${{ env.VERSION }}.md"
if [ ! -f "$sanitized_notes_file" ]; then
echo "Error: Sanitized release notes not found: $sanitized_notes_file"
exit 1
fi
release_notes=$(cat "$sanitized_notes_file")
echo "release_notes<<EOF" >> $GITHUB_ENV
echo "$release_notes" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
shell: bash

- name: Upload Release Assets
uses: actions/upload-artifact@v3
with:
Expand Down
42 changes: 41 additions & 1 deletion package/release_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# set the TIK_DCC environment variable
os.environ["TIK_DCC"] = "null"

import logging
import re
import subprocess

from pathlib import Path
Expand All @@ -17,8 +19,8 @@

INNO_SETUP_EXE = Path("C:\\Program Files (x86)\\Inno Setup 6\\ISCC.exe")
PACKAGE_ROOT = Path(__file__).parent
# INNO_SCRIPT = Path(__file__).parent / "tik_manager4_innosetup_debug.iss"

LOG = logging.getLogger(__name__)

class ReleaseUtility:
"""Class to handle the releases."""
Expand All @@ -32,14 +34,18 @@ def __init__(self, debug_mode=False):

def freeze(self):
"""Freeze the application using pyinstaller."""
LOG.info("\nStarting Freeze Process.\n")
subprocess.call(
["pyinstaller", self.spec_file_name, "--clean", "--noconfirm"],
cwd=self.tik_root,
shell=True,
)
LOG.info("Freeze Process Completed.")
LOG.info("-------------------------")

def inno_setup(self):
"""Compile the installer using inno setup."""
LOG.info("\nStarting Inno Setup.\n")
if not INNO_SETUP_EXE.exists():
raise FileNotFoundError("Inno Setup not found at the specified location.")
sys.stdout.write("Starting Inno Setup.")
Expand All @@ -50,7 +56,40 @@ def inno_setup(self):
injector.replace_single_line(app_line, "#define appVersion")

subprocess.call([str(INNO_SETUP_EXE), str(self.inno_script_path)], shell=True)
LOG.info("Inno Setup completed.")
LOG.info("---------------------")

def extract_and_sanitize_release_notes(self):
"""Extract and sanitize the release notes."""
LOG.info("\nExtracting and sanitizing release notes.\n")
relase_notes = PACKAGE_ROOT.parent / "RELEASE_NOTES.md"
content = relase_notes.read_text()

# Match the target version section and capture its notes
version_pattern = re.compile(
rf"##\s+v{re.escape(self.release_version)}\n(.*?)(?:\n##|$)",
re.DOTALL
)

match = version_pattern.search(content)
if not match:
sanitized_notes = "No release notes found."
LOG.warning(f"Version v%s not found in release notes.", self.release_version)
else:
notes = match.group(1).strip()
# Remove brackets and their content
sanitized_notes = re.sub(r"\[.*?\]\s*", "", notes)

(PACKAGE_ROOT / "build").mkdir(exist_ok=True)

# add the ## What's Changed at the beginning of the sanitized notes
sanitized_notes = f"## What's Changed\n\n{sanitized_notes}"

output_file = PACKAGE_ROOT / "build" / f"ReleaseNotes_v{self.release_version}.md"
output_file.write_text(sanitized_notes)

LOG.info("Release notes extracted and saved to %s", output_file)
return output_file

if __name__ == "__main__":
# get the arguments from sys
Expand All @@ -59,5 +98,6 @@ def inno_setup(self):
_debug_mode = any([opt in ("-d", "--debug") for opt, _ in opts])
release_utility = ReleaseUtility(debug_mode=_debug_mode)
release_utility.freeze()
release_utility.extract_and_sanitize_release_notes()
if not _debug_mode:
release_utility.inno_setup()

0 comments on commit b034bba

Please sign in to comment.