From 7ad2643bf1e797383d8328276c99c2fa50331a08 Mon Sep 17 00:00:00 2001 From: Clarence Date: Fri, 13 Dec 2024 23:38:55 +0800 Subject: [PATCH 1/4] ci: create main workflow Signed-off-by: Clarence --- .github/workflows/main.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..f353741 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,37 @@ +name: CI build +on: + push: + branches: main + pull_request: + branches: main + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: DerYeger/pnpm-setup-action@master + with: + node-version: latest + - name: Build + run: pnpm build + - name: Compress action step + uses: a7ul/tar-action@v1.1.0 + id: compress + with: + command: c + cwd: ./ + files: | + ./build + outPath: build.tar.gz + - name: Archive build artifacts + uses: actions/upload-artifact@v4 + with: + name: build + path: | + build.tar.gz + - name: Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + files: build.tar.gz From 0b11a964cbb2edc505a474b6d548f59b5a61d8ec Mon Sep 17 00:00:00 2001 From: Clarence Date: Fri, 13 Dec 2024 23:57:54 +0800 Subject: [PATCH 2/4] fix: create `packageManager` package.json Manually specify `packageManager` in package.json otherwise the CI will fail to install pnpm. Signed-off-by: Clarence --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 18e8ac7..beb71b8 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.0.0", "private": true, "type": "module", + "packageManager": "pnpm@9.14.3", "scripts": { "dev": "vite", "build": "run-p type-check \"build-only {@}\" --", From 3ca3137dc93cf5126d0d815f7621d90aef0a221f Mon Sep 17 00:00:00 2001 From: Clarence Date: Sat, 14 Dec 2024 00:12:35 +0800 Subject: [PATCH 3/4] fix: tsc type check failed Resolution: Separate build and type check steps. --- .github/workflows/main.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f353741..7ad6d64 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,11 @@ jobs: with: node-version: latest - name: Build - run: pnpm build + run: pnpm build-only + # Separate build and type check, + # because *.d.ts files aren't generated before build + - name: Type Check + run: pnpm type-check - name: Compress action step uses: a7ul/tar-action@v1.1.0 id: compress From 3f44124886f03e5ccef71e50fbcf2303b178c1c6 Mon Sep 17 00:00:00 2001 From: Clarence Date: Sat, 14 Dec 2024 00:15:22 +0800 Subject: [PATCH 4/4] fix: wrong directory name "build" --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7ad6d64..5ec992e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,16 +26,16 @@ jobs: command: c cwd: ./ files: | - ./build - outPath: build.tar.gz + ./dist + outPath: dist.tar.gz - name: Archive build artifacts uses: actions/upload-artifact@v4 with: name: build path: | - build.tar.gz + ./dist.tar.gz - name: Release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') with: - files: build.tar.gz + files: dist.tar.gz