From 9d2ee96af0296e2515b3a9fc3bc2a52a0b421fb7 Mon Sep 17 00:00:00 2001 From: O96u Date: Sun, 23 Aug 2026 18:26:13 +0800 Subject: [PATCH] fix: CI typecheck and native ARM Docker builds for v1.0.3 Fix TypeScript errors blocking CI, split Docker publish into native amd64/arm64 jobs with manifest merge, and add npm cache mounts. --- .github/workflows/docker-publish.yml | 81 ++++++++++++++++++++------- CHANGELOG.md | 9 +++ Dockerfile | 5 +- README.en.md | 3 +- README.md | 3 +- app/components/MobileNavMenu.vue | 6 +- app/components/MobileUserMenu.vue | 6 +- app/composables/useAppearanceMenus.ts | 4 +- app/composables/useImageList.ts | 1 + package-lock.json | 4 +- package.json | 2 +- 11 files changed, 96 insertions(+), 28 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 0ad64b6..9f3409a 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -13,9 +13,19 @@ env: IMAGE_NAME: pichost jobs: - build-and-push: + build: if: ${{ !contains(github.event.head_commit.message, '[skip docker]') }} - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - platform: linux/amd64 + runner: ubuntu-latest + suffix: amd64 + - platform: linux/arm64 + runner: ubuntu-24.04-arm + suffix: arm64 + runs-on: ${{ matrix.runner }} env: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} @@ -23,9 +33,6 @@ jobs: - name: Checkout uses: actions/checkout@v7 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -35,22 +42,58 @@ jobs: username: ${{ env.DOCKERHUB_USERNAME }} password: ${{ env.DOCKERHUB_TOKEN }} - - name: Extract metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }} - tags: | - type=raw,value=latest - type=semver,pattern={{version}} + - name: Resolve version + id: version + run: | + if [ "${{ github.ref_type }}" = "tag" ]; then + echo "value=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT" + else + echo "value=dev" >> "$GITHUB_OUTPUT" + fi - - name: Build and push + - name: Build and push platform image uses: docker/build-push-action@v6 with: context: . push: true - platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max + platforms: ${{ matrix.platform }} + tags: | + ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.value }}-${{ matrix.suffix }} + cache-from: type=gha,scope=${{ matrix.suffix }} + cache-to: type=gha,mode=max,scope=${{ matrix.suffix }} + + merge: + if: ${{ !contains(github.event.head_commit.message, '[skip docker]') }} + needs: build + runs-on: ubuntu-latest + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ env.DOCKERHUB_USERNAME }} + password: ${{ env.DOCKERHUB_TOKEN }} + + - name: Resolve version + id: version + run: | + if [ "${{ github.ref_type }}" = "tag" ]; then + echo "value=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT" + else + echo "value=dev" >> "$GITHUB_OUTPUT" + fi + + - name: Create multi-arch manifest + run: | + IMAGE="${DOCKERHUB_USERNAME}/${IMAGE_NAME}" + VERSION="${{ steps.version.outputs.value }}" + docker buildx imagetools create \ + -t "${IMAGE}:${VERSION}" \ + -t "${IMAGE}:latest" \ + "${IMAGE}:${VERSION}-amd64" \ + "${IMAGE}:${VERSION}-arm64" diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c4d2c6..3decd20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ 本仓库自 **v1.0.0** 起作为正式版维护;此前历史提交已归档重置。 +## [1.0.3] - 2026-08-23 + +### 修复 + +- 修复 CI typecheck 失败(移动端菜单、i18n、统计页图库刷新) +- Docker 构建:arm64 改用原生 ARM Runner,避免 QEMU 下 `npm ci` 极慢 +- Docker 构建:启用 npm 缓存挂载,加快依赖安装 + ## [1.0.2] - 2026-08-23 ### 新增 @@ -47,6 +55,7 @@ - **v1.1.0**(计划中):S3、Cloudflare R2 及更多对象存储后端 +[1.0.3]: https://github.com/O96u/PicHost/releases/tag/v1.0.3 [1.0.2]: https://github.com/O96u/PicHost/releases/tag/v1.0.2 [1.0.1]: https://github.com/O96u/PicHost/releases/tag/v1.0.1 [1.0.0]: https://github.com/O96u/PicHost/releases/tag/v1.0.0 diff --git a/Dockerfile b/Dockerfile index 881bed0..efb8c8b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +# syntax=docker/dockerfile:1 + FROM node:22-alpine AS build WORKDIR /app @@ -6,7 +8,8 @@ WORKDIR /app RUN npm install -g npm@11.12.1 COPY package.json package-lock.json ./ -RUN npm ci +RUN --mount=type=cache,target=/root/.npm \ + npm ci COPY . . RUN npm run build diff --git a/README.en.md b/README.en.md index 282dcf3..adb54d4 100644 --- a/README.en.md +++ b/README.en.md @@ -194,7 +194,8 @@ npm test # Unit tests | Version | Plan | |---------|------| -| **v1.0.2** | i18n, mobile menus, stats/upload UI, Docker password reset (current) | +| **v1.0.3** | CI and Docker multi-arch build fixes (current) | +| **v1.0.2** | i18n, mobile menus, stats/upload UI, Docker password reset | | **v1.0.1** | Settings version display, mobile upload preferences layout fix | | **v1.0.0** | Local storage, multi-user, API, Twikoo | | **v1.1.0** | S3, Cloudflare R2, and more object storage backends | diff --git a/README.md b/README.md index 76948e0..0a95d0f 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,8 @@ npm test # 单元测试 | 版本 | 计划 | |------|------| -| **v1.0.2** | 中英文、移动端菜单、统计/上传 UI、Docker 重置密码(当前) | +| **v1.0.3** | CI 与 Docker 多架构构建修复(当前) | +| **v1.0.2** | 中英文、移动端菜单、统计/上传 UI、Docker 重置密码 | | **v1.0.1** | 设置页版本展示、移动端上传偏好布局修复 | | **v1.0.0** | 本地存储、多用户、API、Twikoo | | **v1.1.0** | S3、Cloudflare R2 等对象存储后端 | diff --git a/app/components/MobileNavMenu.vue b/app/components/MobileNavMenu.vue index a8200fa..a79988f 100644 --- a/app/components/MobileNavMenu.vue +++ b/app/components/MobileNavMenu.vue @@ -36,6 +36,10 @@ watch(open, (isOpen) => { onUnmounted(() => { document.removeEventListener('click', onDocumentClick, true) }) + +function toggleOpen() { + open.value = !open.value +}