Skip to content

Commit ec7c63d

Browse files
authored
ci: add permissions to release actions (#6436)
1 parent 6d2b50b commit ec7c63d

11 files changed

Lines changed: 123 additions & 8 deletions

File tree

.changeset/lemon-experts-sleep.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Fixed an issue where binaries weren't copied anymore inside the `@biomejs/cli-*` packages.

.github/workflows/release.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,20 @@ jobs:
340340
git restore packages/@biomejs/wasm-nodejs/package.json
341341
git restore packages/@biomejs/wasm-web/package.json
342342
343+
- name: Copy binaries
344+
run: node packages/@biomejs/biome/scripts/copy-binaries.mjs
345+
343346
- name: Publish npm packages as latest
344347
run: pnpm run publish
345348
env:
349+
# To publish on npmjs
346350
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
351+
# To push the tags
352+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
347353

348354
- name: Upload assets to the latest tag
349355
run: |
350356
files=$(ls biome-* | tr '\n' ' ')
351357
gh release upload @biomejs/biome@${{ needs.build-binaries.outputs.version }} $files
358+
env:
359+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import * as fs from "node:fs";
2+
import { resolve } from "node:path";
3+
import { fileURLToPath } from "node:url";
4+
import { format } from "node:util";
5+
6+
const CLI_ROOT = resolve(fileURLToPath(import.meta.url), "../..");
7+
const PACKAGES_ROOT = resolve(CLI_ROOT, "..");
8+
const REPO_ROOT = resolve(PACKAGES_ROOT, "../..");
9+
const MANIFEST_PATH = resolve(CLI_ROOT, "package.json");
10+
11+
const rootManifest = JSON.parse(fs.readFileSync(MANIFEST_PATH, "utf-8"));
12+
13+
function getName(platform, arch, prefix = "cli") {
14+
return format(`${prefix}-${platform}`, arch);
15+
}
16+
17+
function copyBinaryToNativePackage(platform, arch) {
18+
const os = platform.split("-")[0];
19+
const buildName = getName(platform, arch);
20+
const packageRoot = resolve(PACKAGES_ROOT, buildName);
21+
const packageName = `@biomejs/${buildName}`;
22+
23+
// Update the package.json manifest
24+
const { version, license, repository, engines, homepage } = rootManifest;
25+
26+
const manifest = JSON.stringify(
27+
{
28+
name: packageName,
29+
version,
30+
license,
31+
repository,
32+
engines,
33+
homepage,
34+
os: [os],
35+
cpu: [arch],
36+
libc:
37+
os === "linux"
38+
? packageName.endsWith("musl")
39+
? ["musl"]
40+
: ["glibc"]
41+
: undefined,
42+
},
43+
null,
44+
2,
45+
);
46+
47+
const manifestPath = resolve(packageRoot, "package.json");
48+
console.info(`Update manifest ${manifestPath}`);
49+
fs.writeFileSync(manifestPath, manifest);
50+
51+
// Copy the CLI binary
52+
const ext = os === "win32" ? ".exe" : "";
53+
const binarySource = resolve(
54+
REPO_ROOT,
55+
`${getName(platform, arch, "biome")}${ext}`,
56+
);
57+
const binaryTarget = resolve(packageRoot, `biome${ext}`);
58+
59+
if (!fs.existsSync(binarySource)) {
60+
console.error(
61+
`Source for binary for ${buildName} not found at: ${binarySource}`,
62+
);
63+
process.exit(1);
64+
}
65+
66+
console.info(`Copy binary ${binaryTarget}`);
67+
fs.copyFileSync(binarySource, binaryTarget);
68+
fs.chmodSync(binaryTarget, 0o755);
69+
}
70+
71+
const PLATFORMS = ["win32-%s", "darwin-%s", "linux-%s", "linux-%s-musl"];
72+
const ARCHITECTURES = ["x64", "arm64"];
73+
74+
for (const platform of PLATFORMS) {
75+
for (const arch of ARCHITECTURES) {
76+
copyBinaryToNativePackage(platform, arch);
77+
}
78+
}

packages/@biomejs/cli-darwin-arm64/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@
1919
],
2020
"publishConfig": {
2121
"provenance": true
22-
}
22+
},
23+
"files": [
24+
"bin/biome"
25+
]
2326
}

packages/@biomejs/cli-darwin-x64/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@
1919
],
2020
"publishConfig": {
2121
"provenance": true
22-
}
22+
},
23+
"files": [
24+
"bin/biome"
25+
]
2326
}

packages/@biomejs/cli-linux-arm64-musl/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@
2222
],
2323
"publishConfig": {
2424
"provenance": true
25-
}
25+
},
26+
"files": [
27+
"bin/biome"
28+
]
2629
}

packages/@biomejs/cli-linux-arm64/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@
2222
],
2323
"publishConfig": {
2424
"provenance": true
25-
}
25+
},
26+
"files": [
27+
"bin/biome"
28+
]
2629
}

packages/@biomejs/cli-linux-x64-musl/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@
2222
],
2323
"publishConfig": {
2424
"provenance": true
25-
}
25+
},
26+
"files": [
27+
"bin/biome"
28+
]
2629
}

packages/@biomejs/cli-linux-x64/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@
2222
],
2323
"publishConfig": {
2424
"provenance": true
25-
}
25+
},
26+
"files": [
27+
"bin/biome"
28+
]
2629
}

packages/@biomejs/cli-win32-arm64/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@
1919
],
2020
"publishConfig": {
2121
"provenance": true
22-
}
22+
},
23+
"files": [
24+
"bin/biome"
25+
]
2326
}

0 commit comments

Comments
 (0)