Skip to content

Commit

Permalink
automatically show the latest tag/release
Browse files Browse the repository at this point in the history
  • Loading branch information
marph91 committed Oct 6, 2024
1 parent fa5505e commit 00d0525
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
python -c 'from pypandoc.pandoc_download import download_pandoc; download_pandoc(version="3.4")'
- name: Build executables with pyinstaller
run: |
# store the latest tag in static file
git describe --tags --abbrev=0 > .version
python -m PyInstaller jimmy_cli.spec
# python -m PyInstaller jimmy_gui.spec
- name: Release
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ __pycache__
jimmy.log
.cache
.obsidian
.version
build
dist
test_profile
Expand Down
2 changes: 1 addition & 1 deletion jimmy_cli.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from PyInstaller.utils.hooks import collect_data_files

# pypandoc: https://github.com/orgs/pyinstaller/discussions/8387
datas = []
datas = [(".version", ".")]
datas += collect_data_files('pypandoc')


Expand Down
15 changes: 14 additions & 1 deletion src/jimmy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import importlib
import logging
from pathlib import Path
import sys

import pypandoc
from rich import print # pylint: disable=redefined-builtin
Expand Down Expand Up @@ -88,8 +89,20 @@ def get_tree(root_notebooks: list[imf.Notebook], root_tree: Tree) -> Tree:
return root_tree


def get_jimmy_version():
# Pyinstaller has different path than module.
# https://stackoverflow.com/a/44352931/7410886
base_path = getattr(sys, "_MEIPASS", Path(__file__).parent)
version_file = Path(base_path) / ".version"
return (
version_file.read_text().lstrip("v").rstrip()
if version_file.is_file()
else "dev"
)


def jimmy(config) -> common.Stats:
LOGGER.info(f"Jimmy 0.0.23 (Pandoc {pypandoc.get_pandoc_version()})")
LOGGER.info(f"Jimmy {get_jimmy_version()} (Pandoc {pypandoc.get_pandoc_version()})")
inputs_str = " ".join(map(str, config.input))
LOGGER.info(f'Importing notes from "{inputs_str}"')
LOGGER.info("Start parsing")
Expand Down

0 comments on commit 00d0525

Please sign in to comment.