修改ci/cd

This commit is contained in:
jjz
2025-10-09 16:23:35 +08:00
parent a45788c4df
commit 497f0a3719

View File

@@ -9,64 +9,129 @@ jobs:
runs-on: windows runs-on: windows
steps: steps:
# Step 1: Checkout code # Step 1: Check working directory
- name: Checkout code - name: Check working environment
uses: actions/checkout@v4 shell: powershell
with: run: |
fetch-depth: 2 Write-Host "Current working directory:"
Get-Location
# Step 2: Setup Python environment Write-Host "Directory contents:"
- name: Setup Python Get-ChildItem
uses: actions/setup-python@v4 Write-Host "Git status:"
with: try {
python-version: '3.11' git status
} catch {
Write-Host "Not a git repository"
}
# Step 2: Check Python environment
- name: Check Python environment
shell: powershell
run: |
Write-Host "Python version:"
try {
python --version
} catch {
Write-Host "Python not installed"
}
Write-Host "Pip version:"
try {
pip --version
} catch {
Write-Host "Pip not installed"
}
# Step 3: Install dependencies # Step 3: Install dependencies
- name: Install dependencies - name: Install dependencies
shell: powershell shell: powershell
run: | run: |
Write-Host "Installing psycopg2-binary..."
python -m pip install --upgrade pip python -m pip install --upgrade pip
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to upgrade pip"
exit 1
}
pip install psycopg2-binary pip install psycopg2-binary
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to install psycopg2-binary"
exit 1
}
Write-Host "Dependencies installed successfully" Write-Host "Dependencies installed successfully"
# Step 4: Create GUI version record # Step 4: Create GUI version record
- name: Create version record - name: Create version record
id: create_version id: create_version
shell: powershell shell: powershell
env:
DB_HOST: 8.155.9.53
DB_PORT: 5400
DB_NAME: ai_web
DB_USER: user_emKCAb
DB_PASSWORD: password_ee2iQ3
run: | run: |
Write-Host "Starting GUI version release process..." Write-Host "Starting GUI version release process..."
Write-Host "Commit hash: ${{ github.sha }}" Write-Host "Commit hash: ${{ github.sha }}"
Write-Host "Commit author: ${{ github.actor }}" Write-Host "Commit author: ${{ github.actor }}"
Write-Host "Branch: ${{ github.ref_name }}" Write-Host "Branch: ${{ github.ref_name }}"
Write-Host "Database: $env:DB_NAME @ $env:DB_HOST"
python .gitea/scripts/gui_version_creator.py # Retry mechanism: maximum 3 attempts
$SUCCESS = $false
for ($i = 1; $i -le 3; $i++) {
Write-Host "Attempt $i to create version record..."
python .gitea/scripts/gui_version_creator.py
if ($LASTEXITCODE -eq 0) {
Write-Host "Version record created successfully"
$SUCCESS = $true
break
} else {
Write-Host "Attempt $i failed"
if ($i -eq 3) {
Write-Host "All 3 attempts failed"
} else {
Write-Host "Waiting 5 seconds before retry..."
Start-Sleep -Seconds 5
}
}
}
if ($LASTEXITCODE -eq 0) { if (-not $SUCCESS) {
Write-Host "Version record created successfully" Write-Host "Version creation failed"
} else {
Write-Host "Failed to create version record"
exit 1 exit 1
} }
env:
DB_HOST: 8.155.9.53
DB_NAME: ai_web
DB_USER: user_emKCAb
DB_PASSWORD: password_ee2iQ3
DB_PORT: 5400
# Step 5: Show summary # Step 5: Display summary
- name: Display summary - name: Display summary
if: always() if: always()
shell: powershell shell: powershell
run: | run: |
Write-Host "==========================================" $summaryFile = $env:GITHUB_STEP_SUMMARY
Write-Host "GUI Version Release Summary" if ($summaryFile) {
Write-Host "==========================================" "## GUI Version Release Summary" | Out-File -FilePath $summaryFile -Append -Encoding UTF8
Write-Host "Author: ${{ github.actor }}" "" | Out-File -FilePath $summaryFile -Append -Encoding UTF8
Write-Host "Branch: ${{ github.ref_name }}"
Write-Host "Commit: ${{ github.sha }}" if ("${{ job.status }}" -eq "success") {
Write-Host "Time: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" "**Status**: Version release succeeded" | Out-File -FilePath $summaryFile -Append -Encoding UTF8
Write-Host "Status: ${{ job.status }}" } else {
Write-Host "==========================================" "**Status**: Version release failed" | Out-File -FilePath $summaryFile -Append -Encoding UTF8
}
"**Author**: ${{ github.actor }}" | Out-File -FilePath $summaryFile -Append -Encoding UTF8
"**Branch**: ${{ github.ref_name }}" | Out-File -FilePath $summaryFile -Append -Encoding UTF8
"**Time**: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" | Out-File -FilePath $summaryFile -Append -Encoding UTF8
"**Commit**: ${{ github.sha }}" | Out-File -FilePath $summaryFile -Append -Encoding UTF8
} else {
Write-Host "=========================================="
Write-Host "GUI Version Release Summary"
Write-Host "=========================================="
Write-Host "Author: ${{ github.actor }}"
Write-Host "Branch: ${{ github.ref_name }}"
Write-Host "Time: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')"
Write-Host "Commit: ${{ github.sha }}"
Write-Host "Status: ${{ job.status }}"
Write-Host "=========================================="
}