Files
LorenEteval_Furious/.github/workflows/deploy-pypi.yml
T
2025-06-07 20:24:10 +08:00

302 lines
12 KiB
YAML

name: Github Deploy
on: [ push, pull_request ]
defaults:
run:
shell: bash
jobs:
build-distribution:
name: Build distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install libegl1
run: |
sudo apt update && sudo apt install -y libegl1
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
freethreaded: false
check-latest: true
- name: Download Python dependencies & latest asset files
run: |
python -c "import sys; print(sys.version)"
python -m pip install --upgrade pip
python -m pip install setuptools wheel
python -m pip install -r requirements.txt
python -m pip install requests
python Deploy.py --download
- name: Build a binary wheel and a source tarball
run: |
python setup.py sdist bdist_wheel
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: |
dist/*.tar.gz
dist/*.whl
publish-to-pypi:
name: >-
Publish Python distribution to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build-distribution
- deploy-binaries
runs-on: ubuntu-latest
environment:
name: deploy-pypi
url: https://pypi.org/p/Furious-GUI
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
deploy-binaries:
name: Deploy binaries on ${{ matrix.os }} Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
matrix:
os: [ ubuntu-22.04, ubuntu-22.04-arm, windows-2022, windows-2025, macos-13, macos-14 ]
python-version: [ "3.12" ]
include:
- os: windows-2022
tag: win7
env:
# Last PySide6 version that supports macOS 10.9 & Python 3.11
PYSIDE6_LEGACY_VERSION: "6.4.3"
PYSIDE6_TARGET_VERSION: "6.8.3"
# PySide6 has Windows ARM64 build since 6.9.0
PYSIDE6_LATEST_VERSION: "6.9.1"
PYTHON_IN_WIN7_VERSION: "3.12.11"
steps:
- name: Set platform environment variables
run: |
echo "PYSIDE6_Windows_X64_TARGET_VERSION=$PYSIDE6_TARGET_VERSION" >> $GITHUB_ENV
echo "PYSIDE6_Windows_ARM64_TARGET_VERSION=$PYSIDE6_LATEST_VERSION" >> $GITHUB_ENV
echo "PYSIDE6_macOS_X64_TARGET_VERSION=$PYSIDE6_TARGET_VERSION" >> $GITHUB_ENV
echo "PYSIDE6_macOS_ARM64_TARGET_VERSION=$PYSIDE6_TARGET_VERSION" >> $GITHUB_ENV
echo "PYSIDE6_Linux_X64_TARGET_VERSION=$PYSIDE6_TARGET_VERSION" >> $GITHUB_ENV
echo "PYSIDE6_Linux_ARM64_TARGET_VERSION=6.6.3.1" >> $GITHUB_ENV
case "${{ runner.arch }}" in
X64)
echo "MAPPED_RUNNER_ARCH=x86_64" >> $GITHUB_ENV
;;
ARM64)
echo "MAPPED_RUNNER_ARCH=aarch64" >> $GITHUB_ENV
;;
ARM)
echo "MAPPED_RUNNER_ARCH=armv7" >> $GITHUB_ENV
;;
*)
echo "Unknown arch: ${{ runner.arch }}"
exit 1
;;
esac
- uses: actions/checkout@v4
- name: Install macOS dependencies
run: |
brew install create-dmg
if: runner.os == 'macOS'
# Remove problematic brew libs if Intel Mac
# Credits: https://github.com/RimSort/RimSort
- name: Remove problematic brew libs on Intel Mac
run: |
brew remove --force --ignore-dependencies openssl@3
brew cleanup openssl@3
if: runner.os == 'macOS' && runner.arch == 'X64'
- name: Install Linux dependencies
run: |
sudo apt update
sudo apt install -y libxcb-cursor0
sudo apt install -y qt6-base-dev
sudo apt install -y patchelf ccache
echo "QMAKE=$(which qmake6)" >> $GITHUB_ENV
echo "Mapped runner architecture is $MAPPED_RUNNER_ARCH"
mkdir .linuxdeploy-bin
echo "$PWD/.linuxdeploy-bin" >> $GITHUB_PATH
wget -P .linuxdeploy-bin https://github.com/linuxdeploy/linuxdeploy/releases/latest/download/linuxdeploy-$MAPPED_RUNNER_ARCH.AppImage
wget -P .linuxdeploy-bin https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/latest/download/linuxdeploy-plugin-qt-$MAPPED_RUNNER_ARCH.AppImage
wget -P .linuxdeploy-bin https://github.com/AppImage/appimagetool/releases/latest/download/appimagetool-$MAPPED_RUNNER_ARCH.AppImage
chmod +x .linuxdeploy-bin/*
if: runner.os == 'Linux'
- name: Remove pre-installed Python from PATH (PowerShell)
shell: pwsh
run: |
$pythonPath = (Get-Command python).Source
Write-Host "Found python at $pythonPath"
$pythonDir = Split-Path $pythonPath
Write-Host "Python directory: $pythonDir"
# Filter out $pythonDir from $env:Path
$newPath = ($env:Path -split ';' | Where-Object { $_ -notlike "$pythonDir*" }) -join ';'
Write-Host "New PATH: $newPath"
# Export cleaned PATH to GitHub Actions environment
"PATH=$newPath" >> $env:GITHUB_ENV
if: matrix.tag == 'win7'
- name: Set up Python for Windows7
shell: cmd
run: |
curl -L -o python-%PYTHON_IN_WIN7_VERSION%-amd64-full.exe https://github.com/adang1345/PythonWin7/raw/refs/heads/master/%PYTHON_IN_WIN7_VERSION%/python-%PYTHON_IN_WIN7_VERSION%-amd64-full.exe
start /wait python-%PYTHON_IN_WIN7_VERSION%-amd64-full.exe /quiet InstallAllUsers=1 PrependPath=1 Include_launcher=1
echo C:/Program Files/Python312 >> %GITHUB_PATH%
echo C:/Program Files/Python312/Scripts >> %GITHUB_PATH%
if: matrix.tag == 'win7'
- name: Add Python for Windows7 to Path
run: |
echo "C:/Program Files/Python312" >> $GITHUB_PATH
echo "C:/Program Files/Python312/Scripts" >> $GITHUB_PATH
if: matrix.tag == 'win7'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# Support Windows ARM64 build
architecture: ${{ runner.arch == 'ARM64' && 'arm64' || 'x64' }}
freethreaded: false
check-latest: true
if: matrix.tag != 'win7'
- name: Set up PySide6 for Win7
run: |
python -c "import sys; print(sys.version)"
python -m pip install --upgrade pip
python -m pip install setuptools wheel
python -m pip install PySide6-Essentials==$PYSIDE6_TARGET_VERSION
curl -L -o qt6_x64_to_run_on_windows7.7z https://github.com/crystalidea/qt6windows7/releases/download/v$PYSIDE6_TARGET_VERSION/qt6_x64_to_run_on_windows7.7z
7z x qt6_x64_to_run_on_windows7.7z -oqt6_x64_to_run_on_windows7 -y
cd qt6_x64_to_run_on_windows7
mkdir plugins
mv imageformats platforms styles plugins
cd ..
cp -r qt6_x64_to_run_on_windows7/* "C:/Program Files/Python312/Lib/site-packages/PySide6/"
if: matrix.tag == 'win7'
- name: Download Python dependencies & latest asset files
run: |
if [[ "${{ matrix.tag }}" != "win7" ]]; then
python -c "import sys; print(sys.version)"
python -m pip install --upgrade pip
python -m pip install setuptools wheel
fi
if [ "$RUNNER_OS" == "Linux" ] && [ "$RUNNER_ARCH" == "ARM64" ]; then
python -m pip install "numpy<2"
elif [ "$RUNNER_OS" == "Windows" ] && [ "$RUNNER_ARCH" == "ARM64" ]; then
python -m pip install "https://github.com/LorenEteval/numpy-2.2.4-cp313-win_arm64/releases/download/2.2.4/numpy-2.2.4-cp313-cp313-win_arm64.whl"
fi
python -m pip install PySide6-Essentials==$PYSIDE6_${{ runner.os }}_${{ runner.arch }}_TARGET_VERSION
python -m pip install -r requirements.txt
python -m pip install nuitka imageio
python -m pip install requests
python Deploy.py --download
- name: Download LLVM ARM64 Clang toolchain
# TODO: Need mingw-arm64 on Windows ARM64
shell: pwsh
run: |
Invoke-WebRequest -Uri "https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.5/clang+llvm-20.1.5-aarch64-pc-windows-msvc.tar.xz" `
-OutFile "clang+llvm-20.1.5-aarch64-pc-windows-msvc.tar.xz"
$newPath = ($env:PATH -split ";" | Where-Object { $_ -notlike "C:\Program Files\LLVM\bin" }) -join ";"
echo "PATH=$newPath" >> $env:GITHUB_ENV
mkdir C:\llvm-aarch64
tar -xf clang+llvm-20.1.5-aarch64-pc-windows-msvc.tar.xz -C C:\llvm-aarch64
echo "C:\llvm-aarch64\clang+llvm-20.1.5-aarch64-pc-windows-msvc\bin" >> $env:GITHUB_PATH
echo "CGO_ENABLED=1" >> $env:GITHUB_ENV
echo "CC=clang" >> $env:GITHUB_ENV
echo "CXX=clang++" >> $env:GITHUB_ENV
if: runner.os == 'Windows' && runner.arch == 'ARM64'
- name: Set up go
uses: actions/setup-go@v4
with:
go-version: "1.24"
# Support Windows ARM64 build
architecture: ${{ runner.arch == 'ARM64' && 'arm64' || 'x64' }}
check-latest: true
if: matrix.tag != 'win7'
- name: Set up go for Win7
run: |
curl -L -o go-for-win7-windows-amd64.zip https://github.com/XTLS/go-win7/releases/latest/download/go-for-win7-windows-amd64.zip
7z x go-for-win7-windows-amd64.zip -ogo-for-win7-windows-amd64 -y
echo "GOROOT=$PWD/go-for-win7-windows-amd64" >> $GITHUB_ENV
echo "CGO_ENABLED=1" >> $GITHUB_ENV
echo "WIN_VER_COMPATIBLE=windows7" >> $GITHUB_ENV
if: matrix.tag == 'win7'
- name: Install go dependencies
run: |
if [[ "${{ matrix.tag }}" == "win7" ]]; then
export PATH=${GOROOT}/bin:$PATH
fi
go version
python -m pip install "Xray-core >= 1.8.8" "hysteria2 >= 2.0.4" "tun2socks > 2.5.2"
if [[ "${{ matrix.tag }}" == "win7" ]]; then
echo "GOROOT=" >> $GITHUB_ENV
fi
- name: Set up go legacy
uses: actions/setup-go@v4
with:
go-version: "1.20"
# Support Windows ARM64 build
architecture: ${{ runner.arch == 'ARM64' && 'arm64' || 'x64' }}
check-latest: true
- name: Install go legacy dependencies
run: |
go version
python -m pip install "hysteria > 1.3.5"
- name: Run deploy script
run: python Deploy.py
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: binary-distributions-${{ matrix.os }}-Python${{ matrix.python-version }}
path: |
Furious-*.zip
Furious-*.dmg
Furious-*.AppImage
github-release:
name: >-
Upload to GitHub Release
needs:
- deploy-binaries
- publish-to-pypi
runs-on: ubuntu-latest
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
pattern: binary-distributions-*
merge-multiple: true
path: dist/
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
--prerelease
--generate-notes
--title 'Furious ${{ github.ref_name }}'
- name: Upload artifact to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'