Build and Upload DB Binaries to R2 #30
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 and Upload DB Binaries to R2 | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 60 | |
| strategy: | |
| max-parallel: 3 | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - database: mongodb | |
| os: macos-latest | |
| platform: macos | |
| arch: arm64 | |
| - database: mongodb | |
| os: macos-latest | |
| platform: macos | |
| arch: x86_64 | |
| - database: mongodb | |
| os: ubuntu-latest | |
| platform: linux | |
| arch: x86_64 | |
| - database: postgresql | |
| os: macos-latest | |
| platform: macos | |
| arch: arm64 | |
| - database: postgresql | |
| os: macos-latest | |
| platform: macos | |
| arch: x86_64 | |
| - database: postgresql | |
| os: ubuntu-latest | |
| platform: linux | |
| arch: x86_64 | |
| - database: redis | |
| os: macos-latest | |
| platform: macos | |
| arch: arm64 | |
| - database: redis | |
| os: macos-latest | |
| platform: macos | |
| arch: x86_64 | |
| - database: redis | |
| os: ubuntu-latest | |
| platform: linux | |
| arch: x86_64 | |
| env: | |
| R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} | |
| R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
| R2_BUCKET: ${{ secrets.R2_BUCKET }} | |
| R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set environment variables | |
| shell: bash | |
| run: | | |
| echo "DB_MAJOR_VERSION=source" >> $GITHUB_ENV | |
| echo "ARCH_CLEAN=$(echo '${{ matrix.arch }}' | sed 's/^_//')" >> $GITHUB_ENV | |
| - name: Install Python 3.11 for MongoDB build | |
| if: matrix.database == 'mongodb' | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: 3.11 | |
| - name: Install build dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt update | |
| sudo apt install -y build-essential libssl-dev libreadline-dev zlib1g-dev curl git pkg-config python3 python3-pip | |
| - name: Install build dependencies (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install openssl readline zlib cmake pkg-config python git curl | |
| - name: Build and copy binaries | |
| shell: bash | |
| run: | | |
| mkdir -p ./raw/${{ matrix.database }}/source/${{ matrix.platform }}/${{ matrix.arch }} | |
| cd /tmp | |
| case "${{ matrix.database }}" in | |
| mongodb) | |
| git clone --branch r7.0.11 https://github.com/mongodb/mongo.git | |
| cd mongo | |
| python3 -m venv venv | |
| source venv/bin/activate | |
| pip install -r buildscripts/requirements.txt | |
| python3 buildscripts/scons.py install-mongod --prefix=/tmp/mongodb_install | |
| cp /tmp/mongodb_install/bin/mongod $GITHUB_WORKSPACE/raw/${{ matrix.database }}/source/${{ matrix.platform }}/${{ matrix.arch }}/ | |
| curl -LO https://downloads.mongodb.com/compass/mongosh-2.5.6-${{ matrix.platform == 'macos' && (matrix.arch == 'arm64' && 'darwin-arm64' || 'darwin-x64') || 'linux-x64' }}.zip | |
| unzip mongosh-2.5.6-*.zip -d mongosh | |
| cp mongosh/bin/mongosh $GITHUB_WORKSPACE/raw/${{ matrix.database }}/source/${{ matrix.platform }}/${{ matrix.arch }}/ | |
| ;; | |
| postgresql) | |
| curl -LO https://ftp.postgresql.org/pub/source/v17.0/postgresql-17.0.tar.gz | |
| tar -xzf postgresql-17.0.tar.gz | |
| cd postgresql-17.0 | |
| ./configure --prefix=/tmp/pgsql | |
| make -j$(nproc) | |
| make install | |
| cp /tmp/pgsql/bin/* $GITHUB_WORKSPACE/raw/${{ matrix.database }}/source/${{ matrix.platform }}/${{ matrix.arch }}/ | |
| ;; | |
| redis) | |
| curl -LO http://download.redis.io/releases/redis-7.2.4.tar.gz | |
| tar -xzf redis-7.2.4.tar.gz | |
| cd redis-7.2.4 | |
| make -j$(nproc) | |
| cp src/redis-server $GITHUB_WORKSPACE/raw/${{ matrix.database }}/source/${{ matrix.platform }}/${{ matrix.arch }}/ | |
| ;; | |
| esac | |
| - name: Archive binaries | |
| shell: bash | |
| run: | | |
| mkdir -p ./packages/${{ matrix.database }}/source/${{ matrix.platform }} | |
| tar -czf ./packages/${{ matrix.database }}/source/${{ matrix.platform }}/${{ matrix.arch }}.tar.gz -C ./raw/${{ matrix.database }}/source/${{ matrix.platform }}/${{ matrix.arch }} . | |
| - name: Upload to R2 | |
| shell: bash | |
| run: | | |
| pip install awscli --break-system-packages | |
| export AWS_ACCESS_KEY_ID="$R2_ACCESS_KEY_ID" | |
| export AWS_SECRET_ACCESS_KEY="$R2_SECRET_ACCESS_KEY" | |
| export AWS_DEFAULT_REGION="auto" | |
| aws s3 cp \ | |
| ./packages/${{ matrix.database }}/source/${{ matrix.platform }}/ \ | |
| s3://$R2_BUCKET/${{ matrix.database }}/source/${{ matrix.platform }}/ \ | |
| --recursive \ | |
| --endpoint-url "$R2_ENDPOINT" |