|
| 1 | +name: Build/release Zeek |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + tags: |
| 9 | + - v*brim* |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + release: |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + platform: [macos-12, ubuntu-20.04, windows-2019] |
| 20 | + runs-on: ${{ matrix.platform }} |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout build-zeek |
| 24 | + uses: actions/checkout@v3 |
| 25 | + |
| 26 | + - name: Setup Go |
| 27 | + uses: actions/setup-go@v3 |
| 28 | + with: |
| 29 | + go-version: 1.21 |
| 30 | + |
| 31 | + - name: Checkout zeek |
| 32 | + uses: actions/checkout@v3 |
| 33 | + with: |
| 34 | + repository: zeek/zeek |
| 35 | + ref: v6.0.2 |
| 36 | + fetch-depth: 1 |
| 37 | + submodules: recursive |
| 38 | + path: zeek-src |
| 39 | + |
| 40 | + - name: Build zeekrunner (Windows) |
| 41 | + if: startsWith(matrix.platform, 'windows-') |
| 42 | + run: go build -o zeekrunner.exe zeekrunner.go |
| 43 | + |
| 44 | + # Includes workaround from https://github.com/maxmind/libmaxminddb/pull/334 |
| 45 | + - name: Build libmaxminddb (Windows) |
| 46 | + if: startsWith(matrix.platform, 'windows-') |
| 47 | + run: | |
| 48 | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 |
| 49 | + curl -L https://github.com/maxmind/libmaxminddb/releases/download/1.8.0/libmaxminddb-1.8.0.tar.gz | tar xzvf - |
| 50 | + mkdir libmaxminddb-1.8.0\build |
| 51 | + cd libmaxminddb-1.8.0\build |
| 52 | + cmake .. |
| 53 | + cmake --build . |
| 54 | + cmake --build . --target install |
| 55 | + rename "C:\Program Files (x86)\maxminddb\include\maxminddb.h" maxminddb.h.bak |
| 56 | + sed "/typedef ADDRESS_FAMILY sa_family_t/d" "C:\Program Files (x86)\maxminddb\include\maxminddb.h.bak" > "C:\Program Files (x86)\maxminddb\include\maxminddb.h" |
| 57 | + shell: cmd |
| 58 | + |
| 59 | + - name: Build Zeek (Windows) |
| 60 | + if: startsWith(matrix.platform, 'windows-') |
| 61 | + run: | |
| 62 | + choco install -y --no-progress conan --version=1.58.0 |
| 63 | + choco install -y --no-progress winflexbison3 |
| 64 | + call refreshenv |
| 65 | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 |
| 66 | + mkdir zeek-src\build |
| 67 | + cd zeek-src\build |
| 68 | + cmake.exe .. -DCMAKE_BUILD_TYPE=release -DENABLE_ZEEK_UNIT_TESTS=yes -D CMAKE_INSTALL_PREFIX="C:\Program Files\Git\usr\local\zeek" -DLibMMDB_INCLUDE_DIR="C:\Program Files (x86)\maxminddb\include" -DLibMMDB_LIBRARY="C:\Program Files (x86)\maxminddb\lib\maxminddb.lib" -G Ninja |
| 69 | + cmake.exe --build . |
| 70 | + cmake.exe --install . |
| 71 | + cd |
| 72 | + shell: cmd |
| 73 | + |
| 74 | + - name: Install dependencies (Linux) |
| 75 | + if: startsWith(matrix.platform, 'ubuntu-') |
| 76 | + run: sudo apt-get -y install cmake make gcc g++ flex libfl-dev bison libpcap-dev libssl-dev python3 python3-dev python3-setuptools swig zlib1g-dev zip libmaxminddb-dev |
| 77 | + |
| 78 | + - name: Install dependencies (macOS) |
| 79 | + if: startsWith(matrix.platform, 'macos-') |
| 80 | + run: brew install cmake swig openssl bison flex libmaxminddb |
| 81 | + |
| 82 | + - name: Get number of CPU cores |
| 83 | + uses: SimenB/github-actions-cpu-cores@v1 |
| 84 | + id: cpu-cores |
| 85 | + |
| 86 | + - name: Build Zeek (Linux/macOS) |
| 87 | + if: "!startsWith(matrix.platform, 'windows-')" |
| 88 | + run: | |
| 89 | + cd zeek-src |
| 90 | + ./configure --binary-package --enable-static-broker --enable-static-binpac --disable-spicy --disable-af-packet --disable-zeekctl --disable-python --disable-broker-tests --disable-auxtools --disable-archiver --osx-min-version=12 |
| 91 | + make -j${{ steps.cpu-cores.outputs.count }} |
| 92 | + sudo make install |
| 93 | + sudo strip /usr/local/zeek/bin/zeek |
| 94 | +
|
| 95 | + - name: Finish packaging artifact |
| 96 | + run: ./release.sh |
| 97 | + shell: sh |
| 98 | + |
| 99 | + - name: Upload artifact |
| 100 | + uses: actions/upload-artifact@v4 |
| 101 | + with: |
| 102 | + name: ${{ matrix.platform }} |
| 103 | + path: zeek-*.zip |
| 104 | + |
| 105 | + - name: Publish artifact as release |
| 106 | + if: startsWith(github.event.ref, 'refs/tags/') |
| 107 | + |
| 108 | + with: |
| 109 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 110 | + file: zeek-*.zip |
| 111 | + file_glob: true |
| 112 | + tag: ${{ github.ref }} |
| 113 | + overwrite: true |
0 commit comments