Skip to content

Manual Build

Manual Build #32

Workflow file for this run

name: Manual Build
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
environment: KeywordGacha
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Create Env
run: |
resource\aria2c.exe https://www.python.org/ftp/python/3.12.4/python-3.12.4-embed-amd64.zip -o python.zip
powershell -Command "Expand-Archive -Path 'python.zip' -DestinationPath 'env'"
powershell -Command "Remove-Item -Path 'python.zip' -Recurse -Force -ErrorAction SilentlyContinue"
resource\aria2c.exe https://bootstrap.pypa.io/pip/get-pip.py -o get-pip.py
powershell -Command ".\env\python.exe get-pip.py"
powershell -Command "Remove-Item -Path 'get-pip.py' -Recurse -Force -ErrorAction SilentlyContinue"
powershell -Command "Copy-Item -Path 'resource\python312._pth' -Destination 'env\python312._pth' -Force"
- name: Install Requirements
run: |
powershell -Command ".\env\python.exe -m pip install -r requirements.txt"
powershell -Command ".\env\python.exe -m pip cache purge"
- name: Install Model
run: |
resource\aria2c.exe https://github.com/neavo/KeywordGachaModel/releases/download/kg_ner_ja_cpu/kg_ner_ja_cpu.zip -o kg_ner_ja_cpu.zip
powershell -Command "Expand-Archive -Path 'kg_ner_ja_cpu.zip' -DestinationPath 'dist\KeywordGacha\resource\kg_ner_ja_cpu'"
powershell -Command "Remove-Item -Path 'kg_ner_ja_cpu.zip' -Recurse -Force -ErrorAction SilentlyContinue"
- name: Copy Files
run: |
xcopy "env" "dist\KeywordGacha\env" /E /I /H /Y
xcopy "model" "dist\KeywordGacha\model" /E /I /H /Y
xcopy "helper" "dist\KeywordGacha\helper" /E /I /H /Y
xcopy "prompt" "dist\KeywordGacha\prompt" /E /I /H /Y
copy "01_启动.bat" "dist\KeywordGacha\"
copy "02_启用应用内GPU加速.bat" "dist\KeywordGacha\"
copy "03_关闭应用内GPU加速.bat" "dist\KeywordGacha\"
copy "main.py" "dist\KeywordGacha\"
copy "config.json" "dist\KeywordGacha\"
copy "blacklist.txt" "dist\KeywordGacha\"
copy "resource\aria2c.exe" "dist\KeywordGacha\resource\"
copy "resource\python312._pth" "dist\KeywordGacha\resource\"
- name: Compress Archive
id: compress_files
shell: pwsh
run: |
# 获取当前UTC时间
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
# 调整为东八区时间(北京时间)
$timestamp = ([System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId([datetime]::ParseExact($timestamp, "yyyyMMdd_HHmmss", $null), [System.TimeZoneInfo]::Utc.Id, 'China Standard Time')).ToString("yyyyMMdd_HHmmss")
# 压缩dist目录下的所有文件,不包括dist目录本身
Compress-Archive -Path "dist\*" -DestinationPath "KeywordGacha_DEV_$timestamp.zip" -Force
# 输出 timestamp 变量以供后续步骤使用
echo "::set-output name=timestamp::$timestamp"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.KEYWORDGACHA_TOKEN }}
with:
tag_name: MANAUL_BUILD_${{ steps.compress_files.outputs.timestamp }}
release_name: KeywordGacha_DEV_${{ steps.compress_files.outputs.timestamp }}
draft: false
prerelease: false
- name: Upload Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.KEYWORDGACHA_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./KeywordGacha_DEV_${{ steps.compress_files.outputs.timestamp }}.zip
asset_name: KeywordGacha_DEV_${{ steps.compress_files.outputs.timestamp }}.zip
asset_content_type: application/octet-stream