|
| 1 | +name: "Build native binaries" |
| 2 | + |
| 3 | +# Reusable: builds the zstd-extract binaries on each platform's native toolchain, twice to make sure the build is |
| 4 | +# deterministic, and uploads them with their checksums as the "zstd-extract-binaries" artifact. |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_call: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + linux: |
| 14 | + name: "Linux ${{ matrix.arch }}" |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + - os: ubuntu-24.04 |
| 20 | + arch: x86_64 |
| 21 | + - os: ubuntu-24.04-arm |
| 22 | + arch: aarch64 |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 25 | + with: |
| 26 | + persist-credentials: false |
| 27 | + |
| 28 | + - name: Build |
| 29 | + env: |
| 30 | + ARCH: ${{ matrix.arch }} |
| 31 | + run: | |
| 32 | + bin="native/build/zstd-extract-linux-$ARCH" |
| 33 | + native/build-linux.sh |
| 34 | + cp "$bin" "$RUNNER_TEMP/first" |
| 35 | + rm -rf native/build |
| 36 | + native/build-linux.sh |
| 37 | + cmp "$RUNNER_TEMP/first" "$bin" # the build must be reproducible |
| 38 | + file "$bin" | grep -q 'static-pie linked' |
| 39 | + readelf -hW "$bin" | grep -q 'Type: *DYN' # position independent, for ASLR |
| 40 | + "$bin" --version |
| 41 | + "$bin" tests/Fixtures/level19.tar.zst "$RUNNER_TEMP/smoke" |
| 42 | + test -L "$RUNNER_TEMP/smoke/link-to-script" |
| 43 | +
|
| 44 | + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
| 45 | + with: |
| 46 | + name: linux-${{ matrix.arch }} |
| 47 | + path: native/build/zstd-extract-linux-${{ matrix.arch }} |
| 48 | + if-no-files-found: error |
| 49 | + |
| 50 | + darwin: |
| 51 | + name: "macOS universal" |
| 52 | + runs-on: macos-latest |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 55 | + with: |
| 56 | + persist-credentials: false |
| 57 | + |
| 58 | + - name: Build |
| 59 | + run: | |
| 60 | + bin=native/build/zstd-extract-darwin |
| 61 | + make -C native darwin |
| 62 | + cp "$bin" "$RUNNER_TEMP/first" |
| 63 | + make -C native clean darwin |
| 64 | + cmp "$RUNNER_TEMP/first" "$bin" # the build must be reproducible |
| 65 | + lipo -archs "$bin" | grep -q 'x86_64 arm64' |
| 66 | + codesign --verify "$bin" |
| 67 | + "$bin" --version |
| 68 | + "$bin" tests/Fixtures/level19.tar.zst "$RUNNER_TEMP/smoke" |
| 69 | + test -L "$RUNNER_TEMP/smoke/link-to-script" |
| 70 | +
|
| 71 | + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
| 72 | + with: |
| 73 | + name: darwin |
| 74 | + path: native/build/zstd-extract-darwin |
| 75 | + if-no-files-found: error |
| 76 | + |
| 77 | + windows: |
| 78 | + name: "Windows x86_64" |
| 79 | + runs-on: windows-latest |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 82 | + with: |
| 83 | + persist-credentials: false |
| 84 | + |
| 85 | + - name: Build |
| 86 | + shell: pwsh |
| 87 | + run: | |
| 88 | + $bin = 'native\build\zstd-extract-windows-x86_64.exe' |
| 89 | + cmd /c native\build-windows.cmd |
| 90 | + if ($LASTEXITCODE -ne 0) { exit 1 } |
| 91 | + Copy-Item $bin "$env:RUNNER_TEMP\first.exe" |
| 92 | + Remove-Item -Recurse native\build |
| 93 | + cmd /c native\build-windows.cmd |
| 94 | + if ($LASTEXITCODE -ne 0) { exit 1 } |
| 95 | + # the build must be reproducible |
| 96 | + if ((Get-FileHash $bin).Hash -ne (Get-FileHash "$env:RUNNER_TEMP\first.exe").Hash) { Write-Error 'non-deterministic build'; exit 1 } |
| 97 | + & $bin --version |
| 98 | + if ($LASTEXITCODE -ne 0) { exit 1 } |
| 99 | + & $bin tests\Fixtures\level19.tar.zst "$env:RUNNER_TEMP\smoke" |
| 100 | + if ($LASTEXITCODE -ne 0) { exit 1 } |
| 101 | + if (-not (Test-Path "$env:RUNNER_TEMP\smoke\link-to-script" -PathType Leaf)) { exit 1 } |
| 102 | +
|
| 103 | + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
| 104 | + with: |
| 105 | + name: windows-x86_64 |
| 106 | + path: native/build/zstd-extract-windows-x86_64.exe |
| 107 | + if-no-files-found: error |
| 108 | + |
| 109 | + collect: |
| 110 | + name: "Collect" |
| 111 | + needs: [linux, darwin, windows] |
| 112 | + runs-on: ubuntu-latest |
| 113 | + steps: |
| 114 | + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 |
| 115 | + with: |
| 116 | + path: bin |
| 117 | + pattern: '{linux-*,darwin,windows-*}' |
| 118 | + merge-multiple: true |
| 119 | + |
| 120 | + - name: Checksums |
| 121 | + run: | |
| 122 | + chmod +x bin/zstd-extract-* |
| 123 | + cd bin && LC_ALL=C sha256sum zstd-extract-* | tee SHA256SUMS |
| 124 | +
|
| 125 | + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
| 126 | + with: |
| 127 | + name: zstd-extract-binaries |
| 128 | + path: bin/ |
| 129 | + if-no-files-found: error |
0 commit comments