From c84c19739cf733cd4ff0fbccabb14746c8089837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A3=A8=EB=B0=80LuMir?= Date: Thu, 9 Jan 2025 20:49:02 +0900 Subject: [PATCH 1/6] fix: add support for `.zip` files in binary download --- package-lock.json | 22 ++++++++++++++++++++++ package.json | 2 ++ src/release.ts | 15 +++++++++++++-- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4bff27f..8e92610 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,11 +16,13 @@ "@commitlint/cli": "19.5.0", "@commitlint/config-conventional": "19.5.0", "@octokit/rest": "21.0.2", + "@types/adm-zip": "0.5.7", "@types/node": "22.6.1", "@types/proxy-from-env": "1.0.4", "@typescript-eslint/eslint-plugin": "8.7.0", "@typescript-eslint/parser": "8.7.0", "@vercel/ncc": "0.38.2", + "adm-zip": "0.5.16", "eslint": "8.57.1", "prettier": "3.3.3", "proxy": "2.2.0", @@ -1504,6 +1506,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@types/adm-zip": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/@types/adm-zip/-/adm-zip-0.5.7.tgz", + "integrity": "sha512-DNEs/QvmyRLurdQPChqq0Md4zGvPwHerAJYWk9l2jCbD1VPpnzRJorOdiq4zsw09NFbYnhfsoEhWtxIzXpn2yw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/conventional-commits-parser": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/@types/conventional-commits-parser/-/conventional-commits-parser-5.0.0.tgz", @@ -1771,6 +1783,16 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/adm-zip": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.16.tgz", + "integrity": "sha512-TGw5yVi4saajsSEgz25grObGHEUaDrniwvA2qwSC060KfqGPdglhvPMA2lPIoxs3PQIItj2iag35fONcQqgUaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0" + } + }, "node_modules/agent-base": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", diff --git a/package.json b/package.json index dddd464..d676ab0 100644 --- a/package.json +++ b/package.json @@ -44,11 +44,13 @@ "@commitlint/cli": "19.5.0", "@commitlint/config-conventional": "19.5.0", "@octokit/rest": "21.0.2", + "@types/adm-zip": "0.5.7", "@types/node": "22.6.1", "@types/proxy-from-env": "1.0.4", "@typescript-eslint/eslint-plugin": "8.7.0", "@typescript-eslint/parser": "8.7.0", "@vercel/ncc": "0.38.2", + "adm-zip": "0.5.16", "eslint": "8.57.1", "prettier": "3.3.3", "proxy": "2.2.0", diff --git a/src/release.ts b/src/release.ts index 7cdb91c..7dd7d65 100644 --- a/src/release.ts +++ b/src/release.ts @@ -7,6 +7,7 @@ import { fetch, ProxyAgent } from "undici" import type { RequestInit } from "undici" import { extract } from "tar" import tmp from "tmp-promise" +import admzip from "adm-zip" import { COMBINED_PATH, NAME } from "./constants" const octokit = new Octokit({ request: { fetch: proxiedFetch } }) @@ -15,7 +16,10 @@ export async function findRelease(version: string) { const release = await getRelease(version) const releasePrefix = getAssetPrefix() const matchedAsset = release.data.assets.find(({ name }) => { - return name.startsWith(releasePrefix) && name.endsWith(".tar.gz") + return ( + name.startsWith(releasePrefix) && + (name.endsWith(".tar.gz") || name.endsWith(".zip")) + ) }) if (!matchedAsset) { throw new Error(`The binary '${releasePrefix}*' not found`) @@ -27,7 +31,14 @@ export async function downloadBinary(url: string) { const response = await proxiedFetch(url) const tmpfile = await tmp.file() await writeFile(tmpfile.path, Buffer.from(await response.arrayBuffer())) - await extract({ file: tmpfile.path, cwd: COMBINED_PATH, strict: true }) + + if (url.endsWith(".zip")) { + const zip = new admzip(tmpfile.path) + zip.extractAllTo(COMBINED_PATH, true) + } else { + await extract({ file: tmpfile.path, cwd: COMBINED_PATH, strict: true }) + } + await tmpfile.cleanup() } From c80a2e0fc8c6f6bc24754c039dddcb7538b85915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20LUDWIG?= Date: Thu, 9 Jan 2025 15:19:15 +0100 Subject: [PATCH 2/6] ci: check on all OS --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0ab954..99eb926 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,10 @@ on: jobs: build_and_lint: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v4 From 50986adf375e76b6c6ea08f1d41a8fd57341105e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20LUDWIG?= Date: Thu, 9 Jan 2025 15:53:00 +0100 Subject: [PATCH 3/6] ci: run lint steps only on Ubuntu --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99eb926..6c11ae2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,9 +22,18 @@ jobs: - run: npm ci - run: npm run build + - run: npm run lint:commit -- --to "${{ github.sha }}" + if: ${{ runner.os == 'Linux' }} + - run: npm run lint:typescript + if: ${{ runner.os == 'Linux' }} + - run: npm run lint:eslint + if: ${{ runner.os == 'Linux' }} + - run: npm run lint:prettier + if: ${{ runner.os == 'Linux' }} + - run: npm run test - run: npm run start From ec3d022f62e8e819bd15b4c54331468c038ec981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A3=A8=EB=B0=80LuMir?= Date: Fri, 10 Jan 2025 00:07:00 +0900 Subject: [PATCH 4/6] fix: update `start` script to use `node` explicitly --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d676ab0..03616b1 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "prepublishOnly": "npm run build", "build": "rimraf dist && ncc build src/index.ts --minify", "test": "node --import=tsx --test \"src/**/*.spec.ts\"", - "start": "./dist/index.js", + "start": "node ./dist/index.js", "release": "semantic-release" }, "devDependencies": { From a73feb8b72f638c10b43b67468878f32309a30ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A3=A8=EB=B0=80LuMir?= Date: Fri, 10 Jan 2025 00:26:37 +0900 Subject: [PATCH 5/6] ci: disable fail-fast in CI workflow for better job resilience --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c11ae2..f0aec60 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,7 @@ jobs: build_and_lint: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] steps: From bd704cde168854e8975a4b4b81fd9d862ba7d3c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A3=A8=EB=B0=80LuMir?= Date: Fri, 10 Jan 2025 00:32:36 +0900 Subject: [PATCH 6/6] chore: add `.gitattributes` to enforce consistent EOL for text files --- .gitattributes | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8a5a533 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +# https://git-scm.com/docs/gitattributes + +# Ensure consistent EOL(LF) for all files that Git considers text files. +* text=auto eol=lf