Skip to content

Build Executables

Build Executables #14

name: Build Executables
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: '要上传资源的 Release 标签(如 v1.2.0),留空则上传到最新 Release'
required: false
default: ''
permissions:
contents: write
jobs:
build-windows:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade "pip<24.1"
pip install pyinstaller
pip install torch torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install omegaconf==2.0.6 --no-deps
pip install PyYAML antlr4-python3-runtime hydra-core
pip install fairseq==0.12.2 --no-deps
pip install gradio==3.50.2 librosa soundfile scipy numpy praat-parselmouth pyworld torchcrepe faiss-cpu tqdm requests python-dotenv colorama demucs huggingface_hub pedalboard ffmpeg-python av
- name: Download base models
run: |
$env:PYTHONIOENCODING="utf-8"
python tools/download_models.py
shell: pwsh
- name: Build Windows executable
run: |
pyinstaller --name AI-RVC-Windows `
--onefile `
--add-data "ui;ui" `
--add-data "infer;infer" `
--add-data "lib;lib" `
--add-data "models;models" `
--add-data "tools;tools" `
--add-data "i18n;i18n" `
--add-data "configs;configs" `
--add-data "assets/hubert;assets/hubert" `
--add-data "assets/rmvpe;assets/rmvpe" `
--hidden-import=torch `
--hidden-import=torchaudio `
--hidden-import=gradio `
--hidden-import=librosa `
--hidden-import=soundfile `
--hidden-import=fairseq `
--hidden-import=audio_separator `
--hidden-import=demucs `
--hidden-import=pedalboard `
--collect-all torch `
--collect-all torchaudio `
--collect-all gradio `
run.py
shell: pwsh
- name: Create portable package
run: |
mkdir AI-RVC-Windows-Portable
copy dist\AI-RVC-Windows.exe AI-RVC-Windows-Portable\
copy README.md AI-RVC-Windows-Portable\
copy LICENSE AI-RVC-Windows-Portable\
@"
AI-RVC Windows 便携版
使用方法:
双击 AI-RVC-Windows.exe 启动
浏览器访问 http://127.0.0.1:7860
首次启动会自动下载所需模型(约 5-10 分钟)
无需安装 Python,解压即用
注意:便携版仅支持 CPU 推理,处理速度较慢
如需 GPU 加速,请使用本地安装方式:python install.py
"@ | Out-File -Encoding utf8 "AI-RVC-Windows-Portable\使用说明.txt"
shell: pwsh
- name: Compress Windows package
run: |
7z a -tzip AI-RVC-Windows-Portable.zip AI-RVC-Windows-Portable
shell: pwsh
- name: Upload Windows artifact
uses: actions/upload-artifact@v4
with:
name: AI-RVC-Windows
path: AI-RVC-Windows-Portable.zip
build-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
libsndfile1 \
ffmpeg \
portaudio19-dev
- name: Install Python dependencies
run: |
python -m pip install --upgrade "pip<24.1"
pip install pyinstaller
pip install torch torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install omegaconf==2.0.6 --no-deps
pip install PyYAML antlr4-python3-runtime hydra-core
pip install fairseq==0.12.2 --no-deps
pip install gradio==3.50.2 librosa soundfile scipy numpy praat-parselmouth pyworld torchcrepe faiss-cpu tqdm requests python-dotenv colorama demucs huggingface_hub pedalboard ffmpeg-python av
- name: Download base models
run: |
python tools/download_models.py
- name: Build Linux executable
run: |
pyinstaller --name AI-RVC-Linux \
--onefile \
--add-data "ui:ui" \
--add-data "infer:infer" \
--add-data "lib:lib" \
--add-data "models:models" \
--add-data "tools:tools" \
--add-data "i18n:i18n" \
--add-data "configs:configs" \
--add-data "assets/hubert:assets/hubert" \
--add-data "assets/rmvpe:assets/rmvpe" \
--hidden-import=torch \
--hidden-import=torchaudio \
--hidden-import=gradio \
--hidden-import=librosa \
--hidden-import=soundfile \
--hidden-import=fairseq \
--hidden-import=audio_separator \
--hidden-import=demucs \
--hidden-import=pedalboard \
--collect-all torch \
--collect-all torchaudio \
--collect-all gradio \
run.py
- name: Create portable package
run: |
mkdir AI-RVC-Linux-Portable
cp dist/AI-RVC-Linux AI-RVC-Linux-Portable/
cp README.md AI-RVC-Linux-Portable/
cp LICENSE AI-RVC-Linux-Portable/
cat > AI-RVC-Linux-Portable/使用说明.txt << 'EOF'
AI-RVC Linux 便携版
使用方法:
chmod +x AI-RVC-Linux
./AI-RVC-Linux
浏览器访问 http://127.0.0.1:7860
首次启动会自动下载所需模型(约 5-10 分钟)
无需安装 Python,解压即用
注意:便携版仅支持 CPU 推理,处理速度较慢
如需 GPU 加速,请使用本地安装方式:python install.py
EOF
chmod +x AI-RVC-Linux-Portable/AI-RVC-Linux
- name: Compress Linux package
run: |
tar -czf AI-RVC-Linux-Portable.tar.gz AI-RVC-Linux-Portable
- name: Upload Linux artifact
uses: actions/upload-artifact@v4
with:
name: AI-RVC-Linux
path: AI-RVC-Linux-Portable.tar.gz
upload-release:
needs: [build-windows, build-linux]
runs-on: ubuntu-latest
steps:
- name: Download Windows artifact
uses: actions/download-artifact@v4
with:
name: AI-RVC-Windows
- name: Download Linux artifact
uses: actions/download-artifact@v4
with:
name: AI-RVC-Linux
- name: Determine target tag
id: tag
run: |
if [ "${{ github.event_name }}" = "push" ]; then
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
elif [ -n "${{ github.event.inputs.tag }}" ]; then
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
else
# 获取最新的 Release 标签
LATEST=$(gh release list --repo ${{ github.repository }} --limit 1 --json tagName -q '.[0].tagName')
echo "tag=${LATEST}" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload assets to release
run: |
TAG="${{ steps.tag.outputs.tag }}"
echo "上传资源到 Release: ${TAG}"
# 删除已有同名资源(如果存在)再上传
gh release upload "${TAG}" \
AI-RVC-Windows-Portable.zip \
AI-RVC-Linux-Portable.tar.gz \
--repo ${{ github.repository }} \
--clobber
echo "上传完成"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}