Skip to content

wip debugging windows support #14

wip debugging windows support

wip debugging windows support #14

name: Build and Upload DB Binaries to R2

Check failure on line 1 in .github/workflows/upload-binaries.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/upload-binaries.yml

Invalid workflow file

(Line: 117, Col: 14): Unexpected symbol: '('. Located at position 24 within expression: matrix.db_version.split('.')[0]
on:
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
max-parallel: 3
fail-fast: false
matrix:
include:
# MongoDB
- database: mongodb
db_version: 8.0.0
os: macos-latest
platform: macos
arch: arm64
ext: tar.gz
- database: mongodb
db_version: 8.0.0
os: macos-latest
platform: macos
arch: _x86_64
ext: tar.gz
- database: mongodb
db_version: 8.0.0
os: ubuntu-latest
platform: linux
arch: _x86_64
ext: tar.gz
- database: mongodb
db_version: 8.0.0
os: windows-latest
platform: windows
arch: _x86_64
ext: zip
# PostgreSQL (use 16 instead of 17)
- database: postgresql
db_version: 16.0
os: macos-latest
platform: macos
arch: arm64
ext: tar.gz
- database: postgresql
db_version: 16.0
os: macos-latest
platform: macos
arch: _x86_64
ext: tar.gz
- database: postgresql
db_version: 16.0
os: ubuntu-latest
platform: linux
arch: _x86_64
ext: tar.gz
- database: postgresql
db_version: 16.0
os: windows-latest
platform: windows
arch: _x86_64
ext: zip
# Redis
- database: redis
db_version: 7.0.15
os: macos-latest
platform: macos
arch: arm64
ext: tar.gz
- database: redis
db_version: 7.0.15
os: macos-latest
platform: macos
arch: _x86_64
ext: tar.gz
- database: redis
db_version: 7.0.15
os: ubuntu-latest
platform: linux
arch: _x86_64
ext: tar.gz
- database: redis
db_version: 7.0.15
os: windows-latest
platform: windows
arch: _x86_64
ext: zip
environment: production
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 (Linux/macOS)
if: runner.os != 'Windows'
shell: bash
run: |
echo "DATABASE=${{ matrix.database }}" >> $GITHUB_ENV
echo "DB_VERSION=${{ matrix.db_version }}" >> $GITHUB_ENV
echo "DB_MAJOR_VERSION=$(echo '${{ matrix.db_version }}' | cut -d. -f1)" >> $GITHUB_ENV
echo "ARCH_CLEAN=$(echo '${{ matrix.arch }}' | sed 's/^_//')" >> $GITHUB_ENV
- name: Set environment variables (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
echo "DATABASE=${{ matrix.database }}" >> $GITHUB_ENV
echo "DB_VERSION=${{ matrix.db_version }}" >> $GITHUB_ENV
echo "DB_MAJOR_VERSION=${{ matrix.db_version.split('.')[0] }}" >> $GITHUB_ENV
echo "ARCH_CLEAN=${{ matrix.arch.startsWith('_') && matrix.arch.substring(1) || matrix.arch }}" >> $GITHUB_ENV
- name: Set up architecture switching (x86_64 on macOS)
if: matrix.arch == '_x86_64' && matrix.platform == 'macos'
run: echo "alias brew='arch -x86_64 /usr/local/bin/brew'" >> $GITHUB_ENV
- name: Install dependencies and fetch binaries
shell: bash
run: |
mkdir -p ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}
case "$DATABASE" in
redis)
if [[ "$RUNNER_OS" == "Windows" ]]; then
curl -L -o memurai.zip https://github.com/tporadowski/redis/releases/download/v7.0.15/Redis-x64-7.0.15.1.zip
unzip memurai.zip -d ./temp
cp ./temp/*.exe ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/
elif [[ "$RUNNER_OS" == "macOS" ]]; then
brew install redis
cp $(brew --prefix redis)/bin/redis-server ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/
else
sudo apt update && sudo apt install redis-server -y
cp $(which redis-server) ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/
fi
;;
mongodb)
if [[ "$RUNNER_OS" == "Windows" ]]; then
curl -LO https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-${DB_VERSION}.zip
unzip mongodb-windows-x86_64-${DB_VERSION}.zip -d ./temp
cp ./temp/mongodb-*/bin/* ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/
elif [[ "$RUNNER_OS" == "macOS" ]]; then
curl -LO https://fastdl.mongodb.org/osx/mongodb-macos-${ARCH_CLEAN}-${DB_VERSION}.tgz
tar -xzf mongodb-macos-${ARCH_CLEAN}-${DB_VERSION}.tgz
cp ./mongodb-*/bin/* ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/
else
curl -LO https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-${DB_VERSION}.tgz
tar -xzf mongodb-linux-x86_64-ubuntu2204-${DB_VERSION}.tgz
cp ./mongodb-*/bin/* ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/
fi
;;
postgresql)
if [[ "$RUNNER_OS" == "Windows" ]]; then
choco install postgresql --version=${DB_VERSION} -y
cp "C:/Program Files/PostgreSQL/${DB_MAJOR_VERSION}/bin/*" ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/
elif [[ "$RUNNER_OS" == "macOS" ]]; then
brew install postgresql@${DB_MAJOR_VERSION}
cp $(brew --prefix postgresql@${DB_MAJOR_VERSION})/bin/* ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/
else
sudo apt update && sudo apt install postgresql-${DB_MAJOR_VERSION} -y || sudo apt install postgresql -y
cp /usr/lib/postgresql/${DB_MAJOR_VERSION}/bin/* ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/ || cp /usr/lib/postgresql/*/bin/* ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/
fi
;;
esac
- name: Archive binaries into platform-specific package
shell: bash
run: |
mkdir -p ./packages/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}
if [[ "${{ matrix.ext }}" == "zip" ]]; then
7z a ./packages/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}.zip ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/*
else
tar -czf ./packages/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}.tar.gz -C ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }} .
fi
- name: Upload to R2 with aws-cli
shell: bash
run: |
set -euo pipefail
pip install awscli --break-system-packages
if [[ -z "$R2_ENDPOINT" ]]; then
echo "R2_ENDPOINT is empty. Skipping upload."
exit 1
fi
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/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/ \
s3://$R2_BUCKET/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/ \
--recursive \
--endpoint-url "$R2_ENDPOINT"