diff --git a/.github/workflows/windows-distribution.yml b/.github/workflows/windows-distribution.yml index 0386e91..401550f 100644 --- a/.github/workflows/windows-distribution.yml +++ b/.github/workflows/windows-distribution.yml @@ -6,8 +6,13 @@ on: branches: - agent/next-ten-roadmap tags: - - "v*" + - "*" workflow_dispatch: + inputs: + release_tag: + description: "Optional existing release tag to build and publish assets for" + required: false + type: string permissions: contents: write @@ -18,6 +23,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + ref: ${{ inputs.release_tag || github.ref }} - uses: actions/setup-python@v5 with: @@ -27,6 +34,31 @@ jobs: - name: Install build dependencies run: python -m pip install ".[dev,distribution]" + - name: Resolve package and release version + id: release + shell: pwsh + run: | + $version = (python -c "from computer_agent import __version__; print(__version__)").Trim() + if (-not $version) { + throw "Interly package version could not be resolved." + } + + $releaseTag = "${{ inputs.release_tag }}" + if (-not $releaseTag -and "${{ github.ref_type }}" -eq "tag") { + $releaseTag = "${{ github.ref_name }}" + } + if (-not $releaseTag) { + $releaseTag = "v$version" + } + + $tagVersion = $releaseTag -replace '^v', '' + if ($tagVersion -ne $version) { + throw "Release tag '$releaseTag' does not match package version '$version'." + } + + "version=$version" >> $env:GITHUB_OUTPUT + "tag=$releaseTag" >> $env:GITHUB_OUTPUT + - name: Test env: PYNPUT_BACKEND: dummy @@ -46,7 +78,7 @@ jobs: shell: pwsh run: | $version = & .\dist\interly.exe --version - if ($LASTEXITCODE -ne 0 -or $version -ne "Interly 0.6.0") { + if ($LASTEXITCODE -ne 0 -or $version -ne "Interly ${{ steps.release.outputs.version }}") { throw "Standalone executable smoke test failed: $version" } $documentSupport = & .\dist\interly.exe --check-document-support @@ -60,16 +92,18 @@ jobs: - name: Build Windows installer shell: pwsh run: | - & "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe" "/DMyAppVersion=0.6.0" packaging\interly.iss + & "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe" "/DMyAppVersion=${{ steps.release.outputs.version }}" packaging\interly.iss if ($LASTEXITCODE -ne 0) { throw "Inno Setup failed." } - name: Generate WinGet manifests shell: pwsh run: | + $version = "${{ steps.release.outputs.version }}" + $releaseTag = "${{ steps.release.outputs.tag }}" $sha = (Get-FileHash .\dist\InterlySetup-x64.exe -Algorithm SHA256).Hash - $url = "https://github.com/interlinkglobal/Interly/releases/download/v0.6.0/InterlySetup-x64.exe" - python packaging\render_winget.py --version 0.6.0 --installer-url $url --sha256 $sha --output dist\winget - Compress-Archive -Path dist\winget\* -DestinationPath dist\Interly-0.6.0-winget-manifests.zip + $url = "https://github.com/interlinkglobal/Interly/releases/download/$releaseTag/InterlySetup-x64.exe" + python packaging\render_winget.py --version $version --installer-url $url --sha256 $sha --output dist\winget + Compress-Archive -Path dist\winget\* -DestinationPath "dist\Interly-$version-winget-manifests.zip" - name: Upload build artifact uses: actions/upload-artifact@v4 @@ -79,15 +113,17 @@ jobs: dist/interly.exe dist/interlink.exe dist/InterlySetup-x64.exe - dist/Interly-0.6.0-winget-manifests.zip + dist/Interly-${{ steps.release.outputs.version }}-winget-manifests.zip - name: Publish GitHub release - if: startsWith(github.ref, 'refs/tags/v') + if: github.ref_type == 'tag' || inputs.release_tag != '' uses: softprops/action-gh-release@v2 with: + tag_name: ${{ steps.release.outputs.tag }} + overwrite_files: true generate_release_notes: true files: | dist/interly.exe dist/interlink.exe dist/InterlySetup-x64.exe - dist/Interly-0.6.0-winget-manifests.zip + dist/Interly-${{ steps.release.outputs.version }}-winget-manifests.zip