Skip to content

Manual Build

Manual Build #39

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
shell: cmd
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
.\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
shell: cmd
run: |
.\env\python.exe -m pip install -r requirements.txt
.\env\python.exe -m pip cache purge
- name: Install Model
shell: cmd
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
shell: cmd
run: |
xcopy "env" ".\dist\KeywordGacha\env" /E /I /Q /H /Y
xcopy "model" ".\dist\KeywordGacha\model" /E /I /Q /H /Y
xcopy "helper" ".\dist\KeywordGacha\helper" /E /I /Q /H /Y
xcopy "prompt" ".\dist\KeywordGacha\prompt" /E /I /Q /H /Y
copy "01_启动.bat" ".\dist\KeywordGacha\"
copy "main.py" ".\dist\KeywordGacha\"
copy "config.json" ".\dist\KeywordGacha\"
copy "blacklist.txt" ".\dist\KeywordGacha\"
copy "libomp140.x86_64.dll" ".\dist\KeywordGacha\"
- name: Create Timestamp
id: create_timestamp
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")
# 输出 timestamp 变量以供后续步骤使用
echo "::set-output name=timestamp::$timestamp"
- name: Compress Archive
shell: cmd
run: |
.\resource\7za.exe a -y -bt -mx5 -slp KeywordGacha_${{ steps.create_timestamp.outputs.timestamp }}.zip .\dist\*
- name: Change To NV Version
shell: cmd
run: |
.\dist\KeywordGacha\env\python.exe -m pip uninstall --yes torch torchvision torchaudio
.\dist\KeywordGacha\env\python.exe -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
.\dist\KeywordGacha\env\python.exe -m pip cache purge
.\resource\aria2c.exe https://github.com/neavo/KeywordGachaModel/releases/download/kg_ner_ja_gpu/kg_ner_ja_gpu.zip -o kg_ner_ja_gpu.zip
powershell -Command "Expand-Archive -Path 'kg_ner_ja_gpu.zip' -DestinationPath 'dist\KeywordGacha\resource\kg_ner_ja_gpu'"
powershell -Command "Remove-Item -Path 'kg_ner_ja_gpu.zip' -Recurse -Force -ErrorAction SilentlyContinue"
echo > .\dist\KeywordGacha\gpuboost.txt
- name: Compress Archive NV
shell: cmd
run: |
.\resource\7za.exe a -y -bt -mx5 -slp -v2000M KeywordGacha_NV_${{ steps.create_timestamp.outputs.timestamp }}.zip .\dist\*
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.KEYWORDGACHA_TOKEN }}
with:
tag_name: MANAUL_BUILD_${{ steps.create_timestamp.outputs.timestamp }}
release_name: KeywordGacha_${{ steps.create_timestamp.outputs.timestamp }}
draft: true
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_${{ steps.create_timestamp.outputs.timestamp }}.zip
asset_name: KeywordGacha_${{ steps.create_timestamp.outputs.timestamp }}.zip
asset_content_type: application/zip
- name: Upload Release NV 001
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.KEYWORDGACHA_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./KeywordGacha_NV_${{ steps.create_timestamp.outputs.timestamp }}.zip.001
asset_name: KeywordGacha_NV_${{ steps.create_timestamp.outputs.timestamp }}.zip.001
asset_content_type: application/zip
- name: Upload Release NV 002
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.KEYWORDGACHA_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./KeywordGacha_NV_${{ steps.create_timestamp.outputs.timestamp }}.zip.002
asset_name: KeywordGacha_NV_${{ steps.create_timestamp.outputs.timestamp }}.zip.002
asset_content_type: application/zip