Build Liblogger #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Liblogger | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| actions: read | |
| contents: read | |
| jobs: | |
| build-liblogger-windows: | |
| runs-on: windows-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - artifact_arch: x64 | |
| vs_arch: x64 | |
| sign_with_signpath: true | |
| - artifact_arch: x86 | |
| vs_arch: Win32 | |
| sign_with_signpath: false | |
| - artifact_arch: arm64 | |
| vs_arch: ARM64 | |
| sign_with_signpath: false | |
| env: | |
| SIGNPATH_API_TOKEN: ${{ secrets.SIGNPATH_API_TOKEN }} | |
| SIGNPATH_ORGANIZATION_ID: '0126c615-e5f1-4fed-a438-6b8de149c8f4' | |
| SIGNPATH_PROJECT_SLUG: 'Toolscreen' | |
| SIGNPATH_SIGNING_POLICY_SLUG: 'release-signing' | |
| SIGNPATH_LIBLOGGER_ARTIFACT_CONFIGURATION_SLUG: 'liblogger-dll' | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Resolve liblogger SignPath version | |
| id: signpath_version | |
| if: ${{ matrix.sign_with_signpath }} | |
| shell: pwsh | |
| run: | | |
| $versionFile = Join-Path $env:GITHUB_WORKSPACE 'liblogger/LibLoggerVersion.cmake' | |
| $versionContent = Get-Content $versionFile -Raw | |
| $majorMatch = [regex]::Match($versionContent, 'set\(LIBLOGGER_VERSION_MAJOR\s+(\d+)\)') | |
| $minorMatch = [regex]::Match($versionContent, 'set\(LIBLOGGER_VERSION_MINOR\s+(\d+)\)') | |
| $patchMatch = [regex]::Match($versionContent, 'set\(LIBLOGGER_VERSION_PATCH\s+(\d+)\)') | |
| if (-not $majorMatch.Success -or -not $minorMatch.Success -or -not $patchMatch.Success) { | |
| throw "Failed to parse version from $versionFile" | |
| } | |
| $version = '{0}.{1}.{2}' -f $majorMatch.Groups[1].Value, $minorMatch.Groups[1].Value, $patchMatch.Groups[1].Value | |
| "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
| - name: Set up Java 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '17' | |
| - name: Configure liblogger build preset | |
| shell: pwsh | |
| run: | | |
| cmake -S . -B "out/build-liblogger/windows-${{ matrix.artifact_arch }}" -G "Visual Studio 17 2022" -A "${{ matrix.vs_arch }}" -DTOOLSCREEN_ENABLE_JAR_PACKAGING=OFF -DTOOLSCREEN_BUILD_LIBLOGGER_FROM_SOURCE=ON | |
| - name: Build liblogger DLL | |
| shell: cmd | |
| run: cmake --build out\build-liblogger\windows-${{ matrix.artifact_arch }} --config Release --target liblogger_windows | |
| - name: Upload liblogger DLL for SignPath | |
| id: signpath_liblogger_upload | |
| if: ${{ matrix.sign_with_signpath }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: liblogger-signpath-dll-input | |
| if-no-files-found: error | |
| retention-days: 1 | |
| path: out/build-liblogger/windows-${{ matrix.artifact_arch }}/bin/Release/liblogger_${{ matrix.artifact_arch }}.dll | |
| - name: Submit liblogger DLL to SignPath with origin verification | |
| if: ${{ matrix.sign_with_signpath }} | |
| uses: signpath/github-action-submit-signing-request@v2 | |
| with: | |
| api-token: ${{ env.SIGNPATH_API_TOKEN }} | |
| organization-id: ${{ env.SIGNPATH_ORGANIZATION_ID }} | |
| project-slug: ${{ env.SIGNPATH_PROJECT_SLUG }} | |
| signing-policy-slug: ${{ env.SIGNPATH_SIGNING_POLICY_SLUG }} | |
| artifact-configuration-slug: ${{ env.SIGNPATH_LIBLOGGER_ARTIFACT_CONFIGURATION_SLUG }} | |
| github-artifact-id: ${{ steps.signpath_liblogger_upload.outputs.artifact-id }} | |
| wait-for-completion: true | |
| output-artifact-directory: out/signpath-liblogger-dll-output | |
| parameters: | | |
| version: ${{ toJSON(steps.signpath_version.outputs.version) }} | |
| - name: Replace liblogger DLL with signed output | |
| if: ${{ matrix.sign_with_signpath }} | |
| shell: pwsh | |
| run: | | |
| $artifactDllPath = 'out/build-liblogger/windows-${{ matrix.artifact_arch }}/bin/Release/liblogger_${{ matrix.artifact_arch }}.dll' | |
| $signedDllPath = 'out/signpath-liblogger-dll-output/liblogger_x64.dll' | |
| if (-not (Test-Path $artifactDllPath)) { | |
| throw "Expected liblogger DLL not found: $artifactDllPath" | |
| } | |
| if (-not (Test-Path $signedDllPath)) { | |
| throw "Expected signed liblogger DLL not found: $signedDllPath" | |
| } | |
| Copy-Item -Path $signedDllPath -Destination $artifactDllPath -Force | |
| - name: Upload signed Windows liblogger artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: liblogger-windows-${{ matrix.artifact_arch }} | |
| if-no-files-found: error | |
| retention-days: 14 | |
| path: | | |
| out/build-liblogger/windows-${{ matrix.artifact_arch }}/bin/Release/liblogger_${{ matrix.artifact_arch }}.dll | |
| out/build-liblogger/windows-${{ matrix.artifact_arch }}/bin/Release/liblogger_${{ matrix.artifact_arch }}.pdb | |
| build-liblogger-linux: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: | |
| - x64 | |
| - x86 | |
| - arm64 | |
| - arm32 | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Java 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '17' | |
| - name: Install Linux liblogger dependencies | |
| shell: bash | |
| run: | | |
| write_primary_sources() { | |
| local architectures="$1" | |
| printf '%s\n' \ | |
| 'Types: deb' \ | |
| 'URIs: http://azure.archive.ubuntu.com/ubuntu/' \ | |
| 'Suites: noble noble-updates noble-backports' \ | |
| 'Components: main restricted universe multiverse' \ | |
| "Architectures: ${architectures}" \ | |
| 'Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg' \ | |
| '' \ | |
| 'Types: deb' \ | |
| 'URIs: http://security.ubuntu.com/ubuntu/' \ | |
| 'Suites: noble-security' \ | |
| 'Components: main restricted universe multiverse' \ | |
| "Architectures: ${architectures}" \ | |
| 'Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg' \ | |
| | sudo tee /etc/apt/sources.list.d/ubuntu.sources >/dev/null | |
| } | |
| write_ports_sources() { | |
| local architecture="$1" | |
| printf '%s\n' \ | |
| 'Types: deb' \ | |
| 'URIs: http://ports.ubuntu.com/ubuntu-ports/' \ | |
| 'Suites: noble noble-updates noble-backports noble-security' \ | |
| 'Components: main restricted universe multiverse' \ | |
| "Architectures: ${architecture}" \ | |
| 'Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg' \ | |
| | sudo tee /etc/apt/sources.list.d/ubuntu-ports.sources >/dev/null | |
| } | |
| case "${{ matrix.target }}" in | |
| x64) | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| pkg-config \ | |
| clang \ | |
| binutils \ | |
| libssl-dev | |
| ;; | |
| x86) | |
| write_primary_sources 'amd64 i386' | |
| sudo dpkg --add-architecture i386 | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| pkg-config \ | |
| clang \ | |
| binutils \ | |
| gcc-multilib \ | |
| g++-multilib \ | |
| libc6-dev-i386 \ | |
| libssl-dev \ | |
| libssl-dev:i386 | |
| ;; | |
| arm64) | |
| write_primary_sources 'amd64' | |
| write_ports_sources 'arm64' | |
| sudo dpkg --add-architecture arm64 | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| pkg-config \ | |
| clang \ | |
| binutils \ | |
| binutils-aarch64-linux-gnu \ | |
| gcc-aarch64-linux-gnu \ | |
| g++-aarch64-linux-gnu \ | |
| libc6-dev-arm64-cross \ | |
| libssl-dev \ | |
| libssl-dev:arm64 | |
| ;; | |
| arm32) | |
| write_primary_sources 'amd64' | |
| write_ports_sources 'armhf' | |
| sudo dpkg --add-architecture armhf | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| pkg-config \ | |
| clang \ | |
| binutils \ | |
| binutils-arm-linux-gnueabihf \ | |
| gcc-arm-linux-gnueabihf \ | |
| g++-arm-linux-gnueabihf \ | |
| libc6-dev-armhf-cross \ | |
| libssl-dev \ | |
| libssl-dev:armhf | |
| ;; | |
| *) | |
| echo "Unsupported Linux liblogger target: ${{ matrix.target }}" >&2 | |
| exit 1 | |
| ;; | |
| esac | |
| - name: Build Linux liblogger binaries | |
| shell: bash | |
| run: LINUX_TARGETS="${{ matrix.target }}" bash ./liblogger/build.sh | |
| - name: Upload Linux liblogger artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: liblogger-linux-${{ matrix.target }} | |
| if-no-files-found: error | |
| retention-days: 14 | |
| path: liblogger/dist/linux/liblogger_${{ matrix.target }}.so | |
| build-liblogger-macos: | |
| runs-on: macos-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Java 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '17' | |
| - name: Build macOS liblogger binary | |
| shell: bash | |
| run: bash ./liblogger/build-macos.sh | |
| - name: Upload macOS liblogger artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: liblogger-macos | |
| if-no-files-found: error | |
| retention-days: 14 | |
| path: liblogger/dist/macos/*.dylib | |
| package-liblogger-binaries: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-liblogger-windows | |
| - build-liblogger-linux | |
| - build-liblogger-macos | |
| steps: | |
| - name: Download signed Windows liblogger artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: liblogger-windows-x64 | |
| path: collected/windows | |
| - name: Download x86 Windows liblogger artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: liblogger-windows-x86 | |
| path: collected/windows | |
| - name: Download ARM64 Windows liblogger artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: liblogger-windows-arm64 | |
| path: collected/windows | |
| - name: Download Linux liblogger artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: liblogger-linux-x64 | |
| path: collected/linux | |
| - name: Download x86 Linux liblogger artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: liblogger-linux-x86 | |
| path: collected/linux | |
| - name: Download ARM64 Linux liblogger artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: liblogger-linux-arm64 | |
| path: collected/linux | |
| - name: Download ARM32 Linux liblogger artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: liblogger-linux-arm32 | |
| path: collected/linux | |
| - name: Download macOS liblogger artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: liblogger-macos | |
| path: collected/macos | |
| - name: Assemble combined liblogger bundle | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| mkdir -p release/windows release/linux release/macos release/bundle | |
| find collected/windows -maxdepth 1 -type f \( -name '*.dll' -o -name '*.pdb' \) -exec cp {} release/windows/ \; | |
| find collected/linux -maxdepth 1 -type f -name '*.so' -exec cp {} release/linux/ \; | |
| find collected/macos -maxdepth 1 -type f -name '*.dylib' -exec cp {} release/macos/ \; | |
| ( | |
| cd release | |
| zip -r bundle/liblogger-all-platforms.zip windows linux macos | |
| ) | |
| - name: Log liblogger artifact SHA-512 hashes | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| manifest='release/SHA512SUMS.txt' | |
| : > "$manifest" | |
| while IFS= read -r -d '' file; do | |
| rel_path="${file#release/}" | |
| hash="$(sha512sum "$file" | cut -d' ' -f1)" | |
| printf 'SHA512 %s %s\n' "$hash" "$rel_path" | |
| printf '%s %s\n' "$hash" "$rel_path" >> "$manifest" | |
| done < <(find release -type f ! -name 'SHA512SUMS.txt' -print0 | sort -z) | |
| - name: Upload combined liblogger zip artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: liblogger-all-platforms | |
| if-no-files-found: error | |
| retention-days: 14 | |
| path: release/bundle/liblogger-all-platforms.zip | |
| - name: Upload collected liblogger artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: liblogger-release-artifacts | |
| if-no-files-found: error | |
| retention-days: 14 | |
| path: | | |
| release/windows/*.dll | |
| release/windows/*.pdb | |
| release/linux/*.so | |
| release/macos/*.dylib | |
| release/bundle/liblogger-all-platforms.zip | |
| release/SHA512SUMS.txt |