diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b1d132cf..6cbba0c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -64,6 +64,7 @@ on: - all # android + ios + macos + windows + linux - mobile # android + ios only — skips the desktop builds - android # android only; no macOS runner is started at all + - windows # windows only, to add it to a release whose Windows build failed release: description: 'What to do with the GitHub Release' type: choice @@ -180,10 +181,11 @@ jobs: with: # The tag push below needs real history, not a shallow clone. fetch-depth: 0 - # GITHUB_TOKEN, writable through the job's permissions above. A - # RELEASE_PAT is still honoured if one is ever added, but see the - # push step: a PAT-pushed tag re-triggers workflows. - token: ${{ secrets.RELEASE_PAT || github.token }} + # GITHUB_TOKEN, writable through the job's permissions above. Not the + # RELEASE_PAT secret: that token now gets a 403 ("Permission denied + # to professorDeveloper"), so 3.2.1+9 was never written back, and a + # PAT-pushed tag would start this workflow again anyway. + token: ${{ github.token }} # Which machines build this release. # @@ -379,6 +381,7 @@ jobs: # ---------------------------------------------------------------- Android ---- android: needs: version + if: ${{ inputs.platforms != 'windows' }} runs-on: ${{ fromJSON(needs.version.outputs.android_runner) }} timeout-minutes: 45 steps: @@ -606,7 +609,7 @@ jobs: needs: version # Desktop is not part of a mobile release. Skipping the job skips the whole # runner, which is the only saving that is ever 100%. - if: ${{ inputs.platforms == '' || inputs.platforms == 'all' }} + if: ${{ inputs.platforms == '' || inputs.platforms == 'all' || inputs.platforms == 'windows' }} runs-on: windows-latest timeout-minutes: 60 env: @@ -775,7 +778,7 @@ jobs: # The expensive one. Started for 'all' and 'mobile' (iOS lives here), and # not at all for an Android-only release. A tag push has no inputs, so the # empty case means everything. - if: ${{ inputs.platforms == '' || inputs.platforms != 'android' }} + if: ${{ inputs.platforms == '' || (inputs.platforms != 'android' && inputs.platforms != 'windows') }} needs: version runs-on: ${{ fromJSON(needs.version.outputs.mac_runner) }} # A self-hosted runner that is offline queues a job for six hours before @@ -1016,6 +1019,21 @@ jobs: API="${API%/}" echo "### CDN" >> "$GITHUB_STEP_SUMMARY" + # Cloudflare answers GitHub's runners (Azure addresses) with a "Just a + # moment..." challenge page. That is not a failure of this release: + # the backend takes a published release from GitHub itself + # (src/jobs/appReleaseSyncCron.js in sozo-backend), so this job steps + # aside instead of turning the run red. + challenged() { + [ "$1" = 403 ] && grep -qiE 'just a moment|cf-chl|challenge-platform' "$2" 2>/dev/null + } + defer() { + echo "status=deferred" >> "$GITHUB_OUTPUT" + echo "::warning title=CDN deferred to the backend::Cloudflare challenged ${1} from this runner. The backend uploads the APKs and updates the admin panel by itself within 10 minutes of the GitHub release being published." + echo "Cloudflare challenged the runner; the backend takes the release from GitHub once it is published." >> "$GITHUB_STEP_SUMMARY" + exit 0 + } + # x86_64 is for emulators and has no row on the download page. for pair in arm64-v8a:arm64 armeabi-v7a:armv7; do ABI="${pair%%:*}"; ARCH="${pair##*:}" @@ -1033,6 +1051,7 @@ jobs: HTTP="$(curl -sS --max-time 30 -X POST "${API}/admin/downloads/upload-url" \ -H "X-Release-Token: ${SOZO_MOBILE_RELEASE_TOKEN}" -H 'Content-Type: application/json' \ --data @presign-req.json -o presign.json -w '%{http_code}')" || HTTP=000 + if challenged "${HTTP}" presign.json; then defer "POST /admin/downloads/upload-url"; fi if [ "${HTTP}" != 200 ]; then echo "::error title=CDN upload URL::POST /admin/downloads/upload-url (${ARCH}) returned HTTP ${HTTP}: $(head -c 300 presign.json 2>/dev/null)" exit 1 @@ -1059,6 +1078,7 @@ jobs: HTTP="$(curl -sS --max-time 30 -X POST "${API}/admin/downloads" \ -H "X-Release-Token: ${SOZO_MOBILE_RELEASE_TOKEN}" -H 'Content-Type: application/json' \ --data @download-req.json -o download.json -w '%{http_code}')" || HTTP=000 + if challenged "${HTTP}" download.json; then defer "POST /admin/downloads"; fi if [ "${HTTP}" != 201 ]; then echo "::error title=Download row::POST /admin/downloads (${ARCH}) returned HTTP ${HTTP}: $(head -c 300 download.json 2>/dev/null). The file is on the CDN at ${PUBLIC_URL} but not listed." exit 1 @@ -1082,6 +1102,11 @@ jobs: HTTP="$(curl -sS --max-time 30 "${API}/admin/app-versions/android" \ -H "X-Release-Token: ${SOZO_MOBILE_RELEASE_TOKEN}" \ -o current.json -w '%{http_code}')" || HTTP=000 + if [ "${HTTP}" = 403 ] && grep -qiE 'just a moment|cf-chl|challenge-platform' current.json; then + echo "status=deferred" >> "$GITHUB_OUTPUT" + echo "::warning title=Updater deferred to the backend::Cloudflare challenged the runner; the backend points the updater at this build once the GitHub release is published." + exit 0 + fi case "${HTTP}" in 200) ;; 404) echo '{"minVersion": 1, "forceUpdate": false, "active": true}' > current.json ;; @@ -1107,6 +1132,11 @@ jobs: HTTP="$(curl -sS --max-time 30 -X PUT "${API}/admin/app-versions/android" \ -H "X-Release-Token: ${SOZO_MOBILE_RELEASE_TOKEN}" -H 'Content-Type: application/json' \ --data @updater-req.json -o updated.json -w '%{http_code}')" || HTTP=000 + if [ "${HTTP}" = 403 ] && grep -qiE 'just a moment|cf-chl|challenge-platform' updated.json; then + echo "status=deferred" >> "$GITHUB_OUTPUT" + echo "::warning title=Updater deferred to the backend::Cloudflare challenged the runner; the backend points the updater at this build once the GitHub release is published." + exit 0 + fi if [ "${HTTP}" != 200 ]; then echo "::error title=Updater write::PUT /admin/app-versions/android returned HTTP ${HTTP}: $(head -c 300 updated.json 2>/dev/null)" exit 1 @@ -1147,6 +1177,9 @@ jobs: id: stage env: V: ${{ needs.version.outputs.name }} + BUILD: ${{ needs.version.outputs.build }} + SHA: ${{ needs.version.outputs.sha }} + NOTES: ${{ inputs.notes }} run: | set -euo pipefail mkdir -p rel @@ -1192,6 +1225,12 @@ jobs: exit 1 fi + # What the backend reads when it takes this release from GitHub + # (sozo-backend src/services/appReleaseSync.service.js): the build + # number the in-app updater compares, which no file name carries. + jq -n --arg version "${V}" --argjson build "${BUILD}" --arg sha "${SHA}" --arg notes "${NOTES}" \ + '{version: $version, build: $build, sha: $sha, notes: $notes}' > "rel/Sozo-v${V}-release.json" + # Checksums, so a download can be verified and a re-upload can be # told apart from the original. ( cd rel && sha256sum * > "Sozo-v${V}-SHA256SUMS.txt" ) @@ -1247,6 +1286,14 @@ jobs: # have written them, and a re-run must not replace them with the # generated ones. if gh release view "${TAG}" >/dev/null 2>&1; then + # A run that rebuilt only some platforms (platforms: windows) must + # not replace the checksums of the files it did not touch. + SUMS="Sozo-v${V}-SHA256SUMS.txt" + if gh release download "${TAG}" -p "${SUMS}" -D old >/dev/null 2>&1; then + awk 'NR == FNR { new[$2] = $0; next } !($2 in new) { print } END { for (f in new) print new[f] }' \ + "rel/${SUMS}" "old/${SUMS}" | sort -k2 > merged.txt + mv merged.txt "rel/${SUMS}" + fi gh release upload "${TAG}" rel/* --clobber else # --target, not --verify-tag. @@ -1414,6 +1461,7 @@ jobs: # 2. Under the files: what a person needs to install them. FOOT="$(printf '🐉 Sozo %s · build %s' "${VERSION_NAME}" "${VERSION_BUILD}")" case "${CDN_STATUS}:${UPDATER}" in + deferred:*|uploaded:deferred) FOOT="${FOOT}$(printf '\n🔄 Ilova ichidagi yangilanish va yuklab olish sahifasi: release Publish qilingach server o‘zi yangilaydi (10 daqiqa ichida).')" ;; uploaded:published) FOOT="${FOOT}$(printf '\n🔄 Ilova ichidagi yangilanish va yuklab olish sahifasi yangilandi.')" ;; uploaded:*) FOOT="${FOOT}$(printf '\n⚠️ Ilova ichidagi yangilanish YANGILANMADI.')" ;; skipped:*) FOOT="${FOOT}$(printf '\n⚠️ CDN/adminka: o‘tkazib yuborildi (SOZO_MOBILE_RELEASE_TOKEN yo‘q).')" ;; diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml new file mode 100644 index 00000000..5d42d8a1 --- /dev/null +++ b/.github/workflows/windows-ci.yml @@ -0,0 +1,60 @@ +name: Windows build + +# ci.yml builds Android and Linux but not Windows, so when #46 (2026-11-10) +# broke the Windows build, nothing caught it until two releases shipped +# without Windows. This runs only on changes that can break the Windows +# build, because a Windows runner costs twice as much as a Linux one. +on: + pull_request: + paths: + - 'pubspec.yaml' + - 'pubspec.lock' + - 'windows/**' + - 'assets/shaders/**' + - '.github/workflows/windows-ci.yml' + push: + branches: [master] + paths: + - 'pubspec.yaml' + - 'pubspec.lock' + - 'windows/**' + - 'assets/shaders/**' + - '.github/workflows/windows-ci.yml' + workflow_dispatch: + +concurrency: + group: windows-ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-windows: + runs-on: windows-latest + timeout-minutes: 45 + env: + # Same as release.yml's windows job. + CMAKE_POLICY_VERSION_MINIMUM: '3.5' + CL: /D_SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS + steps: + - uses: actions/checkout@v4 + - uses: subosito/flutter-action@v2 + with: + channel: stable + flutter-version: 3.47.9 + cache: true + - name: Ensure NuGet (flutter_inappwebview_windows fetches WebView2 with it) + uses: NuGet/setup-nuget@v2 + - name: Empty .env (a pubspec asset; the build fails without it) + shell: bash + run: touch .env + - run: flutter pub get + - run: flutter build windows --release + + # When it fails, show what MSBuild actually ran and what the tool printed, + # which `flutter build` filters down to the error lines. + - name: Diagnose flutter_assemble + if: failure() + shell: pwsh + run: | + Select-String -Path build\windows\x64\flutter\flutter_assemble.vcxproj -Pattern 'tool_backend' | Select-Object -First 4 | ForEach-Object { $_.Line.Trim() } + cmake --build build\windows\x64 --config Release --target flutter_assemble 2>&1 | + Select-String -Pattern 'tool_backend|SkSL|error|impellerc' -Context 1,1 | Select-Object -First 60 diff --git a/pubspec.yaml b/pubspec.yaml index 9f16ad32..30dd2eab 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,7 +21,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 3.2.0+8 +version: 3.2.1+9 environment: sdk: ^3.11.1 diff --git a/windows/flutter/CMakeLists.txt b/windows/flutter/CMakeLists.txt index 903f4899..a43399bf 100644 --- a/windows/flutter/CMakeLists.txt +++ b/windows/flutter/CMakeLists.txt @@ -94,9 +94,13 @@ add_custom_command( ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ${PHONY_OUTPUT} + # Through tool_backend.ps1, which keeps a shader's Skia warning from reading + # as an MSBuild error. See that file. COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} - "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass + -File "${CMAKE_CURRENT_SOURCE_DIR}/tool_backend.ps1" + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" ${FLUTTER_TARGET_PLATFORM} $ VERBATIM ) diff --git a/windows/flutter/tool_backend.ps1 b/windows/flutter/tool_backend.ps1 new file mode 100644 index 00000000..e95227ae --- /dev/null +++ b/windows/flutter/tool_backend.ps1 @@ -0,0 +1,38 @@ +# Runs Flutter's tool_backend.bat for flutter_assemble. Called from +# CMakeLists.txt next to this file. +# +# When a shader cannot be compiled for Skia, Flutter compiles it without Skia +# and carries on, but prints the Skia compiler's output as a warning, and that +# output has lines like "error: 58: loop index ...". MSBuild treats any line of +# that shape as a build error and fails the step with code -1 even though the +# tool exited 0. liquid_glass_renderer's shaders do this; they only run on +# Impeller, never on desktop. +# +# Inside that warning, from "is incompatible with SkSL" to its closing +# 'Full "..." error output written to' line, "error" is reworded. The block has +# "SkSL Error:", the generated SkSL source and "error: : ..." lines, and +# MSBuild flags more than one shape of them. The exit code is the tool's own, +# so a shader that really fails still fails the build. +param( + [Parameter(Mandatory = $true)][string]$Backend, + [Parameter(ValueFromRemainingArguments = $true)][string[]]$BackendArgs +) + +$ErrorActionPreference = 'Continue' + +$Backend = $Backend -replace '/', '\' +$quotedArgs = ($BackendArgs | ForEach-Object { '"' + $_ + '"' }) -join ' ' +[Console]::Out.WriteLine("tool_backend.ps1: $Backend $quotedArgs") + +$inSkslWarning = $false +cmd.exe /d /s /c "`"$Backend`" $quotedArgs 2>&1" | ForEach-Object { + $line = [string]$_ + if ($line -match 'is incompatible with SkSL') { $inSkslWarning = $true } + $closes = $line -match '^\s*Full ".*" error output written' + if ($inSkslWarning -or $line -match '^\s*error:\s*\d+:') { + $line = $line -replace '(?i)\berror\b', 'issue' + } + if ($closes) { $inSkslWarning = $false } + [Console]::Out.WriteLine($line) +} +exit $LASTEXITCODE