| # Copyright 2023 Google Inc. All Rights Reserved. | |
| # | |
| # Distributed under MIT license. | |
| # See file LICENSE for detail or copy at https://opensource.org/licenses/MIT | |
| # Workflow for building the release binaries. | |
| name: Release build / deploy | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - v*.*.* | |
| release: | |
| types: [ published ] | |
| pull_request: | |
| types: [opened, reopened, labeled, unlabeled, synchronize] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| windows_build: | |
| name: Windows Build (vcpkg / ${{ matrix.triplet }}) | |
| runs-on: ${{ matrix.runs_on }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - triplet: x86-windows-dynamic | |
| arch: '-A Win32' | |
| build_shared_libs: 'ON' | |
| runs_on: windows-latest | |
| - triplet: x64-windows-dynamic | |
| arch: '-A x64' | |
| build_shared_libs: 'ON' | |
| runs_on: windows-latest | |
| - triplet: arm64-windows-dynamic | |
| arch: '-A ARM64' | |
| build_shared_libs: 'ON' | |
| runs_on: windows-11-arm | |
| - triplet: x86-windows-static | |
| arch: '-A Win32' | |
| build_shared_libs: 'OFF' | |
| runs_on: windows-latest | |
| - triplet: x64-windows-static | |
| arch: '-A x64' | |
| build_shared_libs: 'OFF' | |
| runs_on: windows-latest | |
| - triplet: arm64-windows-static | |
| arch: '-A ARM64' | |
| build_shared_libs: 'OFF' | |
| runs_on: windows-11-arm | |
| env: | |
| ARCH: ${{ matrix.arch }} | |
| BUILD_SHARED_LIBS: ${{ matrix.build_shared_libs }} | |
| TRIPLET: ${{ matrix.triplet }} | |
| VCPKG_VERSION: '2022.11.14' | |
| VCPKG_ROOT: vcpkg | |
| VCPKG_DISABLE_METRICS: 1 | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@dc2769abcc0fcfbadfc1df54081c1608579ef6b2 # v2.22.2 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout the source | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| submodules: false | |
| fetch-depth: 1 | |
| persist-credentials: false | |
| - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| if: github.event_name != 'release' | |
| id: cache-vcpkg | |
| with: | |
| path: vcpkg | |
| key: release-${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ env.TRIPLET }} | |
| # TODO(eustas): remove when https://github.com/zizmorcore/zizmor/issues/2071 is fixed | |
| lookup-only: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| - name: Download vcpkg | |
| if: github.event_name == 'release' || steps.cache-vcpkg.outputs.cache-hit != 'true' | |
| shell: 'powershell' | |
| run: | | |
| Invoke-WebRequest -Uri "https://github.com/microsoft/vcpkg/archive/refs/tags/${env:VCPKG_VERSION}.zip" -OutFile "vcpkg.zip" | |
| - name: Bootstrap vcpkg | |
| if: github.event_name == 'release' || steps.cache-vcpkg.outputs.cache-hit != 'true' | |
| shell: 'bash' | |
| run: | | |
| set -x | |
| unzip -q vcpkg.zip | |
| rm -rf ${VCPKG_ROOT} | |
| mv vcpkg-${VCPKG_VERSION} ${VCPKG_ROOT} | |
| ${VCPKG_ROOT}/bootstrap-vcpkg.sh | |
| - name: Configure | |
| shell: 'bash' | |
| run: | | |
| set -x | |
| mkdir out | |
| cmake -Bout -H. ${ARCH} \ | |
| -DBUILD_TESTING=OFF \ | |
| -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_INSTALL_PREFIX=`pwd`/prefix \ | |
| -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake \ | |
| -DVCPKG_TARGET_TRIPLET=${TRIPLET} \ | |
| # | |
| - name: Build | |
| shell: 'bash' | |
| run: | | |
| set -x | |
| cmake --build out --config Release | |
| - name: Install | |
| shell: 'bash' | |
| run: | | |
| set -x | |
| cmake --build out --config Release --target install | |
| cp LICENSE prefix/bin/LICENSE.brotli | |
| - name: Package release zip | |
| shell: 'powershell' | |
| run: | | |
| Compress-Archive -Path prefix\bin\* ` | |
| -DestinationPath brotli-${env:TRIPLET}.zip | |
| - name: Upload package | |
| uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 | |
| with: | |
| name: brotli-${{matrix.triplet}} | |
| path: brotli-${{matrix.triplet}}.zip | |
| compression-level: 0 | |
| testdata_upload: | |
| name: Upload testdata | |
| runs-on: 'ubuntu-latest' | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@dc2769abcc0fcfbadfc1df54081c1608579ef6b2 # v2.22.2 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout the source | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| submodules: false | |
| fetch-depth: 1 | |
| persist-credentials: false | |
| - name: Compress testdata | |
| run: | | |
| tar cvfJ testdata.txz tests/testdata | |
| - name: Upload archive | |
| uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 | |
| with: | |
| name: testdata | |
| path: testdata.txz | |
| compression-level: 0 | |
| publish_release_assets: | |
| name: Publish release assets | |
| needs: [windows_build, testdata_upload] | |
| if: github.event_name == 'release' | |
| runs-on: [ubuntu-latest] | |
| permissions: | |
| contents: write # upload assets | |
| steps: | |
| - name: Checkout the source | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| submodules: false | |
| fetch-depth: 1 | |
| persist-credentials: false | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 | |
| with: | |
| path: release_assets | |
| merge-multiple: true | |
| - name: Publish assets | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_EVENT_RELEASE_TAG_NAME: ${{ github.event.release.tag_name }} | |
| run: | | |
| gh release upload ${GITHUB_EVENT_RELEASE_TAG_NAME} ./release_assets/* | |
| archive_build: | |
| needs: publish_release_assets | |
| name: Build and test from archive | |
| runs-on: 'ubuntu-latest' | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@dc2769abcc0fcfbadfc1df54081c1608579ef6b2 # v2.22.2 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout the source | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| submodules: false | |
| fetch-depth: 1 | |
| persist-credentials: false | |
| - name: Archive | |
| run: | | |
| git archive HEAD -o archive.tgz | |
| - name: Pick tag | |
| run: | | |
| echo "BROTLI_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV | |
| - name: Extract | |
| run: | | |
| mkdir archive | |
| cd archive | |
| tar xvzf ../archive.tgz | |
| - name: Download testdata | |
| run: | | |
| cd archive | |
| scripts/download_testdata.sh | |
| - name: Configure and Build | |
| run: | | |
| cd archive | |
| cmake -B out . | |
| cmake --build out | |
| - name: Test | |
| run: | | |
| cd archive | |
| cd out | |
| ctest |