diff --git a/.github/workflows/dev-latest.yml b/.github/workflows/dev-latest.yml index eed5d029..93a6883d 100644 --- a/.github/workflows/dev-latest.yml +++ b/.github/workflows/dev-latest.yml @@ -19,22 +19,53 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + if [ -f backend/requirements-dev.txt ]; then pip install -r backend/requirements-dev.txt; fi pip install pytest - name: Test - working-directory: ./src + working-directory: ./backend/src run: | mkdir -p config pytest - dev-latest: + build-webui: + runs-on: ubuntu-latest + needs: [test] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: latest + + - uses: pnpm/action-setup@v2 + name: Install pnpm + id: pnpm-install + with: + version: latest + run_install: true + + - name: Build + run: | + cd webui + pnpm build && zip -r dist.zip dist + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: dist.zip + path: webui/dist.zip + + + dev-build: runs-on: ubuntu-latest needs: [test] steps: - name: Checkout uses: actions/checkout@v3 - name: Create Version info - working-directory: ./src + working-directory: ./backend/src run: | echo "VERSION = '$GITHUB_REF_NAME'" > module/__version__.py @@ -44,6 +75,11 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: dist.zip + - name: Docker metadata id: meta uses: docker/metadata-action@v4 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 110b0185..79f38562 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -19,26 +19,86 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + if [ -f backend/requirements.txt ]; then pip install -r backend/requirements.txt; fi pip install pytest - name: Test - working-directory: ./src + working-directory: ./backend/src run: | mkdir -p config pytest - - build: + build-webui: runs-on: ubuntu-latest needs: [test] steps: - name: Checkout uses: actions/checkout@v3 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: latest + + - uses: pnpm/action-setup@v2 + name: Install pnpm + id: pnpm-install + with: + version: latest + run_install: true + + - name: Build + run: | + cd webui + pnpm build && zip -r dist.zip dist + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: dist + path: webui/dist.zip + + + draft-release: + runs-on: ubuntu-latest + needs: [test] + if: > + github.event.pull_request.merged == true && + github.event.pull_request.base.ref == 'main' + steps: + + - name: Checkout code + uses: actions/checkout@v2 + + - name: download artifact + uses: actions/download-artifact@v3 + with: + name: dist + path: dist.zip + + - name: Generate Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ github.event.pull_request.title }} + name: 🌟${{ github.event.pull_request.title }} + body: ${{ github.event.pull_request.body }} + draft: true + prerelease: false + files: | + dist.zip + env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + + build-docker: + runs-on: ubuntu-latest + needs: [test, build-webui] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Create Version info - working-directory: ./src + working-directory: ./backend/src run: | echo "VERSION = '$GITHUB_REF_NAME'" > module/__version__.py - - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -73,6 +133,12 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.ACCESS_TOKEN }} + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: dist + path: backend/dist.zip + - name: Build and push uses: docker/build-push-action@v4 with: diff --git a/.gitignore b/.gitignore index f6222a65..dff85d3d 100644 --- a/.gitignore +++ b/.gitignore @@ -162,18 +162,17 @@ cython_debug/ #.idea/ # Custom -/src/test.py +/backend/src/test.py -/src/module/run_debug.sh -/src/module/debug_run.sh -/src/module/__version__.py -/src/data/ +/backend/src/module/run_debug.sh +/backend/src/module/debug_run.sh +/backend/src/module/__version__.py +/backend/src/data/ /src/module/conf/config_dev.ini test.* .run -/src/templates/ -/src/config/ -/src/debuger.py -/src/dist.zip +/backend/src/templates/ +/backend/src/config/ +/backend/src/dist.zip diff --git a/Dockerfile b/Dockerfile index 7f58121f..9e0f62d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,8 @@ ENV S6_SERVICES_GRACETIME=30000 \ WORKDIR /app -COPY requirements.txt . +COPY backend/requirements.txt . +COPY backend/dist.zip . RUN apk add --no-cache \ bash \ ca-certificates \ @@ -34,9 +35,8 @@ RUN apk add --no-cache \ python3 -m pip install --upgrade pip && \ sed -i '/bcrypt/d' requirements.txt && \ pip install --no-cache-dir -r requirements.txt && \ - # Download WebUI - curl -sL "https://github.com/Rewrite0/Auto_Bangumi_WebUI/releases/latest/download/dist.zip" | busybox unzip -q -d /app - && \ - mv /app/dist /app/templates && \ + # Unzip WebUI \ + unzip dist.zip -d /app/templates && \ # Add user addgroup -S ab -g 911 && \ adduser -S ab -G ab -h /ab -s /bin/bash -u 911 && \ @@ -45,8 +45,8 @@ RUN apk add --no-cache \ /root/.cache \ /tmp/* -COPY --chmod=755 src/. . -COPY --chmod=755 src/docker / +COPY --chmod=755 backend/src/. . +COPY --chmod=755 backend/src/docker / ENTRYPOINT [ "/init" ] diff --git a/webui/.github/workflows/create-release-draft.yaml b/webui/.github/workflows/create-release-draft.yaml deleted file mode 100644 index 329d89aa..00000000 --- a/webui/.github/workflows/create-release-draft.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: Create Release Draft - -on: - push: - tags: - - 'v*.*.*' - -permissions: - contents: write - discussions: write - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version: latest - - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - version: latest - run_install: true - - - name: Build - run: pnpm build && zip -r dist.zip dist - - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - files: dist.zip