name: Desktop Release on: push: branches: - master jobs: release: runs-on: windows steps: - name: Checkout uses: https://git.daemonlord.ru/actions/checkout@v4 with: fetch-depth: 0 tags: true - name: Ensure Python 3.13 shell: powershell run: | if (Get-Command python -ErrorAction SilentlyContinue) { python --version } elseif (Get-Command py -ErrorAction SilentlyContinue) { $pyExe = py -3.13 -c "import sys; print(sys.executable)" if (-not $pyExe) { throw "Python 3.13 launcher is available, but interpreter was not found." } Split-Path $pyExe | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append python --version } else { throw "Python is not installed on runner. Install Python 3.13 and restart runner service." } - name: Install dependencies shell: powershell run: | python -m pip install --upgrade pip pip install -r requirements.txt pyinstaller - name: Extract app version id: extract_version shell: powershell run: | $version = (python -c "from app_version import APP_VERSION; print(APP_VERSION)").Trim() $utf8NoBom = New-Object System.Text.UTF8Encoding($false) [System.IO.File]::AppendAllText($env:GITHUB_OUTPUT, "version=$version`n", $utf8NoBom) Write-Host "Detected version: $version" - name: Stop if version already released id: stop shell: powershell run: | $version = "${{ steps.extract_version.outputs.version }}" $tag = "v$version" git show-ref --tags --quiet --verify "refs/tags/$tag" $tagExists = ($LASTEXITCODE -eq 0) $global:LASTEXITCODE = 0 $utf8NoBom = New-Object System.Text.UTF8Encoding($false) if ($tagExists) { Write-Host "Version $tag already released, stopping job." [System.IO.File]::AppendAllText($env:GITHUB_ENV, "CONTINUE=false`n", $utf8NoBom) } else { Write-Host "Version $tag not released yet, continuing workflow..." [System.IO.File]::AppendAllText($env:GITHUB_ENV, "CONTINUE=true`n", $utf8NoBom) } exit 0 - name: Run tests if: env.CONTINUE == 'true' shell: powershell run: | python -m py_compile app_version.py main.py build.py tests/test_auth_relogin_smoke.py python -m unittest tests/test_auth_relogin_smoke.py - name: Build release zip if: env.CONTINUE == 'true' shell: powershell run: | python build.py - name: Ensure archive exists if: env.CONTINUE == 'true' shell: powershell run: | $version = "${{ steps.extract_version.outputs.version }}" $archivePath = "dist/AnabasisManager-$version.zip" if (-not (Test-Path $archivePath)) { throw "Archive not found: $archivePath" } - name: Generate SHA256 checksum if: env.CONTINUE == 'true' shell: powershell run: | $version = "${{ steps.extract_version.outputs.version }}" $archiveName = "AnabasisManager-$version.zip" $archivePath = "dist/$archiveName" $checksumPath = "dist/$archiveName.sha256" $hash = (Get-FileHash -Path $archivePath -Algorithm SHA256).Hash.ToLower() "$hash $archiveName" | Set-Content -Path $checksumPath -Encoding UTF8 Write-Host "Checksum created: $checksumPath" - name: Configure git identity if: env.CONTINUE == 'true' shell: powershell run: | git config user.name "gitea-actions" git config user.email "gitea-actions@daemonlord.ru" - name: Create git tag if: env.CONTINUE == 'true' shell: powershell run: | $version = "${{ steps.extract_version.outputs.version }}" $tag = "v$version" git tag "$tag" git push origin "$tag" - name: Create Gitea Release if: env.CONTINUE == 'true' uses: https://git.daemonlord.ru/actions/gitea-release-action@v1 with: server_url: https://git.daemonlord.ru repository: ${{ gitea.repository }} token: ${{ secrets.API_TOKEN }} tag_name: v${{ steps.extract_version.outputs.version }} name: Anabasis Manager ${{ steps.extract_version.outputs.version }} body: | Desktop release v${{ steps.extract_version.outputs.version }} files: | dist/AnabasisManager-${{ steps.extract_version.outputs.version }}.zip dist/AnabasisManager-${{ steps.extract_version.outputs.version }}.zip.sha256