mirror of
https://github.com/Portabase/agent.git
synced 2026-09-11 02:27:10 +00:00
101 lines
3.2 KiB
YAML
101 lines
3.2 KiB
YAML
name: Build Windows release
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
version:
|
|
description: 'Release version (git tag), e.g. 1.18.4'
|
|
type: string
|
|
required: false
|
|
ref:
|
|
description: 'Git ref to check out and build'
|
|
type: string
|
|
required: false
|
|
draft_tag:
|
|
description: 'Draft GitHub release tag to attach the asset to (e.g. untagged-xxxx). Empty = skip upload.'
|
|
type: string
|
|
required: false
|
|
secrets:
|
|
GH_TOKEN:
|
|
required: false
|
|
|
|
workflow_dispatch:
|
|
inputs:
|
|
ref:
|
|
description: 'Git ref to check out and build'
|
|
type: string
|
|
required: false
|
|
|
|
jobs:
|
|
build-windows:
|
|
runs-on: windows-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ inputs.ref || github.ref }}
|
|
|
|
- name: Set up Rust toolchain (MSVC)
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: x86_64-pc-windows-msvc
|
|
|
|
- name: Cache cargo build
|
|
uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Cache vcpkg installed packages
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: C:\vcpkg\installed
|
|
key: vcpkg-openssl-x64-windows-v1
|
|
|
|
- name: Install OpenSSL (x64) via vcpkg
|
|
shell: pwsh
|
|
run: |
|
|
# windows-latest ships vcpkg preinstalled; the install is a no-op when the
|
|
# package is restored from cache.
|
|
& "$env:VCPKG_INSTALLATION_ROOT\vcpkg.exe" install openssl:x64-windows
|
|
'VCPKG_ROOT=C:\vcpkg' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
'OPENSSL_DIR=C:\vcpkg\installed\x64-windows' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
|
|
- name: Build (cargo release)
|
|
shell: pwsh
|
|
run: cargo build --release --bin app
|
|
|
|
- name: Prepare artifact zip
|
|
id: prepare_artifact
|
|
shell: pwsh
|
|
env:
|
|
RELEASE_VERSION: ${{ inputs.version }}
|
|
run: |
|
|
$tag = $env:RELEASE_VERSION
|
|
if (-not $tag) { $tag = $env:GITHUB_SHA }
|
|
|
|
$exe = "target\release\app.exe"
|
|
if (-not (Test-Path $exe)) { Write-Error "Built binary $exe not found in target/release"; exit 1 }
|
|
|
|
$outDir = "artifact"
|
|
New-Item -ItemType Directory -Path $outDir -Force | Out-Null
|
|
# Ship under the package name, not the internal bin name "app".
|
|
Copy-Item -Path $exe -Destination "$outDir\portabase-agent.exe"
|
|
|
|
$zipName = "windows-release-$tag.zip"
|
|
if (Test-Path $zipName) { Remove-Item $zipName }
|
|
Compress-Archive -Path "$outDir\*" -DestinationPath $zipName -Force
|
|
"zip=$zipName" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
|
|
|
|
- name: Upload build artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: windows-release
|
|
path: ${{ steps.prepare_artifact.outputs.zip }}
|
|
|
|
- name: Attach asset to draft release
|
|
if: ${{ inputs.draft_tag != '' }}
|
|
shell: pwsh
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
run: |
|
|
gh release upload "${{ inputs.draft_tag }}" "${{ steps.prepare_artifact.outputs.zip }}" --clobber
|