Files
Onekey/.github/workflows/release.yml
2025-06-08 18:51:18 +08:00

141 lines
4.7 KiB
YAML

name: Build and Release
on:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
jobs:
build:
permissions:
contents: write
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get package version
id: get_version
shell: powershell
run: |
$packageJson = Get-Content package.json | ConvertFrom-Json
$version = $packageJson.version
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
echo "Package version: $version"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
architecture: "x64"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install Pillow
pip install pyinstaller
- name: Create icon if not exists
shell: powershell
run: |
if (-not (Test-Path "icon.ico")) {
Write-Host "Icon file not found, using default Windows icon"
$iconPath = "C:\Windows\System32\shell32.dll,0"
}
- name: Build executable
run: |
pyinstaller --onefile `
--name "Onekey_v${{ steps.get_version.outputs.VERSION }}" `
--uac-admin `
--uac-uiaccess `
--add-data "src;src" `
--hidden-import=winreg `
--hidden-import=httpx `
--hidden-import=vdf `
--hidden-import=colorama `
--hidden-import=logzero `
--hidden-import=ujson `
--console `
main.py
- name: Compress with UPX
uses: crazy-max/ghaction-upx@v3
with:
version: latest
files: |
./dist/*.exe
args: "-9"
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: dist/Onekey_v${{ steps.get_version.outputs.VERSION }}.exe
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create tag and release (if not tagged)
if: github.ref == 'refs/heads/main'
run: |
git config user.name github-actions
git config user.email github-actions@github.com
$version = "${{ steps.get_version.outputs.VERSION }}"
# Check if tag exists
$tagExists = git tag -l "v$version"
if (-not $tagExists) {
git tag -a "v$version" -m "Release version $version"
git push origin "v$version"
}
- name: Upload to Gitee Release
if: success() && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
continue-on-error: true
uses: nicennnnnnnlee/action-gitee-release@v1.0.5
with:
gitee_owner: ikun0014
gitee_repo: Onekey
gitee_token: ${{ secrets.GITEE_TOKEN }}
gitee_tag_name: v${{ steps.get_version.outputs.VERSION }}
gitee_release_name: v${{ steps.get_version.outputs.VERSION }}
gitee_release_body: "Onekey version ${{ steps.get_version.outputs.VERSION }} release"
gitee_target_commitish: main
gitee_upload_retry_times: 3
gitee_file_name: Onekey_v${{ steps.get_version.outputs.VERSION }}.exe
gitee_file_path: dist/Onekey_v${{ steps.get_version.outputs.VERSION }}.exe
- name: Upload to Telegram Channel
if: success() && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
continue-on-error: true
shell: powershell
run: |
$version = "${{ steps.get_version.outputs.VERSION }}"
$filePath = "dist/Onekey_v${version}.exe"
if (Test-Path $filePath) {
curl.exe -F "chat_id=${{ secrets.TELEGRAM_TO }}" `
-F "thread_id=${{ secrets.TELEGRAM_THREAD }}" `
-F "document=@$filePath" `
-F "caption=🎮 **Onekey New Update** v${version}`n`n✨ Steam Game Unlocker`n💻 Windows 10/11`n`n[GitHub](https://github.com/ikunshare/Onekey)" `
-F "parse_mode=Markdown" `
"https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendDocument"
} else {
Write-Error "File not found: $filePath"
}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Onekey_v${{ steps.get_version.outputs.VERSION }}
path: dist/Onekey_v${{ steps.get_version.outputs.VERSION }}.exe
retention-days: 30