mirror of
https://github.com/ikunshare/Onekey.git
synced 2026-01-12 16:25:53 +08:00
125 lines
4.0 KiB
YAML
125 lines
4.0 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: Build executable
|
|
run: |
|
|
pyinstaller --onefile `
|
|
--icon "./icon.jpg" `
|
|
--name "Onekey_v${{ steps.get_version.outputs.VERSION }}" `
|
|
--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.2.0
|
|
with:
|
|
version: latest
|
|
files: |
|
|
./dist/*.exe
|
|
args: "-fq"
|
|
|
|
- name: Create git tag
|
|
uses: pkgdeps/git-tag-action@v3
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
github_repo: ${{ github.repository }}
|
|
version: ${{ steps.get_version.outputs.VERSION }}
|
|
git_commit_sha: ${{ github.sha }}
|
|
git_tag_prefix: "v"
|
|
|
|
- name: Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: v${{ steps.get_version.outputs.VERSION }}
|
|
files: dist/Onekey_v${{ steps.get_version.outputs.VERSION }}.exe
|
|
prerelease: false
|
|
draft: false
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Upload to Gitee Release
|
|
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
|
|
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
|