-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (147 loc) · 6.49 KB
/
upload-binaries.yml
File metadata and controls
165 lines (147 loc) · 6.49 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Build and Upload DB Binaries to R2
on:
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
max-parallel: 3
fail-fast: false
matrix:
include:
# MongoDB
- database: mongodb
db_version: 8.0.12
os: macos-latest
platform: macos
arch: arm64
ext: tar.gz
- database: mongodb
db_version: 8.0.12
os: macos-latest
platform: macos
arch: x86_64
ext: tar.gz
- database: mongodb
db_version: 8.0.12
os: ubuntu-latest
platform: linux
arch: x86_64
ext: tar.gz
- database: mongodb
db_version: 8.0.12
os: ubuntu-latest
platform: linux
arch: arm64
ext: tar.gz
# PostgreSQL
# This is built manually on target machines due to the limitations
# of Github Actions. See joystick-database-binaries/manual.
# Redis
- database: redis
db_version: 7.2.5
os: macos-latest
platform: macos
arch: arm64
ext: tar.gz
- database: redis
db_version: 7.2.5
os: macos-latest
platform: macos
arch: x86_64
ext: tar.gz
- database: redis
db_version: 7.2.5
os: ubuntu-latest
platform: linux
arch: x86_64
ext: tar.gz
- database: redis
db_version: 7.2.5
os: ubuntu-latest
platform: linux
arch: arm64
ext: tar.gz
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
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: Install dependencies and fetch binaries
shell: bash
run: |
mkdir -p ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}
case "$DATABASE" in
redis)
curl -LO http://download.redis.io/releases/redis-${DB_VERSION}.tar.gz
tar -xzf redis-${DB_VERSION}.tar.gz
make -C redis-${DB_VERSION}
cp redis-${DB_VERSION}/src/redis-server ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/
;;
mongodb)
if [[ "$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 -r ./mongodb-*/* ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/
if [[ "${{ matrix.arch }}" == "arm64" ]]; then
curl -LO https://downloads.mongodb.com/compass/mongosh-2.5.6-darwin-arm64.zip
unzip mongosh-2.5.6-darwin-arm64.zip
cp ./mongosh-2.5.6-darwin-arm64/bin/mongosh ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/bin/
else
curl -LO https://downloads.mongodb.com/compass/mongosh-2.5.6-darwin-x64.zip
unzip mongosh-2.5.6-darwin-x64.zip
cp ./mongosh-2.5.6-darwin-x64/bin/mongosh ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/bin/
fi
else
if [[ "${{ matrix.arch }}" == "arm64" ]]; then
curl -LO https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-ubuntu2204-${DB_VERSION}.tgz
tar -xzf mongodb-linux-aarch64-ubuntu2204-${DB_VERSION}.tgz
cp -r ./mongodb-linux-aarch64-ubuntu2204-${DB_VERSION}/* ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/
curl -LO https://downloads.mongodb.com/compass/mongosh-2.5.6-linux-arm64.tgz
tar -xzf mongosh-2.5.6-linux-arm64.tgz
cp ./mongosh-2.5.6-linux-arm64/bin/mongosh ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/bin/
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 -r ./mongodb-linux-x86_64-ubuntu2204-${DB_VERSION}/* ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/
curl -LO https://downloads.mongodb.com/compass/mongosh-2.5.6-linux-x64.tgz
tar -xzf mongosh-2.5.6-linux-x64.tgz
cp ./mongosh-2.5.6-linux-x64/bin/mongosh ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}/bin/
fi
fi
;;
esac
- name: Archive binaries into platform-specific package
shell: bash
run: |
mkdir -p ./packages/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}
tar -czf ./packages/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }}.tar.gz -C ./raw/${DATABASE}/${DB_MAJOR_VERSION}/${{ matrix.platform }}/${{ matrix.arch }} .
- 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"