Prepare push-triggered v0.6.0 publisher #44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: ЦУП Альтаир — Windows installer | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| types: [opened, synchronize, reopened, closed] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-windows: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install PlatformIO | |
| run: python -m pip install --upgrade platformio | |
| - name: Compile ESP32 radio gateway | |
| run: pio run -d firmware/radio_gateway_esp32 | |
| - name: Compile STM32 v6 transmitter reference | |
| run: pio run -d firmware/transmitter_stm32_v6 | |
| - name: Prepare bundled ESP32 firmware | |
| shell: pwsh | |
| run: | | |
| $ErrorActionPreference = "Stop" | |
| $buildDir = "firmware/radio_gateway_esp32/.pio/build/esp32dev" | |
| $sourceCode = Get-Content "firmware/radio_gateway_esp32/src/main.cpp" -Raw | |
| if ($sourceCode -notmatch 'constexpr\s+char\s+FW_VERSION\[\]\s*=\s*"([^"]+)"') { | |
| throw "Unable to read FW_VERSION from ESP32 gateway source." | |
| } | |
| $firmwareVersion = $Matches[1] | |
| $bootApp0 = Get-ChildItem "$env:USERPROFILE/.platformio/packages" -Recurse -Filter "boot_app0.bin" | Select-Object -First 1 | |
| if (-not $bootApp0) { throw "boot_app0.bin was not found." } | |
| New-Item -ItemType Directory -Force "bundled_firmware" | Out-Null | |
| $images = @( | |
| @{ Source = "$buildDir/bootloader.bin"; File = "gateway-bootloader.bin"; Label = "Bootloader"; Address = 4096 }, | |
| @{ Source = "$buildDir/partitions.bin"; File = "gateway-partitions.bin"; Label = "Partition table"; Address = 32768 }, | |
| @{ Source = $bootApp0.FullName; File = "gateway-boot_app0.bin"; Label = "boot_app0"; Address = 57344 }, | |
| @{ Source = "$buildDir/firmware.bin"; File = "gateway-firmware.bin"; Label = "Altair radio gateway"; Address = 65536 } | |
| ) | |
| $manifestImages = @() | |
| foreach ($image in $images) { | |
| if (-not (Test-Path $image.Source)) { throw "Firmware image not found: $($image.Source)" } | |
| $target = Join-Path "bundled_firmware" $image.File | |
| Copy-Item $image.Source $target -Force | |
| $fileInfo = Get-Item $target | |
| $md5 = (Get-FileHash -Algorithm MD5 $target).Hash.ToLowerInvariant() | |
| $manifestImages += [ordered]@{ file=$image.File; label=$image.Label; address=$image.Address; size=$fileInfo.Length; md5=$md5 } | |
| } | |
| $appVersion = (Get-Content package.json -Raw | ConvertFrom-Json).version | |
| $manifest = [ordered]@{ | |
| schemaVersion = 1 | |
| targetBoard = "ESP32-WROOM-32 / esp32dev" | |
| targetChip = "ESP32" | |
| firmwareVersion = $firmwareVersion | |
| applicationVersion = $appVersion | |
| buildLabel = "Altair MCC v$appVersion CI" | |
| flashMode = "dio" | |
| flashFreq = "40m" | |
| flashSize = "4MB" | |
| eraseAll = $false | |
| images = $manifestImages | |
| } | |
| $manifest | ConvertTo-Json -Depth 6 | Set-Content "bundled_firmware/manifest.json" -Encoding utf8 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| - name: Install desktop build dependencies | |
| run: npm install --no-audit --no-fund | |
| - name: Build Windows installer | |
| run: npm run dist:win | |
| - name: Upload Windows installer artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: CUP-Altair-Windows-Installer | |
| path: | | |
| release/*.exe | |
| release/*.yml | |
| release/*.blockmap | |
| bundled_firmware/*.json | |
| bundled_firmware/*.bin | |
| if-no-files-found: error | |
| retention-days: 30 | |
| - name: Read application version | |
| if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true) }} | |
| id: app_version | |
| shell: pwsh | |
| run: | | |
| $version = (Get-Content package.json -Raw | ConvertFrom-Json).version | |
| "version=$version" >> $env:GITHUB_OUTPUT | |
| "tag=v$version" >> $env:GITHUB_OUTPUT | |
| - name: Publish GitHub Release when this version is new | |
| if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true) }} | |
| shell: pwsh | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| RELEASE_TAG: ${{ steps.app_version.outputs.tag }} | |
| RELEASE_VERSION: ${{ steps.app_version.outputs.version }} | |
| run: | | |
| gh release view $env:RELEASE_TAG *> $null | |
| if ($LASTEXITCODE -eq 0) { | |
| Write-Host "Release $env:RELEASE_TAG already exists." | |
| exit 0 | |
| } | |
| $installer = Get-ChildItem -Path release -Filter "CUP-Altair-Setup-*.exe" | Select-Object -First 1 | |
| if (-not $installer) { throw "Altair Windows installer was not found in release/." } | |
| gh release create $env:RELEASE_TAG $installer.FullName ` | |
| --target main ` | |
| --title "ЦУП Альтаир v6 ($env:RELEASE_TAG) — Технопром 2026. Миссия на Луну" ` | |
| --notes "ЦУП Альтаир v6: фиксированный 29-символьный пакет телеметрии с XOR, режимом 0/1, профиль CC1101 435.000 МГц, ESP32-приёмник с проверкой XOR, RSSI/SNR и STM32-скетч статического передатчика." ` | |
| --latest |