-
-
Notifications
You must be signed in to change notification settings - Fork 8
185 lines (153 loc) · 5.67 KB
/
cross-compile.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
name: Build and Publish PHP Extension
on:
release:
types: [created]
permissions:
contents: write
jobs:
build-and-upload:
name: Build and upload
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# Linux x64 - PHP8.0
- build: x86_64-unknown-linux-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
php-versions: '8.0'
# Macos x64 - PHP8.0
- build: x86_64-apple-darwin
os: macos-latest
target: x86_64-apple-darwin
php-versions: '8.0'
- build: aarch64-apple-darwin
os: macos-latest
target: aarch64-apple-darwin
php-versions: '8.0'
# Windows x64 - PHP8.0
- build: x86_64-pc-windows-msvc
os: windows-latest
target: x86_64-pc-windows-msvc
php-versions: '8.0'
# Linux x64 - PHP8.1
- build: x86_64-unknown-linux-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
php-versions: '8.1'
# Macos x64 - PHP8.1
- build: x86_64-apple-darwin
os: macos-latest
target: x86_64-apple-darwin
php-versions: '8.1'
- build: aarch64-apple-darwin
os: macos-latest
target: aarch64-apple-darwin
php-versions: '8.1'
# Windows x64 - PHP8.1
- build: x86_64-pc-windows-msvc
os: windows-latest
target: x86_64-pc-windows-msvc
php-versions: '8.1'
# Linux x64 - PHP8.2
- build: x86_64-unknown-linux-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
php-versions: '8.2'
# Macos x64 - PHP8.2
- build: x86_64-apple-darwin
os: macos-latest
target: x86_64-apple-darwin
php-versions: '8.2'
- build: aarch64-apple-darwin
os: macos-latest
target: aarch64-apple-darwin
php-versions: '8.2'
# Windows x64 - PHP8.2
- build: x86_64-pc-windows-msvc
os: windows-latest
target: x86_64-pc-windows-msvc
php-versions: '8.2'
# Linux x64 - PHP8.3
- build: x86_64-unknown-linux-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
php-versions: '8.3'
# Macos x64 - PHP8.3
- build: x86_64-apple-darwin
os: macos-latest
target: x86_64-apple-darwin
php-versions: '8.3'
- build: aarch64-apple-darwin
os: macos-latest
target: aarch64-apple-darwin
php-versions: '8.3'
# Windows x64 - PHP8.3
- build: x86_64-pc-windows-msvc
os: windows-latest
target: x86_64-pc-windows-msvc
php-versions: '8.3'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get the release version from the tag
shell: bash
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Install Rust (MacOS and Linux)
if: matrix.os != 'windows-latest'
uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ matrix.target }}
- name: Install Rust (Windows)
if: matrix.os == 'windows-latest'
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Build (Linux)
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target ${{ matrix.target }}
- name: Build (MacOS and Windows)
if: matrix.os != 'ubuntu-latest'
run: cargo build --release --target ${{ matrix.target }}
- name: Build archive
shell: bash
run: |
# Replace with the name of your binary
binary_name="libsql_php"
str_version=${{ env.VERSION }}
version=${str_version#turso-php-extension/}
dirname="$binary_name-$version-php-${{ matrix.php-versions }}-${{ matrix.target }}"
mkdir "$dirname"
if [ "${{ matrix.os }}" = "macos-latest" ]; then
cp "target/${{ matrix.target }}/release/lib${binary_name}.dylib" "target/${{ matrix.target }}/release/lib${binary_name}.so"
mv "target/${{ matrix.target }}/release/lib${binary_name}.dylib" "$dirname"
mv "target/${{ matrix.target }}/release/lib${binary_name}.so" "$dirname"
mv "libsql_php_extension.stubs.php" "$dirname"
elif [ "${{ matrix.os }}" = "windows-latest" ]; then
mv "target/${{ matrix.target }}/release/${binary_name}.dll" "$dirname"
mv "libsql_php_extension.stubs.php" "$dirname"
ls "target/${{ matrix.target }}/release"
else
mv "target/${{ matrix.target }}/release/lib${binary_name}.so" "$dirname"
mv "libsql_php_extension.stubs.php" "$dirname"
fi
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7z a "$dirname.zip" "$dirname"
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
else
tar -czf "$dirname.tar.gz" "$dirname"
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
fi
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
${{ env.ASSET }}