feat: 使用Claude AI重构代码

This commit is contained in:
ikun0014
2025-06-08 18:51:18 +08:00
parent 1072acd698
commit 7a0924cfea
24 changed files with 1126 additions and 1198 deletions

View File

@@ -1,79 +1,140 @@
name: Build
name: Build and Release
on:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
jobs:
build:
permissions:
contents: write
runs-on: windows-latest
steps:
- name: Check out git repository
- name: Checkout repository
uses: actions/checkout@v4
- name: Get package version
id: get_version
shell: powershell
run: |
$version = (Get-Content package.json | ConvertFrom-Json).version
echo "PACKAGE_VERSION=$version" >> $env:GITHUB_ENV
$packageJson = Get-Content package.json | ConvertFrom-Json
$version = $packageJson.version
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
echo "Package version: $version"
- name: Create Executable
uses: sayyid5416/pyinstaller@main
- name: Set up Python
uses: actions/setup-python@v5
with:
python_ver: "3.13.1"
spec: "main.py"
requirements: "requirements.txt"
options: --onefile, --name Onekey_v${{ env.PACKAGE_VERSION }}, --uac-admin, --uac-uiaccess, --icon ./icon.jpg
python-version: "3.12"
architecture: "x64"
- name: Run UPX
uses: crazy-max/ghaction-upx@master
- 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: -fq
args: "-9"
- name: Create git tag
uses: pkgdeps/git-tag-action@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_repo: ${{ github.repository }}
version: ${{ env.PACKAGE_VERSION }}
git_commit_sha: ${{ github.sha }}
git_tag_prefix: "v"
- name: Release
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.PACKAGE_VERSION }}
files: dist/Onekey_v${{ env.PACKAGE_VERSION }}.exe
prerelease: false
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: Gitee Release
- 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${{ env.PACKAGE_VERSION }}
gitee_release_name: v${{ env.PACKAGE_VERSION }}
gitee_release_body: I don't know
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${{ env.PACKAGE_VERSION }}.exe
gitee_file_path: dist/Onekey_v${{ env.PACKAGE_VERSION }}.exe
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: |
& curl -F "chat_id=${{ secrets.TELEGRAM_TO }}" `
-F "thread_id=${{ secrets.TELEGRAM_THREAD }}" `
-F "document=@dist/Onekey_v${{ env.PACKAGE_VERSION }}.exe" `
-F "caption=Onekey's New Update ${{ env.PACKAGE_VERSION }}" `
-F "parse_mode=Markdown" `
"https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendDocument"
$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