From 42272b1294c9d06e82a555e2f7b8b15cf7e9cc12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=80=E1=B4=8D=E1=B4=9B=E1=B4=8F=E1=B4=80=E1=B4=87?= =?UTF-8?q?=CA=80?= Date: Wed, 19 Feb 2025 04:21:33 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E8=B0=83=E6=95=B4=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=B5=81=EF=BC=8C=E5=9C=A8=20commit=20=E6=97=B6=E5=90=8C?= =?UTF-8?q?=E6=A0=B7=E6=9E=84=E5=BB=BA=20binary=20(#266)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{release.yaml => build-binary.yaml} | 89 ++++++------------- .../workflows/{doc.yaml => build-doc.yaml} | 5 +- .github/workflows/commit-build.yaml | 10 +++ .../workflows/{check.yaml => pr-check.yaml} | 0 .github/workflows/release-build.yaml | 78 ++++++++++++++++ 5 files changed, 119 insertions(+), 63 deletions(-) rename .github/workflows/{release.yaml => build-binary.yaml} (59%) rename .github/workflows/{doc.yaml => build-doc.yaml} (94%) create mode 100644 .github/workflows/commit-build.yaml rename .github/workflows/{check.yaml => pr-check.yaml} (100%) create mode 100644 .github/workflows/release-build.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/build-binary.yaml similarity index 59% rename from .github/workflows/release.yaml rename to .github/workflows/build-binary.yaml index 617850b..e70052f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/build-binary.yaml @@ -1,13 +1,36 @@ -name: Build Binary And Release +name: Build Binary on: - push: - tags: - - v* + workflow_call: jobs: + build-frontend: + name: Build frontend + runs-on: ubuntu-20.04 + defaults: + run: + working-directory: web + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Setup bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + - name: Install dependencies + run: bun install --frozen-lockfile + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ~/.bun/install/cache + key: ${{ runner.os }}-bun-${{ hashFiles('docs/bun.lockb') }} + restore-keys: | + ${{ runner.os }}-bun- + - name: Build documentation + run: bun run build build: - name: Release for ${{ matrix.platform.release_for }} + name: Build bili-sync-rs for ${{ matrix.platform.release_for }} + needs: build-frontend runs-on: ${{ matrix.platform.os }} strategy: matrix: @@ -37,7 +60,6 @@ jobs: target: x86_64-pc-windows-msvc bin: bili-sync-rs.exe name: bili-sync-rs-Windows-x86_64.zip - steps: - name: Checkout repo uses: actions/checkout@v4 @@ -72,58 +94,3 @@ jobs: path: | ${{ github.workspace }}/${{ matrix.platform.release_for }}-${{ matrix.platform.bin }} ${{ github.workspace }}/${{ matrix.platform.name }} - release: - name: Create GitHub Release & Docker Image - needs: build - runs-on: ubuntu-20.04 - permissions: - contents: write - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - name: Download release artifact - uses: actions/download-artifact@v4 - with: - merge-multiple: true - - name: Publish GitHub release - uses: softprops/action-gh-release@v2 - with: - files: bili-sync-rs* - tag_name: ${{ github.ref_name }} - draft: true - - name: Docker Meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ secrets.DOCKERHUB_USERNAME }}/bili-sync-rs - tags: | - type=raw,value=latest - type=raw,value=${{ github.ref_name }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - file: Dockerfile - platforms: | - linux/amd64 - linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha, scope=${{ github.workflow }} - cache-to: type=gha, scope=${{ github.workflow }} - - name: Update DockerHub description - uses: peter-evans/dockerhub-description@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - repository: ${{ secrets.DOCKERHUB_USERNAME }}/bili-sync-rs diff --git a/.github/workflows/doc.yaml b/.github/workflows/build-doc.yaml similarity index 94% rename from .github/workflows/doc.yaml rename to .github/workflows/build-doc.yaml index cd17f2b..b12956a 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/build-doc.yaml @@ -1,13 +1,14 @@ -name: Build Docs +name: Build Main Docs on: push: + branches: + - main paths: - 'docs/**' jobs: doc: - if: ${{ github.ref == 'refs/heads/main' }} name: Build documentation runs-on: ubuntu-latest defaults: diff --git a/.github/workflows/commit-build.yaml b/.github/workflows/commit-build.yaml new file mode 100644 index 0000000..91c89da --- /dev/null +++ b/.github/workflows/commit-build.yaml @@ -0,0 +1,10 @@ +name: Build Main Binary + +on: + push: + branches: + - main + +jobs: + build-binary: + uses: amtoaer/bili-sync/.github/workflows/build-binary.yaml@main diff --git a/.github/workflows/check.yaml b/.github/workflows/pr-check.yaml similarity index 100% rename from .github/workflows/check.yaml rename to .github/workflows/pr-check.yaml diff --git a/.github/workflows/release-build.yaml b/.github/workflows/release-build.yaml new file mode 100644 index 0000000..cdc27ad --- /dev/null +++ b/.github/workflows/release-build.yaml @@ -0,0 +1,78 @@ +name: Build Main Binary And Release + +on: + push: + tags: + - v* + +jobs: + build-binary: + uses: amtoaer/bili-sync/.github/workflows/build-binary.yaml@main + github-release: + name: Create GitHub Release + needs: build-binary + runs-on: ubuntu-20.04 + permissions: + contents: write + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Download release artifact + uses: actions/download-artifact@v4 + with: + merge-multiple: true + - name: Publish GitHub release + uses: softprops/action-gh-release@v2 + with: + files: bili-sync-rs* + tag_name: ${{ github.ref_name }} + draft: true + docker-release: + name: Create Docker Image + needs: build-binary + runs-on: ubuntu-20.04 + permissions: + contents: write + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Download release artifact + uses: actions/download-artifact@v4 + with: + merge-multiple: true + - name: Docker Meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/bili-sync-rs + tags: | + type=raw,value=latest + type=raw,value=${{ github.ref_name }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + platforms: | + linux/amd64 + linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha, scope=${{ github.workflow }} + cache-to: type=gha, scope=${{ github.workflow }} + - name: Update DockerHub description + uses: peter-evans/dockerhub-description@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + repository: ${{ secrets.DOCKERHUB_USERNAME }}/bili-sync-rs