diff --git a/.gitea/workflows/gui-version-release.yml b/.gitea/workflows/gui-version-release.yml index 6d205ab..6dd66c0 100644 --- a/.gitea/workflows/gui-version-release.yml +++ b/.gitea/workflows/gui-version-release.yml @@ -77,13 +77,23 @@ jobs: # Retry mechanism: maximum 3 attempts $SUCCESS = $false + $VERSION = "" for ($i = 1; $i -le 3; $i++) { Write-Host "Attempt $i to create version record..." - python .gitea/scripts/gui_version_creator.py + $output = python .gitea/scripts/gui_version_creator.py | Out-String if ($LASTEXITCODE -eq 0) { Write-Host "Version record created successfully" $SUCCESS = $true + + # Extract version from JSON output (last line) + $jsonLine = ($output -split "`n" | Where-Object { $_ -match '^\{' } | Select-Object -Last 1) + if ($jsonLine) { + $json = $jsonLine | ConvertFrom-Json + $VERSION = $json.version + Write-Host "Created version: $VERSION" + } + break } else { Write-Host "Attempt $i failed" @@ -100,6 +110,9 @@ jobs: Write-Host "Version creation failed" exit 1 } + + # Set version for next steps + echo "VERSION=$VERSION" >> $env:GITHUB_ENV env: DB_HOST: 8.155.9.53 DB_NAME: ai_web @@ -107,7 +120,30 @@ jobs: DB_PASSWORD: password_ee2iQ3 DB_PORT: 5400 - # Step 5: Display summary + # Step 5: Commit changes back to repository + - name: Commit version changes + if: success() + shell: powershell + run: | + Write-Host "Committing version changes..." + Write-Host "New version: $env:VERSION" + + git config user.name "Gitea Actions" + git config user.email "actions@gitea.local" + + git add config.py + git add version_history.json + + $hasChanges = git diff --staged --quiet + if ($LASTEXITCODE -ne 0) { + git commit -m "[skip ci] Update version to $env:VERSION" + git push origin master + Write-Host "Version changes committed and pushed" + } else { + Write-Host "No changes to commit" + } + + # Step 6: Display summary - name: Display summary if: always() shell: powershell