diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index e285cb9d..7d765429 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -19,8 +19,8 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: '3.8' @@ -33,8 +33,8 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: '3.8' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..48ac3b46 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,42 @@ +name: Release + +on: + push: + branches: [ 'workflows/release' ] + tags: + - "v*" + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + strategy: + matrix: + architecture: [x64] + name: Build on Windows ${{ matrix.architecture }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Python + id: set_up_python + uses: actions/setup-python@v5 + with: + python-version: '3.8' + architecture: ${{ matrix.architecture }} + - name: Install python dependencies + run: pip install poetry && poetry install -E win + - name: Build + run: poetry run python builder.py build + - name: Generate installer + run: poetry run python builder.py bdist_msi + - name: Upload the artifact + uses: actions/upload-artifact@v4 + with: + path: dist/*.msi + name: ${{ runner.os }}-${{ matrix.architecture }} + # - name: Release + # uses: softprops/action-gh-release@v1 + # if: startsWith(github.ref, 'refs/tags/') + # with: + # files: | + # dist/*.msi diff --git a/builder.py b/builder.py index 6a23ac29..ca803c5c 100644 --- a/builder.py +++ b/builder.py @@ -5,42 +5,64 @@ from sportorg import config base = None -if sys.platform == "win32": - base = "Win32GUI" +if sys.platform == 'win32': + base = 'Win32GUI' include_files = [ config.LOCALE_DIR, config.TEMPLATE_DIR, config.IMG_DIR, config.SOUND_DIR, - config.base_dir("LICENSE"), - config.base_dir("changelog.md"), - config.base_dir("changelog_ru.md"), - config.base_dir("configs"), + config.base_dir('LICENSE'), + config.base_dir('changelog.en.md'), + config.base_dir('changelog.ru.md'), + config.base_dir('configs'), config.STYLE_DIR, ] includes = ["atexit", "codecs", "playsound", "pyImpinj"] excludes = ["Tkinter", "unittest", "test", "pydoc"] -options = { - "build_exe": { - "includes": includes, - "excludes": excludes, - "packages": ["idna", "requests", "encodings", "asyncio", "pywinusb"], - "include_files": include_files, - "zip_include_packages": ["PySide6"], - "optimize": 2, - 'include_msvcr': True, - } +build_exe_options = { + "includes": includes, + "excludes": excludes, + "packages": ["idna", "requests", "encodings", "asyncio", "pywinusb"], + "include_files": include_files, + "zip_include_packages": ["PySide6"], + "optimize": 2, + 'include_msvcr': True, + 'silent': 1, } +bdist_msi_options = { + 'all_users': False, + 'data': { + 'Shortcut': [ + ( + 'DesktopShortcut', # Shortcut + 'DesktopFolder', # Directory + config.NAME, # Name + 'TARGETDIR', # Component + '[TARGETDIR]SportOrg.exe', # Target + None, # Arguments + None, # Description + None, # Hotkey + None, # Icon + None, # IconIndex + None, # ShowCmd + 'TARGETDIR', # WkDir + ), + ] + }, +} + +options = {'build_exe': build_exe_options, 'bdist_msi': bdist_msi_options} + executables = [ Executable( - "SportOrg.pyw", + 'SportOrg.pyw', base=base, - icon=config.icon_dir("sportorg.ico"), - shortcut_dir=config.NAME.lower(), - copyright="GNU GENERAL PUBLIC LICENSE {}".format(config.NAME), + icon=config.icon_dir('sportorg.ico'), + copyright='GNU GENERAL PUBLIC LICENSE {}'.format(config.NAME), ) ] @@ -50,5 +72,4 @@ description=config.NAME, options=options, executables=executables, - packages=[], ) diff --git a/pyproject.toml b/pyproject.toml index 7c63264b..4fa1ad60 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,7 @@ requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" [tool.poe.env] -CODE = "tests sportorg" +CODE = "tests sportorg builder.py" [tool.poe.tasks.all] help = "Run format lint test"