forked from prisma/prisma-engines
-
Notifications
You must be signed in to change notification settings - Fork 0
202 lines (181 loc) · 7.91 KB
/
build-engines-linux-template.yml
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: Build Engines for Linux
on:
workflow_call:
inputs:
commit:
description: 'Commit on the given branch to build'
type: string
required: false
jobs:
build:
name: '${{ matrix.target.name }} for commit ${{ inputs.commit }}'
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
# ⚠️ The target names are used to dtermine the directory name when uploaded to the buckets.
# Do not change them.
target:
# Linux Glibc
- name: 'rhel-openssl-1.0.x'
image: 'prismagraphql/build:rhel-libssl1.0.x'
target_string: ''
target_path: ''
features_string: '--features vendored-openssl'
- name: 'rhel-openssl-1.1.x'
image: 'prismagraphql/build:rhel-libssl1.1.x'
target_string: ''
target_path: ''
features_string: ''
- name: 'rhel-openssl-3.0.x'
image: 'prismagraphql/build:rhel-libssl3.0.x'
target_string: ''
target_path: ''
features_string: ''
# Linux Musl
# A better name would be "linux-musl-openssl-1.1.x"
# But we keep the old name for compatibility reasons
- name: 'linux-musl'
image: 'prismagraphql/build:alpine-libssl1.1.x'
target_string: ''
target_path: ''
features_string: ''
- name: 'linux-musl-openssl-3.0.x'
image: 'prismagraphql/build:alpine-libssl3.0.x'
target_string: ''
target_path: ''
features_string: ''
# Linux Static x86_64
# Note that the name should have "-static-"
# Because we look for "-static-" later in the construct_build_command step
- name: 'linux-static-x64'
image: 'prismagraphql/build:linux-static-x64'
target_string: '--target x86_64-unknown-linux-musl'
target_path: 'x86_64-unknown-linux-musl'
features_string: '--features vendored-openssl'
# Linux Glibc ARM64
- name: 'linux-arm64-openssl-1.0.x'
image: 'prismagraphql/build:cross-linux-arm-ssl-1.0.x'
target_string: '--target aarch64-unknown-linux-gnu'
target_path: 'aarch64-unknown-linux-gnu'
features_string: '--features vendored-openssl'
- name: 'linux-arm64-openssl-1.1.x'
image: 'prismagraphql/build:cross-linux-arm-ssl-1.1.x'
target_string: '--target aarch64-unknown-linux-gnu'
target_path: 'aarch64-unknown-linux-gnu'
features_string: ''
- name: 'linux-arm64-openssl-3.0.x'
image: 'prismagraphql/build:cross-linux-arm-ssl-3.0.x'
target_string: '--target aarch64-unknown-linux-gnu'
target_path: 'aarch64-unknown-linux-gnu'
features_string: ''
# Linux Musl ARM64
- name: 'linux-musl-arm64-openssl-1.1.x'
image: 'prismagraphql/build:cross-linux-musl-arm-ssl-1.1.x'
target_string: '--target aarch64-unknown-linux-musl'
target_path: 'aarch64-unknown-linux-musl'
features_string: ''
- name: 'linux-musl-arm64-openssl-3.0.x'
image: 'prismagraphql/build:cross-linux-musl-arm-ssl-3.0.x'
target_string: '--target aarch64-unknown-linux-musl'
target_path: 'aarch64-unknown-linux-musl'
features_string: ''
# Linux Static ARM64
# Note that the name should have "-static-"
# Because we look for "-static-" later in the construct_build_command step
- name: 'linux-static-arm64'
image: 'prismagraphql/build:linux-static-arm64'
target_string: '--target aarch64-unknown-linux-musl'
target_path: 'aarch64-unknown-linux-musl'
features_string: '--features vendored-openssl'
steps:
- name: Output link to commit
if: ${{ inputs.commit }}
run: echo https://github.com/prisma/prisma-engines/commit/${{ inputs.commit }}
- name: Checkout ${{ inputs.commit }}
uses: actions/checkout@v4
with:
ref: ${{ inputs.commit }}
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Construct build command
id: construct_build_command
env:
TARGET_NAME: ${{ matrix.target.name }}
IMAGE: ${{ matrix.target.image }}
TARGET_STRING: ${{ matrix.target.target_string }}
FEATURES_STRING: ${{ matrix.target.features_string }}
run: |
set -eux;
command=$(bash .github/workflows/utils/constructDockerBuildCommand.sh)
# store command in GitHub output
echo "COMMAND=$command" >> "$GITHUB_OUTPUT"
- name: Show Build Command
env:
COMMAND: ${{ steps.construct_build_command.outputs.COMMAND }}"
run: echo "Build command is $COMMAND"
- name: Execute Build command
run: ${{ steps.construct_build_command.outputs.command }}
- name: Prepare files for "release" target
if: ${{ matrix.target.target_path == '' }}
env:
TARGET_NAME: ${{ matrix.target.name }}
RELEASE_DIR: ${{ github.workspace }}/target/release
run: |
echo "Files in target/release before renaming"
ls -la $RELEASE_DIR
echo "Copying files to engines-artifacts"
cp -r $RELEASE_DIR/ engines-artifacts
echo "Rename libquery_engine.so to libquery_engine.so.node for non-static targets"
if [[ "$TARGET_NAME" == *-static-* ]]; then
echo "Current target is static. Skipping."
else
mv engines-artifacts/libquery_engine.so engines-artifacts/libquery_engine.so.node
fi
echo "Files in engines-artifacts after renaming"
ls -la engines-artifacts
- name: Upload artifacts for "release" target
uses: actions/upload-artifact@v4
if: ${{ matrix.target.target_path == '' }}
with:
name: '${{ matrix.target.name }}'
path: |
${{ github.workspace }}/engines-artifacts/libquery_engine.so.node
${{ github.workspace }}/engines-artifacts/schema-engine
${{ github.workspace }}/engines-artifacts/query-engine
${{ github.workspace }}/engines-artifacts/prisma-fmt
- name: Prepare files for "${{ matrix.target.name }}" target
if: ${{ matrix.target.target_path != '' }}
env:
TARGET_NAME: ${{ matrix.target.name }}
RELEASE_DIR: ${{ github.workspace }}/target/${{ matrix.target.target_path }}/release
run: |
echo "Files in target/release before renaming"
ls -la $RELEASE_DIR
echo "Copying files to engines-artifacts"
cp -r $RELEASE_DIR/ engines-artifacts
echo "Rename libquery_engine.so to libquery_engine.so.node for non-static targets"
if [[ "$TARGET_NAME" == *-static-* ]]; then
echo "Current target is static. Skipping."
else
mv engines-artifacts/libquery_engine.so engines-artifacts/libquery_engine.so.node
fi
echo "Files in engines-artifacts after renaming"
ls -la engines-artifacts
- name: Upload artifacts for "${{ matrix.target.name }}" target
uses: actions/upload-artifact@v4
if: ${{ matrix.target.target_path != '' }}
with:
name: ${{ matrix.target.name }}
path: |
${{ github.workspace }}/engines-artifacts/libquery_engine.so.node
${{ github.workspace }}/engines-artifacts/schema-engine
${{ github.workspace }}/engines-artifacts/query-engine
${{ github.workspace }}/engines-artifacts/prisma-fmt