From 6548140eaf8a6e807dd490c79a3cd0e8e0899c46 Mon Sep 17 00:00:00 2001 From: Charles GTE Date: Sat, 25 Jul 2026 15:19:46 +0200 Subject: [PATCH] fix: windows build --- .github/workflows/release.yml | 12 ++++ .github/workflows/windows-release.yml | 100 +++++++++++++------------- src/domain/docker_volume/docker.rs | 2 +- 3 files changed, 65 insertions(+), 49 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2b80707..4cc7d73 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -118,12 +118,24 @@ jobs: secrets: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + build-windows: + needs: create-release + if: ${{ needs.create-release.result == 'success' }} + uses: ./.github/workflows/windows-release.yml + with: + version: ${{ needs.create-release.outputs.version }} + ref: ${{ needs.create-release.outputs.version }} + draft_tag: ${{ needs.create-release.outputs.draft_tag }} + secrets: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + finalize-release: needs: - create-release - publish-docker - publish-docker-ghcr - publish-helm + - build-windows runs-on: ubuntu-latest outputs: release_tag: ${{ steps.publish_release_step.outputs.release_tag }} diff --git a/.github/workflows/windows-release.yml b/.github/workflows/windows-release.yml index c5e5cf3..5945754 100644 --- a/.github/workflows/windows-release.yml +++ b/.github/workflows/windows-release.yml @@ -1,14 +1,30 @@ 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: - push: - tags: - - '[0-9]+.[0-9]+.[0-9]+' - branches: - - main - - master + inputs: + ref: + description: 'Git ref to check out and build' + type: string + required: false jobs: build-windows: @@ -17,80 +33,68 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref || github.ref }} - name: Set up Rust toolchain (MSVC) - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: - toolchain: stable-x86_64-pc-windows-msvc - profile: minimal - override: true + targets: x86_64-pc-windows-msvc - - name: Install vcpkg and OpenSSL (x64) + - 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: | - # Install vcpkg and the prebuilt OpenSSL package - git clone https://github.com/microsoft/vcpkg C:\vcpkg - C:\vcpkg\bootstrap-vcpkg.bat - C:\vcpkg\vcpkg install openssl:x64-windows - # Export variables for subsequent steps + # 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 - env: - # Cargo / openssl-sys will pick up OPENSSL_DIR from the environment - OPENSSL_DIR: ${{ env.OPENSSL_DIR }} - run: | - # Ensure the environment variable is present for this step - if (-Not $env:OPENSSL_DIR) { Write-Host "OPENSSL_DIR not set, printing env for debugging"; Get-ChildItem Env: | ForEach-Object { Write-Host $_ } } - # Build the declared bin target explicitly (Cargo.toml [[bin]] name = "app") - cargo build --release --bin app + run: cargo build --release --bin app - name: Prepare artifact zip id: prepare_artifact shell: pwsh env: - RELEASE_TAG: ${{ github.ref_name }} + RELEASE_VERSION: ${{ inputs.version }} run: | - $tag = $env:RELEASE_TAG + $tag = $env:RELEASE_VERSION if (-not $tag) { $tag = $env:GITHUB_SHA } - # Package the declared bin target deterministically (Cargo.toml [[bin]] name = "app") $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" + # 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 - Write-Host "ZIP=$zipName" - Write-Output "zip=$zipName" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + "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: windows-release-*.zip + path: ${{ steps.prepare_artifact.outputs.zip }} - - name: Create GitHub Release - if: startsWith(github.ref, 'refs/tags/') - id: create_release - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{ github.ref_name }} + - name: Attach asset to draft release + if: ${{ inputs.draft_tag != '' }} + shell: pwsh env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload release asset - if: startsWith(github.ref, 'refs/tags/') - uses: actions/upload-release-asset@v1 - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: windows-release-${{ github.ref_name }}.zip - asset_name: windows-release-${{ github.ref_name }}.zip - asset_content_type: application/zip \ No newline at end of file + GH_TOKEN: ${{ secrets.GH_TOKEN }} + run: | + gh release upload "${{ inputs.draft_tag }}" "${{ steps.prepare_artifact.outputs.zip }}" --clobber diff --git a/src/domain/docker_volume/docker.rs b/src/domain/docker_volume/docker.rs index 8784230..9efa791 100644 --- a/src/domain/docker_volume/docker.rs +++ b/src/domain/docker_volume/docker.rs @@ -15,7 +15,7 @@ pub const EPHEMERAL_LABEL: &str = "io.portabase.ephemeral"; const HELPER_MOUNT: &str = "/vol"; pub fn client() -> Result { - Docker::connect_with_unix_defaults().context("Failed to connect to Docker daemon socket") + Docker::connect_with_defaults().context("Failed to connect to Docker daemon socket") } pub fn parse_container_id(mountinfo: &str, cgroup: &str) -> Option {