From f6485ebdbd2269c8f634515d51bd04523fcb2530 Mon Sep 17 00:00:00 2001 From: KevinNitroG Date: Tue, 24 Sep 2024 21:13:40 +0700 Subject: [PATCH] feat: support prebuilt for MacOS M1 --- .github/workflows/release.yml | 29 ++++++++++++++++------------- docs/README.md | 5 +++-- src/constants.py | 2 +- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 58bcfac..a65dcf4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,23 +60,30 @@ jobs: run: echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT build: - name: build + name: build - ${{ matrix.os }} needs: prepare strategy: fail-fast: false matrix: os: - - ubuntu - - windows - - macos - runs-on: ${{ matrix.os }}-latest + - macos-13 + - macos-latest + - ubuntu-latest + - windows-latest + runs-on: ${{ matrix.os }} timeout-minutes: 10 if: ${{ needs.prepare.outputs.CONTINUE == 'true' }} steps: - name: get OS lowercase id: get_os shell: bash - run: echo "OS_LOWER=$(echo $RUNNER_OS | awk '{print tolower($0)}')" >> $GITHUB_ENV + run: | + case "${{ matrix.os }}" in + "macos-13") echo "OS_NAME_FOR_RELEASE=macos" >> "$GITHUB_ENV" ;; + "macos-latest") echo "OS_NAME_FOR_RELEASE=macos-m1" >> "$GITHUB_ENV" ;; + "ubuntu-latest") echo "OS_NAME_FOR_RELEASE=linux" >> "$GITHUB_ENV" ;; + "windows-latest") echo "OS_NAME_FOR_RELEASE=windows" >> "$GITHUB_ENV" ;; + esac - name: Checkout repo uses: actions/checkout@main @@ -90,21 +97,17 @@ jobs: - name: Install dependacies run: pip install -r requirements/requirements.txt && pip install pyinstaller - - name: Build for ${{ env.OS_LOWER }} - env: - OS_LOWER: ${{ env.OS_LOWER }} - run: pyinstaller --noconfirm --onefile --console --icon="assets/images/VNU_HCM_LOGO-256.ico" --name="VNULIB-Downloader-${{ env.OS_LOWER }}" --log-level="INFO" --add-data="src/:src/" --add-data="config-sample.yml:." --add-data="assets/images/error_page.jpg:assets/images/" --add-data="assets/utils/ascii_banner.txt:assets/utils/" --add-data="LICENSE:." --collect-data grapheme "main.py" + - name: Build for ${{ env.OS_NAME_FOR_RELEASE }} + run: pyinstaller --noconfirm --onefile --console --icon="assets/images/VNU_HCM_LOGO-256.ico" --name="VNULIB-Downloader-${{ env.OS_NAME_FOR_RELEASE }}" --log-level="INFO" --add-data="src/:src/" --add-data="config-sample.yml:." --add-data="assets/images/error_page.jpg:assets/images/" --add-data="assets/utils/ascii_banner.txt:assets/utils/" --add-data="LICENSE:." --collect-data grapheme "main.py" - name: Change permissions if: runner.os == 'Linux' || runner.os == 'macOS' run: chmod +x dist/VNULIB-Downloader-* - name: Upload to artifact - env: - OS_LOWER: ${{ env.OS_LOWER }} uses: actions/upload-artifact@main with: - name: VNULIB-Downloader-${{ env.OS_LOWER }} + name: VNULIB-Downloader-${{ env.OS_NAME_FOR_RELEASE }} path: dist/VNULIB-Downloader-* compression-level: 6 retention-days: 30 diff --git a/docs/README.md b/docs/README.md index 3003dfd..dca06d0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -111,12 +111,13 @@ Python CLI tool download sách từ VNULIB - [![Windows](https://img.shields.io/badge/Windows-8aadf4?style=for-the-badge&logo=windows&logoColor=white)](https://github.com/KevinNitroG/VNULIB-Downloader/releases/latest/download/VNULIB-Downloader-windows.exe) - [![Mac OS](https://img.shields.io/badge/MAC_OS-ed8796?style=for-the-badge&logo=apple&logoColor=white)](https://github.com/KevinNitroG/VNULIB-Downloader/releases/latest/download/VNULIB-Downloader-macos) +- [![Mac OS M1](https://img.shields.io/badge/MAC_OS_M1-f38ba8?style=for-the-badge&logo=apple&logoColor=white)](https://github.com/KevinNitroG/VNULIB-Downloader/releases/latest/download/VNULIB-Downloader-macos-m1) - [![Linux](https://img.shields.io/badge/Linux-5b6078?style=for-the-badge&logo=linux&logoColor=white)](https://github.com/KevinNitroG/VNULIB-Downloader/releases/latest/download/VNULIB-Downloader-linux) > [!IMPORTANT] > -> - Các bản prebuilt chỉ dành cho máy chip `AMD64`. -> - Với các máy dùng chip `ARM64` hãy dùng phương pháp [📦 Docker](#-docker) hoặc [🤐 Python](#-python). +> - Các bản prebuilt chỉ dành cho máy chip `AMD64` và MacOS chip `M1`. +> - Với các máy dùng chip `ARM64` khác hãy dùng phương pháp [📦 Docker](#-docker) hoặc [🤐 Python](#-python). > - Các máy dùng chip khác có thể sẽ không dùng được vì một số thư viện không hỗ trợ. Hãy dùng tool đơn giản hơn như [`tlatonf/vnulib`](https://github.com/tlatonf/vnulib) _(Windows only)_. > [!NOTE] diff --git a/src/constants.py b/src/constants.py index 1382096..cc91e1c 100644 --- a/src/constants.py +++ b/src/constants.py @@ -26,7 +26,7 @@ def _get_number_of_thread(max_number_of_threads: int) -> int: return number_of_thread if number_of_thread * 5 < max_number_of_threads else max_number_of_threads -VERSION: str = "v1.17.5" +VERSION: str = "v1.17.6" AUTHORS: str = "KevinNitroG & NTGNguyen" BANNER_FILE: str = f"{BUNDLE_DIR}assets/utils/ascii_banner.txt" with open(BANNER_FILE, encoding="utf-8") as banner_content: