Skip to content

Make release

Make release #140

Workflow file for this run

name: Make release
on:
workflow_dispatch: # allows manual triggering
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
create-tag:
runs-on: ubuntu-20.04
outputs:
release_id: ${{ steps.create_release.outputs.id }}
name: ${{ steps.tag.outputs.name }}
steps:
- name: Clone
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine tag name
id: tag
shell: bash
run: |
BUILD_NUMBER="$(git rev-list --count HEAD)"
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
if [[ "${{ env.BRANCH_NAME }}" == "master-custom" ]]; then
echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
else
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
fi
- name: Create release
id: create_release
uses: anzz1/action-create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
tag_name: ${{ steps.tag.outputs.name }}
build-all:
needs:
- create-tag
strategy:
matrix:
include:
- os: windows-latest
os_suffix: windows-amd64
reqs: cuda
backend: cuda
python-version: '3.11'
- os: windows-latest
os_suffix: windows-amd64
reqs: dml
backend: dml
python-version: '3.11'
- os: macos-13
os_suffix: macos-amd64
reqs: cpu
backend: cpu
python-version: '3.11'
- os: macos-latest
os_suffix: macos-arm64
reqs: cpu
backend: cpu
python-version: '3.11'
- os: ubuntu-20.04
os_suffix: linux-amd64
reqs: cpu
backend: cpu
python-version: '3.11'
- os: ubuntu-20.04
os_suffix: linux-amd64
reqs: cuda
backend: cuda
# Linux CUDA depends on faiss-gpu-cp310
python-version: '3.10'
- os: ubuntu-20.04
os_suffix: linux-amd64
reqs: rocm
backend: rocm
# onnxruntime-rocm supports only cp310
python-version: '3.10'
runs-on: ${{ matrix.os }}
env:
BACKEND: ${{ matrix.backend }}
BUILD_NAME: ${{ needs.create-tag.outputs.name }}
steps:
- name: Maximize build space
if: matrix.os == 'ubuntu-20.04'
uses: AdityaGarg8/remove-unwanted-software@v3
with:
remove-swapfile: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
remove-android: 'true'
remove-dotnet: 'true'
# remove-large-packages: 'true'
remove-haskell: 'true'
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# architecture: x64
# cache: pip
- name: Installing build dependencies
run: python -m pip install --no-cache-dir --upgrade pip wheel setuptools pyinstaller
- name: Installing project dependencies
run: python -m pip install --no-cache-dir -r requirements-common.txt -r requirements-${{ matrix.reqs }}.txt
working-directory: ./server
- name: Building executable
run: pyinstaller --clean -y --dist ./dist --workpath /tmp MMVCServerSIO.spec
working-directory: ./server
- name: Copy utils
run: cp ./server/{force_gpu_clocks.bat,reset_gpu_clocks.bat} ./server/dist/
shell: bash
if: matrix.os == 'windows-latest' && matrix.backend == 'cuda'
- name: Add CUDA library symlinks
run: ln -svf nvidia/*/lib/*.so* .
shell: bash
if: matrix.os == 'ubuntu-20.04' && matrix.backend == 'cuda'
working-directory: ./server/dist/MMVCServerSIO/_internal
- name: Pack artifact
shell: bash
run: |
mkdir ./server/artifacts
if [ "$RUNNER_OS" = "Windows" ]; then
7z a -v2000m -tzip ./server/artifacts/voice-changer-${{ matrix.os_suffix }}-${{ matrix.reqs }}.zip ./server/dist/* > /dev/null 2>&1
else
cd ./server/dist
tar czf - ./* | split -b 2000m - ../artifacts/voice-changer-${{ matrix.os_suffix }}-${{ matrix.reqs }}.tar.gz.
cd -
fi
- name: Rename single asset
shell: bash
run: |
ls -al ./server/artifacts/
COUNT=$(ls -1q ./server/artifacts/ | wc -l | sed -r 's/[[:space:]]+//g')
if [ $COUNT = 1 ]; then
if [ "$RUNNER_OS" = "Windows" ]; then
mv ./server/artifacts/voice-changer-${{ matrix.os_suffix }}-${{ matrix.reqs }}.zip.001 ./server/artifacts/voice-changer-${{ matrix.os_suffix }}-${{ matrix.reqs }}.zip
else
mv ./server/artifacts/voice-changer-${{ matrix.os_suffix }}-${{ matrix.reqs }}.tar.gz.aa ./server/artifacts/voice-changer-${{ matrix.os_suffix }}-${{ matrix.reqs }}.tar.gz
fi
fi
- name: Upload release
id: upload_release
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const path = require('path');
const fs = require('fs');
const root = './server/artifacts';
const release_id = '${{ needs.create-tag.outputs.release_id }}';
const files = fs.readdirSync(root);
for (const file of files) {
console.log('uploadReleaseAsset', file);
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release_id,
name: file,
data: await fs.readFileSync(path.join(root, file))
});
}