Skip to content

Commit 01b92aa

Browse files
committed
♻️ Use script directly
1 parent 84b2f91 commit 01b92aa

File tree

8 files changed

+88
-85
lines changed

8 files changed

+88
-85
lines changed

.github/actions/check-deps-published.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/hub-publish.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ jobs:
5353
git commit -m "🔖 @huggingface/hub $BUMPED_VERSION"
5454
git tag "hub-v$BUMPED_VERSION"
5555
56-
- uses: ./.github/actions/check-deps-published
57-
with:
58-
dep: tasks
56+
- name: "Check Deps are published before publishing this package"
57+
run: pnpm -w check-deps tasks
5958

6059
- run: pnpm publish --no-git-checks .
6160
env:

.github/workflows/inference-publish.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ jobs:
5353
git commit -m "🔖 @huggingface/inference $BUMPED_VERSION"
5454
git tag "inference-v$BUMPED_VERSION"
5555
56-
- uses: ./.github/actions/check-deps-published
57-
with:
58-
dep: tasks
56+
- name: "Check Deps are published before publishing this package"
57+
run: pnpm -w check-deps gguf
5958

6059
- run: pnpm publish --no-git-checks .
6160
env:

.github/workflows/tasks-publish.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ jobs:
5050
git commit . -m "🔖 @huggingface/tasks $BUMPED_VERSION"
5151
git tag "tasks-v$BUMPED_VERSION"
5252
53-
- uses: ./.github/actions/check-deps-published
54-
with:
55-
dep: gguf
53+
- name: "Check Deps are published before publishing this package"
54+
run: pnpm -w check-deps gguf
5655

5756
- run: pnpm publish --no-git-checks .
5857
env:

.github/workflows/test-check-deps.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,5 @@ jobs:
1313
with:
1414
node-version: "20"
1515
cache: "pnpm"
16-
- uses: ./.github/actions/check-deps-published
17-
with:
18-
dep: hub
19-
- uses: ./.github/actions/check-deps-published
20-
with:
21-
dep: tasks
16+
- run: pnpm -w check-deps tasks
17+
- run: pnpm -w check-deps hub

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
"lint": "eslint --quiet --fix --ext .cjs,.ts .eslintrc.cjs",
88
"lint:check": "eslint --ext .cjs,.ts .eslintrc.cjs",
99
"format": "prettier --write package.json .prettierrc .vscode .eslintrc.cjs e2e .github *.md",
10-
"format:check": "prettier --check package.json .prettierrc .vscode .eslintrc.cjs .github *.md"
10+
"format:check": "prettier --check package.json .prettierrc .vscode .eslintrc.cjs .github *.md",
11+
"check-deps": "tsx scripts/check-deps.ts"
1112
},
1213
"devDependencies": {
1314
"@typescript-eslint/eslint-plugin": "^7.2.0",
1415
"@typescript-eslint/parser": "^7.2.0",
16+
"@types/node": "^18.16.1",
1517
"@vitest/browser": "^0.34.6",
1618
"eslint": "^8.57.0",
1719
"eslint-config-prettier": "^9.0.0",

pnpm-lock.yaml

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

scripts/check-deps.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { execSync } from "node:child_process";
2+
import { readFileSync } from "node:fs";
3+
import { parseArgs } from "node:util";
4+
5+
const args = parseArgs({
6+
allowPositionals: true,
7+
});
8+
9+
const dep = args.positionals[0];
10+
11+
if (!dep) {
12+
console.error("Error: No dependency specified.");
13+
process.exit(1);
14+
}
15+
16+
process.chdir(`./packages/${dep}`);
17+
18+
const localVersion = JSON.parse(readFileSync(`./package.json`, "utf-8")).version as string;
19+
const remoteVersion = execSync(`npm view @huggingface/${dep} version`).toString().trim();
20+
21+
if (localVersion !== remoteVersion) {
22+
console.error(
23+
`Error: The local @huggingface/${dep} package version (${localVersion}) differs from the remote version (${remoteVersion}). Release halted.`
24+
);
25+
process.exit(1);
26+
}
27+
28+
execSync(`npm pack @huggingface/${dep}`);
29+
execSync(`mv huggingface-${dep}-${localVersion}.tgz ${dep}-local.tgz`);
30+
31+
execSync(`npm pack @huggingface/${dep}@${remoteVersion}`);
32+
execSync(`mv huggingface-${dep}-${remoteVersion}.tgz ${dep}-remote.tgz`);
33+
34+
execSync(`tar -xf ${dep}-local.tgz`);
35+
const localChecksum = execSync(`cd package && tar --mtime='1970-01-01' --mode=755 -cf - . | sha256sum | cut -d' ' -f1`)
36+
.toString()
37+
.trim();
38+
console.log(`Local package checksum: ${localChecksum}`);
39+
execSync(`rm -Rf package`);
40+
41+
execSync(`tar -xf ${dep}-remote.tgz`);
42+
const remoteChecksum = execSync(`cd package && tar --mtime='1970-01-01' --mode=755 -cf - . | sha256sum | cut -d' ' -f1`)
43+
.toString()
44+
.trim();
45+
console.log(`Remote package checksum: ${remoteChecksum}`);
46+
execSync(`rm -Rf package`);
47+
48+
if (localChecksum !== remoteChecksum) {
49+
console.error(
50+
`Checksum Verification Failed: The local @huggingface/${dep} package differs from the remote version. Release halted. Local Checksum: ${localChecksum}, Remote Checksum: ${remoteChecksum}`
51+
);
52+
process.exit(1);
53+
}
54+
console.log(
55+
`Checksum Verification Successful: The local and remote @huggingface/${dep} packages are consistent. Local Checksum: ${localChecksum}, Remote Checksum: ${remoteChecksum}.`
56+
);

0 commit comments

Comments
 (0)