feat: add support for Ubuntu 24.04 ARM architecture in release workfl… #223
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
branches: [ "main" ] | |
tags: | |
- "v*" | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
permissions: write-all | |
strategy: | |
matrix: | |
include: | |
- os: windows-latest | |
os_name: windows | |
arch: amd64 | |
- os: windows-latest | |
os_name: windows | |
arch: arm64 | |
- os: macos-latest | |
os_name: darwin | |
arch: amd64 | |
target_arch: x86_64 | |
- os: macos-latest | |
os_name: darwin | |
arch: arm64 | |
target_arch: arm64 | |
- os: ubuntu-latest | |
os_name: linux | |
arch: amd64 | |
- os: ubuntu-24.04-arm | |
os_name: linux | |
arch: arm64 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version-file: ".python-version" | |
- name: Install uv and restore cache | |
uses: astral-sh/setup-uv@v5 | |
with: | |
version: "0.6.0" | |
enable-cache: true | |
cache-dependency-glob: "uv.lock" | |
- name: Install Dependencies | |
run: uv sync | |
- name: Build Executable (macOS) | |
if: runner.os == 'macOS' | |
run: | | |
source .venv/bin/activate | |
mkdir -p core | |
curl -L "https://github.com/Mythologyli/zju-connect/releases/latest/download/zju-connect-darwin-${{ matrix.arch }}.zip" -o core/zju-connect.zip | |
unzip -o core/zju-connect.zip -d core | |
rm core/zju-connect.zip | |
pyinstaller --clean --windowed \ | |
--target-arch ${{ matrix.target_arch }} \ | |
--add-data "assets:assets" \ | |
--add-data "utils:utils" \ | |
--add-data "core/zju-connect:core" \ | |
--add-data ".app-version:." \ | |
--icon assets/icon.icns \ | |
-n "HITSZ Connect Verge" main.py | |
- name: Create DMG (macOS) | |
if: runner.os == 'macOS' | |
run: | | |
brew install create-dmg | |
create-dmg \ | |
--volname "HITSZ Connect Verge" \ | |
--background "assets/bg.svg" \ | |
--window-pos 400 200 \ | |
--window-size 660 400 \ | |
--icon-size 100 \ | |
--icon "HITSZ Connect Verge.app" 160 185 \ | |
--app-drop-link 500 185 \ | |
"dist/hitsz-connect-verge-${{ matrix.os_name }}-${{ matrix.arch }}.dmg" \ | |
"dist/HITSZ Connect Verge.app" | |
- name: Build Executable (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
.\.venv\Scripts\Activate.ps1 | |
mkdir -p core | |
Invoke-WebRequest -Uri "https://github.com/Mythologyli/zju-connect/releases/latest/download/zju-connect-windows-${{ matrix.arch }}.zip" -OutFile "core\zju-connect-windows-${{ matrix.arch }}.zip" | |
Expand-Archive -Path "core\zju-connect-windows-${{ matrix.arch }}.zip" -DestinationPath "core" | |
Remove-Item -Path "core\zju-connect-windows-${{ matrix.arch }}.zip" | |
pyinstaller --clean --noconsole ` | |
--add-data "assets;assets" ` | |
--add-data "utils;utils" ` | |
--add-data "core\zju-connect.exe;core" ` | |
--add-data ".app-version;." ` | |
--icon assets/icon.ico ` | |
-n "HITSZ Connect Verge" main_fluent.py | |
# Install Inno Setup | |
choco install innosetup -y | |
# Compile installer | |
$version = Get-Content .app-version -Raw | |
iscc /DMyAppVersion="$version" ` | |
/DArchitecture="${{ matrix.arch }}" ` | |
installer.iss | |
- name: Install Linux Dependencies | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libglib2.0-0 libgl1 dpkg-dev debhelper | |
- name: Build Executable (Linux) | |
if: runner.os == 'Linux' | |
run: | | |
source .venv/bin/activate | |
mkdir -p core | |
curl -L "https://github.com/Mythologyli/zju-connect/releases/latest/download/zju-connect-linux-${{ matrix.arch }}.zip" -o core/zju-connect.zip | |
unzip -o core/zju-connect.zip -d core | |
rm core/zju-connect.zip | |
pyinstaller --noconsole --clean --onefile \ | |
--add-data "assets:assets" \ | |
--add-data "utils:utils" \ | |
--add-data "core/zju-connect:core" \ | |
--add-data ".app-version:." \ | |
--icon assets/icon.png \ | |
-n hitsz-connect-verge main.py | |
- name: Archive Executable | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hitsz-connect-verge-${{ matrix.os_name }}-${{ matrix.arch }} | |
path: | | |
${{ runner.os == 'macOS' && 'dist/hitsz-connect-verge-*.dmg' || '' }} | |
${{ runner.os == 'Windows' && 'dist/hitsz-connect-verge-*-setup.exe' || '' }} | |
${{ runner.os == 'Linux' && 'dist/hitsz-connect-verge' || '' }} | |
release: | |
permissions: write-all | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Download All Artifacts | |
uses: dawidd6/action-download-artifact@v8 | |
with: | |
path: artifacts | |
- name: Archive Artifact Directories | |
run: | | |
cd artifacts | |
for dir in *; do | |
if [ -d "$dir" ]; then | |
echo "Zipping $dir" | |
zip -r "$dir.zip" "$dir" | |
rm -rf "$dir" | |
fi | |
done | |
- name: Publish Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "artifacts/*.zip" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ github.ref_name }} | |
generateReleaseNotes: true | |
prerelease: true |