|
| 1 | +--- |
| 2 | +name: CI-Windows-Installer |
| 3 | +permissions: {} |
| 4 | + |
| 5 | +on: |
| 6 | + workflow_call: |
| 7 | + inputs: |
| 8 | + azure_signing_account: |
| 9 | + default: '' |
| 10 | + required: false |
| 11 | + type: string |
| 12 | + azure_signing_cert_profile: |
| 13 | + default: '' |
| 14 | + required: false |
| 15 | + type: string |
| 16 | + azure_signing_endpoint: |
| 17 | + default: '' |
| 18 | + required: false |
| 19 | + type: string |
| 20 | + publish_release: |
| 21 | + default: false |
| 22 | + required: false |
| 23 | + type: boolean |
| 24 | + release_version: |
| 25 | + default: '' |
| 26 | + required: false |
| 27 | + type: string |
| 28 | + secrets: |
| 29 | + AZURE_CLIENT_ID: |
| 30 | + required: false |
| 31 | + AZURE_CLIENT_SECRET: |
| 32 | + required: false |
| 33 | + AZURE_TENANT_ID: |
| 34 | + required: false |
| 35 | + |
| 36 | +jobs: |
| 37 | + windows_installer: |
| 38 | + name: Windows Installer (${{ matrix.target }}) |
| 39 | + permissions: |
| 40 | + contents: read |
| 41 | + runs-on: windows-latest |
| 42 | + strategy: |
| 43 | + fail-fast: false |
| 44 | + matrix: |
| 45 | + include: |
| 46 | + - target: x86_64-pc-windows-msvc |
| 47 | + - target: aarch64-pc-windows-msvc |
| 48 | + env: |
| 49 | + CARGO_TERM_COLOR: always |
| 50 | + CARGO_WIX_REV: fde983c2e901970267e76b8fd68120fdd5457a57 |
| 51 | + WIX_EXTENSION_VERSION: 7.0.0 |
| 52 | + WIX_TOOL_PATH: ${{ github.workspace }}\.wix |
| 53 | + WIX_VERSION: 7.0.0 |
| 54 | + steps: |
| 55 | + - name: Checkout |
| 56 | + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 |
| 57 | + |
| 58 | + - name: Download Windows build artifact |
| 59 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 60 | + with: |
| 61 | + name: windows-build-${{ matrix.target }} |
| 62 | + path: . |
| 63 | + |
| 64 | + - name: Setup Rust |
| 65 | + uses: actions-rust-lang/setup-rust-toolchain@2b1f5e9b395427c92ee4e3331786ca3c37afe2d7 # v1.16.0 |
| 66 | + with: |
| 67 | + target: ${{ matrix.target }} |
| 68 | + cache: true |
| 69 | + cache-on-failure: false |
| 70 | + |
| 71 | + - name: Install cargo-edit |
| 72 | + if: inputs.publish_release |
| 73 | + run: cargo install cargo-edit |
| 74 | + |
| 75 | + - name: Update Version |
| 76 | + if: inputs.publish_release |
| 77 | + env: |
| 78 | + INPUTS_RELEASE_VERSION: ${{ inputs.release_version }} |
| 79 | + shell: pwsh |
| 80 | + run: | |
| 81 | + cargo set-version $env:INPUTS_RELEASE_VERSION |
| 82 | + cargo update --workspace |
| 83 | + cargo metadata --locked --no-deps --format-version 1 > $null |
| 84 | +
|
| 85 | + - name: Setup dotnet |
| 86 | + uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0 |
| 87 | + with: |
| 88 | + dotnet-version: '10.x' |
| 89 | + |
| 90 | + - name: Install WiX |
| 91 | + shell: pwsh |
| 92 | + run: | |
| 93 | + New-Item -ItemType Directory -Force -Path $env:WIX_TOOL_PATH | Out-Null |
| 94 | + dotnet tool install --tool-path $env:WIX_TOOL_PATH wix --version $env:WIX_VERSION |
| 95 | + $env:WIX_TOOL_PATH >> $env:GITHUB_PATH |
| 96 | + $env:PATH = "$env:WIX_TOOL_PATH;$env:PATH" |
| 97 | + wix eula accept wix7 |
| 98 | + wix extension add "WixToolset.UI.wixext/$env:WIX_EXTENSION_VERSION" |
| 99 | + wix extension add "WixToolset.Util.wixext/$env:WIX_EXTENSION_VERSION" |
| 100 | + wix --version |
| 101 | +
|
| 102 | + - name: Install cargo-wix |
| 103 | + run: >- |
| 104 | + cargo install --locked |
| 105 | + --git https://github.com/volks73/cargo-wix.git |
| 106 | + --rev ${{ env.CARGO_WIX_REV }} |
| 107 | + cargo-wix |
| 108 | +
|
| 109 | + - name: Sign Windows executable |
| 110 | + if: inputs.publish_release && inputs.azure_signing_account != '' |
| 111 | + uses: azure/trusted-signing-action@c7ab2a863ab5f9a846ddb8265964877ef296ee82 # v2.0.0 |
| 112 | + with: |
| 113 | + azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} |
| 114 | + azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }} |
| 115 | + azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} |
| 116 | + certificate-profile-name: ${{ inputs.azure_signing_cert_profile }} |
| 117 | + endpoint: ${{ inputs.azure_signing_endpoint }} |
| 118 | + files: ${{ github.workspace }}\target\${{ matrix.target }}\release\koko.exe |
| 119 | + signing-account-name: ${{ inputs.azure_signing_account }} |
| 120 | + |
| 121 | + - name: Create Windows archive |
| 122 | + shell: pwsh |
| 123 | + run: | |
| 124 | + New-Item -ItemType Directory -Force -Path artifacts | Out-Null |
| 125 | + 7z a "artifacts\koko-${{ matrix.target }}.7z" ` |
| 126 | + ".\assets" ` |
| 127 | + ".\target\${{ matrix.target }}\release\koko.exe" |
| 128 | +
|
| 129 | + - name: Package Windows installer |
| 130 | + shell: pwsh |
| 131 | + run: | |
| 132 | + cargo wix ` |
| 133 | + --toolset modern ` |
| 134 | + --target ${{ matrix.target }} ` |
| 135 | + --no-build ` |
| 136 | + --target-bin-dir "${{ github.workspace }}\target\${{ matrix.target }}\release" ` |
| 137 | + --package koko ` |
| 138 | + --output "artifacts\koko-${{ matrix.target }}-installer.msi" ` |
| 139 | + --nocapture ` |
| 140 | + crates/server/Cargo.toml |
| 141 | +
|
| 142 | + - name: Sign Windows installer |
| 143 | + if: inputs.publish_release && inputs.azure_signing_account != '' |
| 144 | + uses: azure/trusted-signing-action@c7ab2a863ab5f9a846ddb8265964877ef296ee82 # v2.0.0 |
| 145 | + with: |
| 146 | + azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} |
| 147 | + azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }} |
| 148 | + azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} |
| 149 | + certificate-profile-name: ${{ inputs.azure_signing_cert_profile }} |
| 150 | + endpoint: ${{ inputs.azure_signing_endpoint }} |
| 151 | + files-folder: artifacts |
| 152 | + files-folder-filter: msi |
| 153 | + files-folder-recurse: false |
| 154 | + signing-account-name: ${{ inputs.azure_signing_account }} |
| 155 | + |
| 156 | + - name: Upload Artifacts |
| 157 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 158 | + with: |
| 159 | + if-no-files-found: error |
| 160 | + name: koko-${{ matrix.target }} |
| 161 | + path: artifacts |
0 commit comments