Manual Build #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Create Env | |
run: | | |
python -m venv env | |
- name: Update Pip | |
run: | | |
# 每一个步骤都要激活环境 | |
env\Scripts\activate | |
python -m pip install --upgrade pip | |
- name: Install Requirements | |
run: | | |
# 每一个步骤都要激活环境 | |
env\Scripts\activate | |
pip install -r requirements.txt | |
python -m spacy download ja_core_news_lg | |
- 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 "00_启动.bat" "dist\KeywordGacha\" | |
copy "main.py" "dist\KeywordGacha\" | |
copy "config.json" "dist\KeywordGacha\" | |
copy "blacklist.txt" "dist\KeywordGacha\" | |
- 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 |