ci: add cabal.project.local extra-lib/include-dirs for homebrew keg-o… #11
Workflow file for this run
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: CLI Release | |
| on: | |
| push: | |
| tags: ['v*'] | |
| env: | |
| LANG: C.UTF-8 | |
| jobs: | |
| build-frontend: | |
| name: Build Frontend Assets | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Build CSS | |
| run: | | |
| mkdir -p static/public/assets/css | |
| npm ci | |
| npx tailwindcss -i ./static/public/assets/css/tailwind.css -o ./static/public/assets/css/tailwind.min.css --minify | |
| - name: Upload frontend artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: frontend-assets | |
| path: static/public/assets/css/tailwind.min.css | |
| retention-days: 1 | |
| build-linux-x64: | |
| name: Build Linux x86_64 | |
| needs: build-frontend | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| container: | |
| image: ghcr.io/monoscope-tech/monoscope-deps:latest | |
| credentials: | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GH_TOKEN }} | |
| env: | |
| CABAL_DIR: /root/.cabal | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download frontend artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: frontend-assets | |
| path: static/public/assets/css | |
| - name: Cache dist-newstyle | |
| uses: actions/cache@v4 | |
| with: | |
| path: dist-newstyle | |
| key: cli-linux-x64-${{ hashFiles('**/*.cabal', '**/cabal.project*') }}-${{ github.sha }} | |
| restore-keys: | | |
| cli-linux-x64-${{ hashFiles('**/*.cabal', '**/cabal.project*') }}- | |
| cli-linux-x64- | |
| - name: Build CLI binary | |
| run: cabal build exe:monoscope -j --ghc-options="-O2 +RTS -A64m -n2m -RTS" | |
| - name: Package binary | |
| run: | | |
| BIN=$(cabal list-bin exe:monoscope) | |
| strip "$BIN" | |
| cp "$BIN" monoscope | |
| tar czf monoscope-linux-x86_64.tar.gz monoscope | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: monoscope-linux-x86_64 | |
| path: monoscope-linux-x86_64.tar.gz | |
| retention-days: 5 | |
| build-linux-arm64: | |
| name: Build Linux ARM64 | |
| needs: build-frontend | |
| continue-on-error: true | |
| runs-on: blacksmith-4vcpu-ubuntu-2404-arm | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download frontend artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: frontend-assets | |
| path: static/public/assets/css | |
| - name: Install GHC and Cabal | |
| uses: haskell-actions/setup@v2 | |
| with: | |
| ghc-version: '9.12.2' | |
| cabal-version: '3.14' | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| libssl-dev librdkafka-dev libsnappy-dev libgrpc-dev \ | |
| libpq-dev libldap2-dev libsasl2-dev liblz4-dev libzstd-dev \ | |
| pkg-config protobuf-compiler | |
| - name: Cache Cabal | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cabal | |
| key: cli-linux-arm64-cabal-${{ hashFiles('**/*.cabal', '**/cabal.project*') }} | |
| restore-keys: cli-linux-arm64-cabal- | |
| - name: Cache dist-newstyle | |
| uses: actions/cache@v4 | |
| with: | |
| path: dist-newstyle | |
| key: cli-linux-arm64-dist-${{ hashFiles('**/*.cabal', '**/cabal.project*') }}-${{ github.sha }} | |
| restore-keys: | | |
| cli-linux-arm64-dist-${{ hashFiles('**/*.cabal', '**/cabal.project*') }}- | |
| cli-linux-arm64-dist- | |
| - name: Build CLI binary | |
| run: cabal build exe:monoscope -j --ghc-options="-O2 +RTS -A64m -n2m -RTS" | |
| - name: Package binary | |
| run: | | |
| BIN=$(cabal list-bin exe:monoscope) | |
| strip "$BIN" | |
| cp "$BIN" monoscope | |
| tar czf monoscope-linux-arm64.tar.gz monoscope | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: monoscope-linux-arm64 | |
| path: monoscope-linux-arm64.tar.gz | |
| retention-days: 5 | |
| build-macos-arm64: | |
| name: Build macOS ARM64 | |
| needs: build-frontend | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download frontend artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: frontend-assets | |
| path: static/public/assets/css | |
| - name: Install GHC and Cabal | |
| uses: haskell-actions/setup@v2 | |
| with: | |
| ghc-version: '9.12.2' | |
| cabal-version: '3.14' | |
| - name: Cache Cabal | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cabal | |
| key: cli-macos-arm64-cabal-${{ hashFiles('**/*.cabal', '**/cabal.project*') }} | |
| restore-keys: cli-macos-arm64-cabal- | |
| - name: Cache dist-newstyle | |
| uses: actions/cache@v4 | |
| with: | |
| path: dist-newstyle | |
| key: cli-macos-arm64-dist-${{ hashFiles('**/*.cabal', '**/cabal.project*') }}-${{ github.sha }} | |
| restore-keys: | | |
| cli-macos-arm64-dist-${{ hashFiles('**/*.cabal', '**/cabal.project*') }}- | |
| cli-macos-arm64-dist- | |
| - name: Install system deps | |
| run: | | |
| brew install pkg-config libpq librdkafka snappy lz4 zstd grpc openssl protobuf | |
| PREFIX=$(brew --prefix) | |
| echo "PKG_CONFIG_PATH=$PREFIX/opt/libpq/lib/pkgconfig:$PREFIX/opt/snappy/lib/pkgconfig:$PREFIX/opt/librdkafka/lib/pkgconfig:$PREFIX/opt/lz4/lib/pkgconfig:$PREFIX/opt/zstd/lib/pkgconfig:$PREFIX/opt/grpc/lib/pkgconfig:$PREFIX/opt/openssl/lib/pkgconfig" >> $GITHUB_ENV | |
| echo "$PREFIX/opt/libpq/bin" >> $GITHUB_PATH | |
| # Write extra lib/include dirs for Cabal's configure-based packages (snappy-c, etc.) | |
| cat >> cabal.project.local <<EOF | |
| extra-lib-dirs: $PREFIX/opt/snappy/lib $PREFIX/opt/libpq/lib $PREFIX/opt/librdkafka/lib $PREFIX/opt/lz4/lib $PREFIX/opt/zstd/lib $PREFIX/opt/openssl/lib $PREFIX/lib | |
| extra-include-dirs: $PREFIX/opt/snappy/include $PREFIX/opt/libpq/include $PREFIX/opt/librdkafka/include $PREFIX/opt/lz4/include $PREFIX/opt/zstd/include $PREFIX/opt/openssl/include $PREFIX/include | |
| EOF | |
| - name: Build CLI binary | |
| run: cabal build exe:monoscope -j --ghc-options="-O2 +RTS -A64m -n2m -RTS" | |
| - name: Package binary | |
| run: | | |
| BIN=$(cabal list-bin exe:monoscope) | |
| strip "$BIN" | |
| cp "$BIN" monoscope | |
| tar czf monoscope-darwin-arm64.tar.gz monoscope | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: monoscope-darwin-arm64 | |
| path: monoscope-darwin-arm64.tar.gz | |
| retention-days: 5 | |
| build-macos-x64: | |
| name: Build macOS x86_64 | |
| needs: build-frontend | |
| runs-on: macos-13 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download frontend artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: frontend-assets | |
| path: static/public/assets/css | |
| - name: Install GHC and Cabal | |
| uses: haskell-actions/setup@v2 | |
| with: | |
| ghc-version: '9.12.2' | |
| cabal-version: '3.14' | |
| - name: Cache Cabal | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cabal | |
| key: cli-macos-x64-cabal-${{ hashFiles('**/*.cabal', '**/cabal.project*') }} | |
| restore-keys: cli-macos-x64-cabal- | |
| - name: Cache dist-newstyle | |
| uses: actions/cache@v4 | |
| with: | |
| path: dist-newstyle | |
| key: cli-macos-x64-dist-${{ hashFiles('**/*.cabal', '**/cabal.project*') }}-${{ github.sha }} | |
| restore-keys: | | |
| cli-macos-x64-dist-${{ hashFiles('**/*.cabal', '**/cabal.project*') }}- | |
| cli-macos-x64-dist- | |
| - name: Install system deps | |
| run: | | |
| brew install pkg-config libpq librdkafka snappy lz4 zstd grpc openssl protobuf | |
| PREFIX=$(brew --prefix) | |
| echo "PKG_CONFIG_PATH=$PREFIX/opt/libpq/lib/pkgconfig:$PREFIX/opt/snappy/lib/pkgconfig:$PREFIX/opt/librdkafka/lib/pkgconfig:$PREFIX/opt/lz4/lib/pkgconfig:$PREFIX/opt/zstd/lib/pkgconfig:$PREFIX/opt/grpc/lib/pkgconfig:$PREFIX/opt/openssl/lib/pkgconfig" >> $GITHUB_ENV | |
| echo "$PREFIX/opt/libpq/bin" >> $GITHUB_PATH | |
| cat >> cabal.project.local <<EOF | |
| extra-lib-dirs: $PREFIX/opt/snappy/lib $PREFIX/opt/libpq/lib $PREFIX/opt/librdkafka/lib $PREFIX/opt/lz4/lib $PREFIX/opt/zstd/lib $PREFIX/opt/openssl/lib $PREFIX/lib | |
| extra-include-dirs: $PREFIX/opt/snappy/include $PREFIX/opt/libpq/include $PREFIX/opt/librdkafka/include $PREFIX/opt/lz4/include $PREFIX/opt/zstd/include $PREFIX/opt/openssl/include $PREFIX/include | |
| EOF | |
| - name: Build CLI binary | |
| run: cabal build exe:monoscope -j --ghc-options="-O2 +RTS -A64m -n2m -RTS" | |
| - name: Package binary | |
| run: | | |
| BIN=$(cabal list-bin exe:monoscope) | |
| strip "$BIN" | |
| cp "$BIN" monoscope | |
| tar czf monoscope-darwin-x86_64.tar.gz monoscope | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: monoscope-darwin-x86_64 | |
| path: monoscope-darwin-x86_64.tar.gz | |
| retention-days: 5 | |
| release: | |
| name: Create GitHub Release | |
| needs: [build-linux-x64, build-linux-arm64, build-macos-arm64, build-macos-x64] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Generate checksums | |
| run: | | |
| cd artifacts | |
| sha256sum *.tar.gz > checksums.txt | |
| cat checksums.txt | |
| - name: Create release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| cd artifacts | |
| ASSETS=$(ls *.tar.gz checksums.txt 2>/dev/null | tr '\n' ' ') | |
| if gh release view "$GITHUB_REF_NAME" &>/dev/null; then | |
| gh release upload "$GITHUB_REF_NAME" $ASSETS --clobber | |
| else | |
| gh release create "$GITHUB_REF_NAME" \ | |
| --title "Monoscope ${GITHUB_REF_NAME}" \ | |
| --generate-notes \ | |
| $ASSETS | |
| fi |