aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/release.yaml
blob: 89acdf34e8b19311d8974bc6a55c448afe025a77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# 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 ]

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: [windows-2022]
    strategy:
      fail-fast: false
      matrix:
        include:
          - triplet: x86-windows-dynamic
            arch: '-A Win32'
            build_shared_libs: 'ON'
          - triplet: x64-windows-dynamic
            arch: '-A x64'
            build_shared_libs: 'ON'
          - triplet: x86-windows-static
            arch: '-A Win32'
            build_shared_libs: 'OFF'
          - triplet: x64-windows-static
            arch: '-A x64'
            build_shared_libs: 'OFF'

    env:
      VCPKG_VERSION: '2022.11.14'
      VCPKG_ROOT: vcpkg
      VCPKG_DISABLE_METRICS: 1

    steps:
    - name: Checkout the source
      uses: actions/checkout@v4
      with:
        submodules: false
        fetch-depth: 1

    - uses: actions/cache@v3
      id: cache-vcpkg
      with:
        path: vcpkg
        key: release-${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.triplet }}

    - name: Download vcpkg
      if: steps.cache-vcpkg.outputs.cache-hit != 'true'
      # wget doesn't seem to work under bash.
      shell: 'powershell'
      run: |
        C:\msys64\usr\bin\wget.exe -nv `
           https://github.com/microsoft/vcpkg/archive/refs/tags/${{ env.VCPKG_VERSION }}.zip `
          -O vcpkg.zip
    - name: Bootstrap vcpkg
      if: 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. ${{ matrix.arch }} \
          -DBUILD_TESTING=OFF \
          -DBUILD_SHARED_LIBS=${{ matrix.build_shared_libs }} \
          -DCMAKE_BUILD_TYPE=Release \
          -DCMAKE_INSTALL_PREFIX=`pwd`/prefix \
          -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake \
          -DVCPKG_TARGET_TRIPLET=${{ matrix.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: Upload artifacts
      uses: actions/upload-artifact@v3
      with:
        name: brotli-${{matrix.triplet}}
        path: |
          prefix/bin/*

    - name: Package release zip
      if: github.event_name == 'release'
      shell: 'powershell'
      run: |
        Compress-Archive -Path prefix\bin\* `
          -DestinationPath brotli-${{matrix.triplet}}.zip

    - name: Upload binaries to release
      if: github.event_name == 'release'
      uses: AButler/upload-release-assets@v2.0
      with:
        files: brotli-${{matrix.triplet}}.zip
        repo-token: ${{ secrets.GITHUB_TOKEN }}