Manual Build #21
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: Create Env | |
run: | | |
powershell -Command "Invoke-WebRequest -Uri https://www.python.org/ftp/python/3.12.4/python-3.12.4-embed-amd64.zip -OutFile python.zip" | |
powershell -Command "Expand-Archive -Path 'python.zip' -DestinationPath 'env'" | |
powershell -Command "Remove-Item -Path 'python.zip' -Recurse -Force" | |
powershell -Command "Invoke-WebRequest -Uri https://bootstrap.pypa.io/pip/get-pip.py -OutFile get-pip.py" | |
powershell -Command ".\env\python.exe get-pip.py" | |
powershell -Command "Remove-Item -Path 'get-pip.py' -Recurse -Force" | |
powershell -Command "Copy-Item -Path 'resource\python312._pth' -Destination 'env\python312._pth' -Force" | |
- name: Install Requirements Step | |
run: | | |
powershell -Command ".\env\python.exe -m pip install -r requirements.txt" | |
powershell -Command ".\env\python.exe -m pip cache purge" | |
- 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 | |
xcopy "resource" "dist\KeywordGacha\resource" /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 |