Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
feat: 🐧 add linux compatibility (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
choulily committed Jun 20, 2022
1 parent 7935939 commit 085de93
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 11 deletions.
50 changes: 45 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ jobs:
tag_name: ${{ steps.release_please.outputs.tag_name }}

steps:
- uses: google-github-actions/release-please-action@v3
- name: Release Please
uses: google-github-actions/release-please-action@v3
id: release_please
with:
release-type: simple
pull-request-title-pattern: 'chore${scope}: 🔖 release${component} ${version}'

pack:
windowsbuild:
runs-on: windows-latest
name: Pack and Upload
name: Pack on Windows and Upload
needs: release-please
if: ${{ needs.release-please.outputs.release_created }}

Expand All @@ -47,6 +48,45 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release-please.outputs.upload_url }}
asset_path: dist\main.exe
asset_name: CurseForgeModpackDownloader-${{ needs.release-please.outputs.tag_name }}.exe
asset_path: ./dist/main.exe
asset_name: CurseForgeModpackDownloader-${{ needs.release-please.outputs.tag_name }}-Windows.exe
asset_content_type: application/vnd.microsoft.portable-executable

linuxbuild:
runs-on: ubuntu-latest
name: Pack on Linux and Upload
needs: release-please
if: ${{ needs.release-please.outputs.release_created }}

steps:
- name: Check Out
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: '3.10'

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Make
run: pyinstaller -i icon.ico --clean --noconsole --onefile main.py

- name: Generate Start Up Script
run: cd dist && echo "#!/bin/sh" >> start.sh && echo "export SSL_CERT_DIR=/etc/ssl/certs" >> start.sh && echo "./main" >> start.sh

- name: Compress Application
run: cd dist && tar -cvf pack.tar.gz start.sh main

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release-please.outputs.upload_url }}
asset_path: ./dist/pack.tar.gz
asset_name: CurseForgeModpackDownloader-${{ needs.release-please.outputs.tag_name }}-Linux.tar.gz
asset_content_type: application/x-gtar
7 changes: 6 additions & 1 deletion utils/constant.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sys
import platform

NAME = 'CurseForgeModpackDownloader'
NAME_WITH_SPACE = 'CurseForge Modpack Downloader (CMPDL)'
Expand All @@ -20,7 +21,11 @@ class PATH:
BASE_DIR = BASE_DIR
WORKING_DIR = os.getcwd()

ICON_PATH = os.path.join(BASE_DIR, 'icon.ico')
if platform.system() == 'Windows':
ICON_PATH = os.path.join(BASE_DIR, 'icon.ico')
else:
ICON_PATH = None

TEMP_DIR_PATH = os.path.join(WORKING_DIR, f'.{NAME}')
LOG_FILE_NAME = f'{NAME}.log'

Expand Down
12 changes: 7 additions & 5 deletions utils/window/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import platform
from threading import Thread
from ctypes import windll
from tkinter import Tk
from tkinter.messagebox import askokcancel

Expand All @@ -22,11 +22,13 @@ def __init__(self):
self.title(NAME_WITH_SPACE)
self.iconbitmap(PATH.ICON_PATH)

# High DPI
# High DPI on Windows
# https://stackoverflow.com/questions/62794931/high-dpi-tkinter-re-scaling-when-i-run-it-in-spyder-and-when-i-run-it-direct-in
windll.shcore.SetProcessDpiAwareness(2)
scale_factor = windll.shcore.GetScaleFactorForDevice(0) / 75
self.tk.call('tk', 'scaling', scale_factor)
if platform.system() == 'Windows':
from ctypes import windll
windll.shcore.SetProcessDpiAwareness(2)
scale_factor = windll.shcore.GetScaleFactorForDevice(0) / 75
self.tk.call('tk', 'scaling', scale_factor)

self.__title_frame = frames.Title(self)
self.__search_frame = frames.Search(self)
Expand Down

0 comments on commit 085de93

Please sign in to comment.