mirror of
https://github.com/KenanZhu/AutoLibrary.git
synced 2026-06-18 07:23:03 +08:00
ci(workflows): 重构 CI/CD 工作流执行配置
This commit is contained in:
@@ -1,48 +1,41 @@
|
|||||||
name: Build and Release
|
name: Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_call:
|
||||||
tags:
|
inputs:
|
||||||
- 'v[0-9]+.[0-9]+.[0-9]+'
|
version:
|
||||||
|
description: 'Version number'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
tag_name:
|
||||||
|
description: 'Tag name'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
outputs:
|
||||||
|
version:
|
||||||
|
description: 'The version number'
|
||||||
|
value: ${{ jobs.build-windows.outputs.version }}
|
||||||
|
tag_name:
|
||||||
|
description: 'The tag name'
|
||||||
|
value: ${{ jobs.build-windows.outputs.tag_name }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-version-info:
|
build-windows:
|
||||||
uses: ./.github/workflows/update-version-info.yml
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
with:
|
|
||||||
tag_name: ${{ github.ref_name }}
|
|
||||||
ref: ${{ github.ref }}
|
|
||||||
|
|
||||||
commit-and-move-tag:
|
|
||||||
needs: update-version-info
|
|
||||||
if: ${{ needs.update-version-info.outputs.has_changes == 'true' }}
|
|
||||||
uses: ./.github/workflows/commit-and-move-tag.yml
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
with:
|
|
||||||
tag_name: ${{ needs.update-version-info.outputs.tag_name }}
|
|
||||||
version: ${{ needs.update-version-info.outputs.version }}
|
|
||||||
file_path: src/gui/ALVersionInfo.py
|
|
||||||
|
|
||||||
build-and-release:
|
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
needs: [update-version-info, commit-and-move-tag]
|
outputs:
|
||||||
if: always() && needs.update-version-info.result == 'success'
|
version: ${{ steps.get_version.outputs.VERSION }}
|
||||||
permissions:
|
tag_name: ${{ steps.get_version.outputs.TAG_NAME }}
|
||||||
contents: write
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code with updated version info
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: main
|
ref: main
|
||||||
|
|
||||||
- name: Get version info from previous job
|
- name: Get version info
|
||||||
id: get_tag
|
id: get_version
|
||||||
run: |
|
run: |
|
||||||
$tagName = "${{ needs.update-version-info.outputs.tag_name }}"
|
$version = "${{ inputs.version }}"
|
||||||
$version = "${{ needs.update-version-info.outputs.version }}"
|
$tagName = "${{ inputs.tag_name }}"
|
||||||
|
|
||||||
echo "TAG_NAME=$tagName" >> $env:GITHUB_OUTPUT
|
echo "TAG_NAME=$tagName" >> $env:GITHUB_OUTPUT
|
||||||
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
|
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
|
||||||
@@ -50,17 +43,17 @@ jobs:
|
|||||||
Write-Host "✓ Version: $version"
|
Write-Host "✓ Version: $version"
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
|
|
||||||
- name: Verify ALVersionInfo.py was updated
|
- name: Verify 'ALVersionInfo.py' was updated
|
||||||
run: |
|
run: |
|
||||||
$versionInfoFile = "src/gui/ALVersionInfo.py"
|
$versionInfoFile = "src/gui/ALVersionInfo.py"
|
||||||
Write-Host "Verifying $versionInfoFile content:"
|
Write-Host "Verifying $versionInfoFile content:"
|
||||||
Write-Host "================================"
|
Write-Host "=================================="
|
||||||
Get-Content $versionInfoFile | Write-Host
|
Get-Content $versionInfoFile | Write-Host
|
||||||
Write-Host "================================"
|
Write-Host "=================================="
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.13'
|
python-version: '3.13'
|
||||||
|
|
||||||
@@ -69,7 +62,7 @@ jobs:
|
|||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -r requirement.txt
|
pip install -r requirement.txt
|
||||||
|
|
||||||
- name: Fix ddddocr compatibility and copy model files
|
- name: Solve ddddocr compatibility and copy model files
|
||||||
run: |
|
run: |
|
||||||
$ddddocrPath = python -c "import ddddocr, os; print(os.path.dirname(ddddocr.__file__))"
|
$ddddocrPath = python -c "import ddddocr, os; print(os.path.dirname(ddddocr.__file__))"
|
||||||
Write-Host "ddddocr package location: $ddddocrPath"
|
Write-Host "ddddocr package location: $ddddocrPath"
|
||||||
@@ -121,9 +114,9 @@ jobs:
|
|||||||
./compile_rc.bat
|
./compile_rc.bat
|
||||||
shell: cmd
|
shell: cmd
|
||||||
|
|
||||||
- name: Generate Main.spec dynamically
|
- name: Generate 'Main.spec'
|
||||||
run: |
|
run: |
|
||||||
$version = "${{ steps.get_tag.outputs.VERSION }}"
|
$version = "${{ steps.get_version.outputs.VERSION }}"
|
||||||
$exeName = "AutoLibrary-$version"
|
$exeName = "AutoLibrary-$version"
|
||||||
|
|
||||||
Write-Host "Generating Main.spec for version: $version"
|
Write-Host "Generating Main.spec for version: $version"
|
||||||
@@ -173,28 +166,29 @@ jobs:
|
|||||||
" icon=['src\\gui\\icons\\AutoLibrary_32x32.ico'],"
|
" icon=['src\\gui\\icons\\AutoLibrary_32x32.ico'],"
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
|
|
||||||
$specLines | Out-File -FilePath "Main.spec" -Encoding UTF8
|
$specLines | Out-File -FilePath "Main.spec" -Encoding UTF8
|
||||||
|
|
||||||
Write-Host "✓ Main.spec generated successfully"
|
Write-Host "✓ Main.spec generated successfully"
|
||||||
Write-Host "`n=== Generated Main.spec ==="
|
Write-Host "`nGenerated Main.spec ============"
|
||||||
Get-Content "Main.spec" | Write-Host
|
Get-Content "Main.spec" | Write-Host
|
||||||
Write-Host "==========================`n"
|
Write-Host "==================================`n"
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
|
|
||||||
- name: Build with PyInstaller
|
- name: Build with PyInstaller
|
||||||
run: |
|
run: |
|
||||||
pyinstaller Main.spec
|
pyinstaller Main.spec
|
||||||
|
|
||||||
- name: Create Release Archive
|
- name: Zip windows release
|
||||||
|
id: zip_release
|
||||||
run: |
|
run: |
|
||||||
$tagName = "${{ steps.get_tag.outputs.TAG_NAME }}"
|
$tagName = "${{ steps.get_version.outputs.TAG_NAME }}"
|
||||||
$version = "${{ steps.get_tag.outputs.VERSION }}"
|
$version = "${{ steps.get_version.outputs.VERSION }}"
|
||||||
$exeName = "AutoLibrary-$version.exe"
|
$exeName = "AutoLibrary-$version.exe"
|
||||||
$zipName = "AutoLibrary.$tagName-windows-x86_64.zip"
|
$zipName = "AutoLibrary.$tagName-windows-x86_64.zip"
|
||||||
|
|
||||||
Write-Host "Looking for executable: dist/$exeName"
|
echo "ZIP_PATH=$zipName" >> $env:GITHUB_OUTPUT
|
||||||
|
|
||||||
|
Write-Host "Looking for executable: dist/$exeName"
|
||||||
if (Test-Path "dist/$exeName") {
|
if (Test-Path "dist/$exeName") {
|
||||||
Compress-Archive -Path "dist/$exeName" -DestinationPath $zipName
|
Compress-Archive -Path "dist/$exeName" -DestinationPath $zipName
|
||||||
Write-Host "✓ Created release archive: $zipName"
|
Write-Host "✓ Created release archive: $zipName"
|
||||||
@@ -206,31 +200,9 @@ jobs:
|
|||||||
}
|
}
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
|
|
||||||
- name: Create Release
|
- name: Archive artifacts
|
||||||
id: create_release
|
uses: actions/upload-artifact@v4
|
||||||
uses: softprops/action-gh-release@v2
|
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.get_tag.outputs.TAG_NAME }}
|
name: AutoLibrary.${{ steps.get_version.outputs.TAG_NAME }}-windows-x86_64
|
||||||
name: AutoLibrary ${{ steps.get_tag.outputs.TAG_NAME }}
|
path: |
|
||||||
files: |
|
${{ steps.zip_release.outputs.ZIP_PATH }}
|
||||||
AutoLibrary.${{ steps.get_tag.outputs.TAG_NAME }}-windows-x86_64.zip
|
|
||||||
draft: false
|
|
||||||
prerelease: false
|
|
||||||
generate_release_notes: true
|
|
||||||
body: |
|
|
||||||
### 下载获取
|
|
||||||
- **Windows x86_64**: `AutoLibrary.${{ steps.get_tag.outputs.TAG_NAME }}-windows-x86_64.zip`
|
|
||||||
|
|
||||||
### 如何使用
|
|
||||||
1. 下载 `AutoLibrary.${{ steps.get_tag.outputs.TAG_NAME }}-windows-x86_64.zip` 文件
|
|
||||||
2. 解压到任意目录
|
|
||||||
3. 下载对应浏览器的驱动文件
|
|
||||||
4. 运行 `AutoLibrary-${{ steps.get_tag.outputs.VERSION }}.exe` (首次运行会初始化配置文件)
|
|
||||||
5. 按照提示操作即可
|
|
||||||
|
|
||||||
更多详情请访问 [AutoLibrary 网站](http://autolibrary.cv) 和查看 [帮助手册](https://autolibrary.cv/docs/manual_lists.html)
|
|
||||||
|
|
||||||
---
|
|
||||||
**完整更新日志见下方自动生成的 Release Notes**
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
name: Commit and Move Tag
|
name: Commit Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
@@ -18,10 +18,10 @@ on:
|
|||||||
outputs:
|
outputs:
|
||||||
new_commit_sha:
|
new_commit_sha:
|
||||||
description: 'The new commit SHA after moving the tag'
|
description: 'The new commit SHA after moving the tag'
|
||||||
value: ${{ jobs.commit-and-move-tag.outputs.new_commit_sha }}
|
value: ${{ jobs.commit-release.outputs.new_commit_sha }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
commit-and-move-tag:
|
commit-release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -52,9 +52,9 @@ jobs:
|
|||||||
|
|
||||||
echo "✓ File replaced: $FILE_PATH"
|
echo "✓ File replaced: $FILE_PATH"
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== Updated file content ==="
|
echo "Updated file content ==================="
|
||||||
cat "$FILE_PATH"
|
cat "$FILE_PATH"
|
||||||
echo "============================"
|
echo "========================================"
|
||||||
|
|
||||||
- name: Commit changes
|
- name: Commit changes
|
||||||
id: commit_changes
|
id: commit_changes
|
||||||
@@ -85,7 +85,7 @@ jobs:
|
|||||||
git push origin HEAD:${MAIN_BRANCH}
|
git push origin HEAD:${MAIN_BRANCH}
|
||||||
echo "✓ Changes pushed to ${MAIN_BRANCH}"
|
echo "✓ Changes pushed to ${MAIN_BRANCH}"
|
||||||
|
|
||||||
- name: Move tag to new commit
|
- name: Move tag to new release commit
|
||||||
run: |
|
run: |
|
||||||
TAG_NAME="${{ inputs.tag_name }}"
|
TAG_NAME="${{ inputs.tag_name }}"
|
||||||
|
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
#
|
||||||
|
# Start :
|
||||||
|
# virtual job that indacates the start of the release process
|
||||||
|
#
|
||||||
|
|
||||||
|
start:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Start release
|
||||||
|
run: |
|
||||||
|
echo "✓ Starting release"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Update version :
|
||||||
|
# this job updates the version in the file 'ALVersionInfo.py'
|
||||||
|
#
|
||||||
|
|
||||||
|
update-version:
|
||||||
|
needs:
|
||||||
|
- start
|
||||||
|
uses: ./.github/workflows/update-version.yml
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.ref_name }}
|
||||||
|
ref: ${{ github.ref }}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Commit release :
|
||||||
|
# this job commits the updated version file and move the release
|
||||||
|
# tag to this new commit
|
||||||
|
#
|
||||||
|
|
||||||
|
commit-release:
|
||||||
|
needs:
|
||||||
|
- update-version
|
||||||
|
if: ${{ needs.update-version.outputs.has_changes == 'true' }}
|
||||||
|
uses: ./.github/workflows/commit-release.yml
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
with:
|
||||||
|
tag_name: ${{ needs.update-version.outputs.tag_name }}
|
||||||
|
version: ${{ needs.update-version.outputs.version }}
|
||||||
|
file_path: src/gui/ALVersionInfo.py
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build :
|
||||||
|
# this job builds the application and archives them
|
||||||
|
|
||||||
|
build:
|
||||||
|
needs:
|
||||||
|
- update-version
|
||||||
|
- commit-release
|
||||||
|
if: always() && needs.update-version.result == 'success' && needs.commit-release.result == 'success'
|
||||||
|
uses: ./.github/workflows/build.yml
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
with:
|
||||||
|
version: ${{ needs.update-version.outputs.version }}
|
||||||
|
tag_name: ${{ needs.update-version.outputs.tag_name }}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Release :
|
||||||
|
# this job creates a GitHub release and uploads the archive files
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
if: always() && needs.build.result == 'success'
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: AutoLibrary.${{ needs.build.outputs.tag_name }}-windows-x86_64
|
||||||
|
path: artifacts/
|
||||||
|
|
||||||
|
- name: Create release
|
||||||
|
id: create_release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
tag_name: ${{ needs.build.outputs.tag_name }}
|
||||||
|
name: AutoLibrary ${{ needs.build.outputs.tag_name }}
|
||||||
|
files: |
|
||||||
|
artifacts/AutoLibrary.${{ needs.build.outputs.tag_name }}-windows-x86_64.zip
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
generate_release_notes: true
|
||||||
|
body: |
|
||||||
|
### 下载获取
|
||||||
|
- **Windows x86_64**: `AutoLibrary.${{ needs.build.outputs.tag_name }}-windows-x86_64.zip`
|
||||||
|
|
||||||
|
### 如何使用
|
||||||
|
1. 下载 `AutoLibrary.${{ needs.build.outputs.tag_name }}-windows-x86_64.zip` 文件
|
||||||
|
2. 解压到任意目录
|
||||||
|
3. 下载对应浏览器的驱动文件
|
||||||
|
4. 运行 `AutoLibrary-${{ needs.build.outputs.version }}.exe` (首次运行会初始化配置文件)
|
||||||
|
5. 按照提示操作即可
|
||||||
|
|
||||||
|
更多详情请访问 [AutoLibrary 网站](http://autolibrary.cv) 和查看 [帮助手册](https://autolibrary.cv/docs/manual_lists.html)
|
||||||
|
|
||||||
|
---
|
||||||
|
**完整更新日志见下方自动生成的 Release Notes**
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
# End :
|
||||||
|
# virtual job that indacates the end of the release process
|
||||||
|
#
|
||||||
|
|
||||||
|
end:
|
||||||
|
needs:
|
||||||
|
- release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: End release
|
||||||
|
run: |
|
||||||
|
echo "✓ Ending release"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
name: Update Version Info
|
name: Update Version
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
tag_name:
|
tag_name:
|
||||||
description: 'Tag name (e.g., v1.0.0)'
|
description: 'Tag name'
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
ref:
|
ref:
|
||||||
@@ -14,16 +14,16 @@ on:
|
|||||||
outputs:
|
outputs:
|
||||||
tag_name:
|
tag_name:
|
||||||
description: 'The tag name'
|
description: 'The tag name'
|
||||||
value: ${{ jobs.update-version-info.outputs.tag_name }}
|
value: ${{ jobs.update-version.outputs.tag_name }}
|
||||||
version:
|
version:
|
||||||
description: 'The version number'
|
description: 'The version number'
|
||||||
value: ${{ jobs.update-version-info.outputs.version }}
|
value: ${{ jobs.update-version.outputs.version }}
|
||||||
has_changes:
|
has_changes:
|
||||||
description: 'Whether ALVersionInfo.py was modified'
|
description: 'Whether ALVersionInfo.py was modified'
|
||||||
value: ${{ jobs.update-version-info.outputs.has_changes }}
|
value: ${{ jobs.update-version.outputs.has_changes }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-version-info:
|
update-version:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -69,14 +69,13 @@ jobs:
|
|||||||
BUILD_DATE=$(date -u '+%Y-%m-%d %H:%M:%S UTC')
|
BUILD_DATE=$(date -u '+%Y-%m-%d %H:%M:%S UTC')
|
||||||
|
|
||||||
echo "Updating $APP_INFO_FILE with build information..."
|
echo "Updating $APP_INFO_FILE with build information..."
|
||||||
|
|
||||||
{
|
{
|
||||||
echo '# -*- coding: utf-8 -*-'
|
echo '# -*- coding: utf-8 -*-'
|
||||||
echo ''
|
echo ''
|
||||||
echo '"""'
|
echo '"""'
|
||||||
echo ' The contents of this file will automatically be updated by the'
|
echo ' The contents of this file will automatically be updated by the'
|
||||||
echo ' workflow process. Do not edit manually.'
|
echo ' workflow process. Do not edit manually.'
|
||||||
echo ' '
|
echo ''
|
||||||
echo ' This file is auto-generated during the workflow process.'
|
echo ' This file is auto-generated during the workflow process.'
|
||||||
echo " Last updated: ${BUILD_DATE}"
|
echo " Last updated: ${BUILD_DATE}"
|
||||||
echo '"""'
|
echo '"""'
|
||||||
@@ -91,9 +90,9 @@ jobs:
|
|||||||
|
|
||||||
echo "✓ ALVersionInfo.py updated successfully"
|
echo "✓ ALVersionInfo.py updated successfully"
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== Updated ALVersionInfo.py ==="
|
echo "Updated ALVersionInfo.py ==============="
|
||||||
cat "$APP_INFO_FILE"
|
cat "$APP_INFO_FILE"
|
||||||
echo "=========================="
|
echo "========================================"
|
||||||
|
|
||||||
- name: Check if ALVersionInfo.py was modified
|
- name: Check if ALVersionInfo.py was modified
|
||||||
id: check_changes
|
id: check_changes
|
||||||
Reference in New Issue
Block a user