|
| 1 | +name: Build CPack Packages |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + build-type: |
| 7 | + description: CMake build type used for packaging |
| 8 | + type: string |
| 9 | + default: Release |
| 10 | + extra-cmake-flags: |
| 11 | + description: Additional flags passed to CMake configure step |
| 12 | + type: string |
| 13 | + default: "" |
| 14 | + save-artifacts: |
| 15 | + description: Save built packages as artifacts |
| 16 | + type: boolean |
| 17 | + default: false |
| 18 | + secrets: {} |
| 19 | + workflow_dispatch: |
| 20 | + inputs: |
| 21 | + build-type: |
| 22 | + description: CMake build type used for packaging |
| 23 | + type: string |
| 24 | + default: Release |
| 25 | + extra-cmake-flags: |
| 26 | + description: Additional flags passed to CMake configure step |
| 27 | + type: string |
| 28 | + default: "" |
| 29 | + save-artifacts: |
| 30 | + description: Save built packages as artifacts |
| 31 | + type: boolean |
| 32 | + default: false |
| 33 | + secrets: {} |
| 34 | + |
| 35 | +env: |
| 36 | + CARGO_TERM_COLOR: always |
| 37 | + |
| 38 | +jobs: |
| 39 | + linux: |
| 40 | + name: Linux packages |
| 41 | + runs-on: ubuntu-22.04 |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - name: Install tooling |
| 46 | + run: | |
| 47 | + sudo apt-get update |
| 48 | + sudo apt-get install -y rpm ninja-build |
| 49 | +
|
| 50 | + - name: Configure |
| 51 | + run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} ${{ inputs.extra-cmake-flags }} |
| 52 | + |
| 53 | + - name: Build |
| 54 | + run: cmake --build build --config ${{ inputs.build-type }} |
| 55 | + |
| 56 | + - name: Package (DEB and RPM) |
| 57 | + working-directory: build |
| 58 | + run: | |
| 59 | + cpack -G DEB -C ${{ inputs.build-type }} |
| 60 | + cpack -G RPM -C ${{ inputs.build-type }} |
| 61 | +
|
| 62 | + - name: Collect artifacts |
| 63 | + run: | |
| 64 | + set -euo pipefail |
| 65 | + shopt -s nullglob |
| 66 | + mkdir -p artifacts/linux |
| 67 | + for file in build/*.deb build/*.rpm; do |
| 68 | + cp "$file" artifacts/linux/ |
| 69 | + done |
| 70 | +
|
| 71 | + - uses: actions/upload-artifact@v4 |
| 72 | + if: inputs.save-artifacts |
| 73 | + with: |
| 74 | + name: linux-packages |
| 75 | + path: artifacts/linux |
| 76 | + retention-days: 7 |
| 77 | + |
| 78 | + macos: |
| 79 | + name: macOS packages |
| 80 | + runs-on: macos-13 |
| 81 | + steps: |
| 82 | + - uses: actions/checkout@v4 |
| 83 | + |
| 84 | + - name: Configure |
| 85 | + run: cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} ${{ inputs.extra-cmake-flags }} |
| 86 | + |
| 87 | + - name: Build |
| 88 | + run: cmake --build build --config ${{ inputs.build-type }} |
| 89 | + |
| 90 | + - name: Package (pkg and dmg) |
| 91 | + working-directory: build |
| 92 | + run: | |
| 93 | + cpack -G productbuild -C ${{ inputs.build-type }} |
| 94 | + cpack -G DragNDrop -C ${{ inputs.build-type }} |
| 95 | +
|
| 96 | + - name: Collect artifacts |
| 97 | + run: | |
| 98 | + set -euo pipefail |
| 99 | + shopt -s nullglob |
| 100 | + mkdir -p artifacts/macos |
| 101 | + for file in build/*.pkg build/*.dmg; do |
| 102 | + cp "$file" artifacts/macos/ |
| 103 | + done |
| 104 | +
|
| 105 | + - uses: actions/upload-artifact@v4 |
| 106 | + if: inputs.save-artifacts |
| 107 | + with: |
| 108 | + name: macos-packages |
| 109 | + path: artifacts/macos |
| 110 | + retention-days: 7 |
| 111 | + |
| 112 | + windows: |
| 113 | + name: Windows packages |
| 114 | + runs-on: windows-2022 |
| 115 | + steps: |
| 116 | + - uses: actions/checkout@v4 |
| 117 | + |
| 118 | + - name: Add WiX to PATH |
| 119 | + shell: pwsh |
| 120 | + run: | |
| 121 | + $wixPath = "C:\\Program Files (x86)\\WiX Toolset v3.11\\bin" |
| 122 | + if (Test-Path $wixPath) { Add-Content -Path $env:GITHUB_PATH -Value $wixPath } |
| 123 | +
|
| 124 | + - name: Install OpenSSL |
| 125 | + shell: pwsh |
| 126 | + run: | |
| 127 | + choco install openssl.light --no-progress -y |
| 128 | + $opensslRoot = "C:\\Program Files\\OpenSSL-Win64" |
| 129 | + if (-not (Test-Path $opensslRoot)) { |
| 130 | + $opensslRoot = "C:\\Program Files\\OpenSSL" |
| 131 | + } |
| 132 | + if (-not (Test-Path $opensslRoot)) { |
| 133 | + throw "OpenSSL installation path not found" |
| 134 | + } |
| 135 | + $libPath = Join-Path $opensslRoot "lib" |
| 136 | + $vcLibPath = Join-Path $libPath "VC\\x64" |
| 137 | + if (Test-Path $vcLibPath) { |
| 138 | + $libPath = $vcLibPath |
| 139 | + } |
| 140 | + "OPENSSL_DIR=$opensslRoot" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append |
| 141 | + "OPENSSL_ROOT_DIR=$opensslRoot" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append |
| 142 | + "OPENSSL_LIB_DIR=$libPath" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append |
| 143 | + "OPENSSL_INCLUDE_DIR=$(Join-Path $opensslRoot 'include')" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append |
| 144 | +
|
| 145 | + - name: Configure |
| 146 | + shell: pwsh |
| 147 | + run: | |
| 148 | + cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} ${{ inputs.extra-cmake-flags }} |
| 149 | +
|
| 150 | + - name: Build |
| 151 | + shell: pwsh |
| 152 | + run: cmake --build build --config ${{ inputs.build-type }} |
| 153 | + |
| 154 | + - name: Package (MSI) |
| 155 | + shell: pwsh |
| 156 | + working-directory: build |
| 157 | + run: cpack -G WIX -C ${{ inputs.build-type }} |
| 158 | + |
| 159 | + - name: Collect artifacts |
| 160 | + if: inputs.save-artifacts |
| 161 | + shell: pwsh |
| 162 | + run: | |
| 163 | + New-Item -ItemType Directory -Path artifacts\windows -Force | Out-Null |
| 164 | + Get-ChildItem build -Filter *.msi | Copy-Item -Destination artifacts\windows |
| 165 | +
|
| 166 | + - uses: actions/upload-artifact@v4 |
| 167 | + if: inputs.save-artifacts |
| 168 | + with: |
| 169 | + name: windows-packages |
| 170 | + path: artifacts/windows |
| 171 | + retention-days: 7 |
0 commit comments