Skip to content

Commit a78fab1

Browse files
feat(build): x86 musl build (#518)
1 parent f6bbdc6 commit a78fab1

5 files changed

Lines changed: 184 additions & 204 deletions

File tree

.github/workflows/release.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
- { os: macos-14, target: aarch64-apple-darwin }
4444
- { os: windows-2022, target: x86_64-pc-windows-msvc }
4545
- { os: windows-2022, target: aarch64-pc-windows-msvc }
46+
- { os: ubuntu-22.04, target: x86_64-unknown-linux-musl }
4647

4748
runs-on: ${{ matrix.config.os }}
4849

@@ -53,6 +54,7 @@ jobs:
5354
- uses: actions/checkout@v4
5455
with:
5556
submodules: true
57+
5658
- uses: actions-rust-lang/setup-rust-toolchain@v1
5759
with:
5860
target: ${{ matrix.config.target }}
@@ -67,6 +69,12 @@ jobs:
6769
sudo apt-get update
6870
sudo apt-get install -y gcc-aarch64-linux-gnu
6971
72+
- name: Install musl toolchain
73+
if: matrix.config.target == 'x86_64-unknown-linux-musl'
74+
run: |
75+
sudo apt-get update
76+
sudo apt-get install -y musl-tools
77+
7078
- name: Setup Postgres
7179
uses: ./.github/actions/setup-postgres
7280

@@ -130,7 +138,9 @@ jobs:
130138

131139
- name: Ensure tag matches
132140
if: steps.create_changelog.outputs.version != needs.extract_version.outputs.version
133-
run: exit 1
141+
run: |
142+
echo "Tag does not match: ${{ steps.create_changelog.outputs.version }} vs ${{ needs.extract_version.outputs.version }}"
143+
exit 1
134144
135145
- name: 👇 Download Artifacts
136146
uses: actions/download-artifact@v4

bun.lock

Lines changed: 55 additions & 133 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@postgrestools/postgrestools/bin/postgrestools

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#!/usr/bin/env node
22
const { platform, arch, env } = process;
33

4-
/**
5-
* platform and arch are values injected into the node runtime.
6-
* We use the values documented on https://nodejs.org.
7-
*/
84
const PLATFORMS = {
95
win32: {
106
x64: "@postgrestools/cli-x86_64-windows-msvc/postgrestools.exe",
@@ -18,9 +14,40 @@ const PLATFORMS = {
1814
x64: "@postgrestools/cli-x86_64-linux-gnu/postgrestools",
1915
arm64: "@postgrestools/cli-aarch64-linux-gnu/postgrestools",
2016
},
17+
"linux-musl": {
18+
x64: "@postgrestools/cli-x86_64-linux-musl/postgrestools",
19+
// no arm64 build for musl
20+
},
2121
};
2222

23-
const binPath = env.POSTGRESTOOLS_BINARY || PLATFORMS?.[platform]?.[arch];
23+
function isMusl() {
24+
let stderr;
25+
try {
26+
stderr = execSync("ldd --version", {
27+
stdio: [
28+
"ignore", // stdin
29+
"pipe", // stdout – glibc systems print here
30+
"pipe", // stderr – musl systems print here
31+
],
32+
});
33+
} catch (err) {
34+
stderr = err.stderr;
35+
}
36+
if (stderr.indexOf("musl") > -1) {
37+
return true;
38+
}
39+
return false;
40+
}
41+
42+
function getPlatform() {
43+
if (platform === "linux") {
44+
return isMusl() ? "linux-musl" : "linux";
45+
}
46+
47+
return platform;
48+
}
49+
50+
const binPath = env.POSTGRESTOOLS_BINARY || PLATFORMS?.[getPlatform()]?.[arch];
2451

2552
if (binPath) {
2653
const result = require("child_process").spawnSync(
Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,44 @@
11
{
2-
"name": "@postgrestools/postgrestools",
3-
"version": "<placeholder>",
4-
"bin": {
5-
"postgrestools": "bin/postgrestools"
6-
},
7-
"repository": {
8-
"type": "git",
9-
"url": "git+https://github.com/supabase-community/postgres-language-server.git",
10-
"directory": "packages/@postgrestools/postgrestools"
11-
},
12-
"author": "Supabase Community",
13-
"contributors": [
14-
{
15-
"name": "Philipp Steinrötter",
16-
"url": "https://github.com/psteinroe"
17-
},
18-
{
19-
"name": "Julian Domke",
20-
"url": "https://github.com/juleswritescode"
21-
}
22-
],
23-
"license": "MIT or Apache-2.0",
24-
"description": "A collection of language tools and a Language Server Protocol (LSP) implementation for Postgres, focusing on developer experience and reliable SQL tooling.",
25-
"files": ["bin/postgrestools", "schema.json"],
26-
"engines": {
27-
"node": ">=20"
28-
},
29-
"publishConfig": {
30-
"provenance": true
31-
},
32-
"optionalDependencies": {
33-
"@postgrestools/cli-x86_64-windows-msvc": "<placeholder>",
34-
"@postgrestools/cli-aarch64-windows-msvc": "<placeholder>",
35-
"@postgrestools/cli-x86_64-apple-darwin": "<placeholder>",
36-
"@postgrestools/cli-aarch64-apple-darwin": "<placeholder>",
37-
"@postgrestools/cli-x86_64-linux-gnu": "<placeholder>",
38-
"@postgrestools/cli-aarch64-linux-gnu": "<placeholder>"
39-
}
2+
"name": "@postgrestools/postgrestools",
3+
"version": "<placeholder>",
4+
"bin": {
5+
"postgrestools": "bin/postgrestools"
6+
},
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/supabase-community/postgres-language-server.git",
10+
"directory": "packages/@postgrestools/postgrestools"
11+
},
12+
"author": "Supabase Community",
13+
"contributors": [
14+
{
15+
"name": "Philipp Steinrötter",
16+
"url": "https://github.com/psteinroe"
17+
},
18+
{
19+
"name": "Julian Domke",
20+
"url": "https://github.com/juleswritescode"
21+
}
22+
],
23+
"license": "MIT or Apache-2.0",
24+
"description": "A collection of language tools and a Language Server Protocol (LSP) implementation for Postgres, focusing on developer experience and reliable SQL tooling.",
25+
"files": [
26+
"bin/postgrestools",
27+
"schema.json"
28+
],
29+
"engines": {
30+
"node": ">=20"
31+
},
32+
"publishConfig": {
33+
"provenance": true
34+
},
35+
"optionalDependencies": {
36+
"@postgrestools/cli-x86_64-windows-msvc": "<placeholder>",
37+
"@postgrestools/cli-aarch64-windows-msvc": "<placeholder>",
38+
"@postgrestools/cli-x86_64-apple-darwin": "<placeholder>",
39+
"@postgrestools/cli-aarch64-apple-darwin": "<placeholder>",
40+
"@postgrestools/cli-x86_64-linux-gnu": "<placeholder>",
41+
"@postgrestools/cli-aarch64-linux-gnu": "<placeholder>",
42+
"@postgrestools/cli-x86_64-linux-musl": "<placeholder>"
43+
}
4044
}

0 commit comments

Comments
 (0)