Skip to content

Commit

Permalink
ci: 🎡 add version number to executable
Browse files Browse the repository at this point in the history
  • Loading branch information
soul-codes committed Oct 15, 2024
1 parent fbb86e5 commit ab86346
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/build_exe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+-?*"
pull_request:
branches:
- main
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -70,6 +73,16 @@ jobs:
- name: Install PyInstaller
run: pip install pyinstaller

- name: Print version string (for tag)
id: get_version_tag
if: ${{ github.ref_type == 'tag' }}
run: echo ${{ github.ref_name }} > VERSION

- name: Print version string (for branch)
id: get_version_branch
if: ${{ github.ref_type != 'tag' }}
run: echo ${{ github.ref_name }}-${{ github.sha }} > VERSION

- name: Build the executable
run: |
pyinstaller pyinstaller.spec
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.5.0-alpha.0
15 changes: 15 additions & 0 deletions components/splash.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
from terminal_tools import clear_terminal, wait_for_key
from pathlib import Path
import os


def splash():
clear_terminal()
print(_ascii_splash)
print("")
print(f"{get_version()}")
print("")
wait_for_key(True)


def get_version():
root_path = str(Path(__file__).resolve().parent.parent)
version_path = os.path.join(root_path, "VERSION")
try:
with open(version_path, "r") as version_file:
return version_file.read().strip()
except FileNotFoundError:
return "<development version>"


_ascii_splash: str = """
-..*+:..-
-.=-+%@%##+-=.-
Expand Down
6 changes: 6 additions & 0 deletions pyinstaller.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ a = Analysis(
pathex=['.'], # Ensure all paths are correctly included
binaries=[],
datas=[
# version file, if defined
*(
[('VERSION', 'VERSION')]
if os.path.exists('VERSION') else []
),

# inquirer depends on readchar as a hidden dependency that requires package metadata
*copy_metadata('readchar'),

Expand Down

0 comments on commit ab86346

Please sign in to comment.