From 3eb2f0b14d1cbd11d0ff7e697adca6f980be394f 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 14:33:47 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E4=BF=AE=E5=A4=8D=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20ci=20=E6=B5=81=E7=A8=8B=20(#269)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-binary.yaml | 15 +++++++++++---- Dockerfile | 6 +++--- Justfile | 23 +++++++++++++++-------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-binary.yaml b/.github/workflows/build-binary.yaml index e70052f..d5f5d3b 100644 --- a/.github/workflows/build-binary.yaml +++ b/.github/workflows/build-binary.yaml @@ -26,8 +26,13 @@ jobs: key: ${{ runner.os }}-bun-${{ hashFiles('docs/bun.lockb') }} restore-keys: | ${{ runner.os }}-bun- - - name: Build documentation + - name: Build Frontend run: bun run build + - name: Upload Web Build Artifact + uses: actions/upload-artifact@v4 + with: + name: web-build + path: web/build build: name: Build bili-sync-rs for ${{ matrix.platform.release_for }} needs: build-frontend @@ -63,6 +68,11 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v4 + - name: Download Web Build Artifact + uses: actions/download-artifact@v4 + with: + name: web-build + path: web/build - name: Cache dependencies uses: Swatinem/rust-cache@v2 - name: Install musl-tools @@ -79,7 +89,6 @@ jobs: - name: Package as archive shell: bash run: | - cp target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} ${{ matrix.platform.release_for }}-${{ matrix.platform.bin }} cd target/${{ matrix.platform.target }}/release if [[ "${{ matrix.platform.target }}" == "x86_64-pc-windows-msvc" ]]; then 7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} @@ -90,7 +99,5 @@ jobs: uses: actions/upload-artifact@v4 with: name: bili-sync-rs-${{ matrix.platform.release_for }} - # contains raw binary and compressed archive path: | - ${{ github.workspace }}/${{ matrix.platform.release_for }}-${{ matrix.platform.bin }} ${{ github.workspace }}/${{ matrix.platform.name }} diff --git a/Dockerfile b/Dockerfile index d0dab3c..0c2911b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,12 +9,12 @@ RUN apk update && apk add --no-cache \ tzdata \ ffmpeg -COPY ./*-bili-sync-rs ./targets/ +COPY ./bili-sync-rs-Linux-*.tar.gz ./targets/ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ - mv ./targets/Linux-x86_64-bili-sync-rs ./bili-sync-rs; \ + tar xzvf ./targets/bili-sync-rs-Linux-x86_64-musl.tar.gz -C ./; \ else \ - mv ./targets/Linux-aarch64-bili-sync-rs ./bili-sync-rs; \ + tar xzvf ./targets/bili-sync-rs-Linux-aarch64-musl.tar.gz -C ./; \ fi RUN rm -rf ./targets && chmod +x ./bili-sync-rs diff --git a/Justfile b/Justfile index 6f50321..7e1c32b 100644 --- a/Justfile +++ b/Justfile @@ -1,17 +1,24 @@ clean: - rm -rf ./*-bili-sync-rs + rm -rf ./bili-sync-rs-Linux*.tar.gz -build: +build-frontend: + cd ./web && bun run build && cd .. + +build: build-frontend cargo build --target x86_64-unknown-linux-musl --release +build-debug: build-frontend + cargo build --target x86_64-unknown-linux-musl + build-docker: build - cp target/x86_64-unknown-linux-musl/release/bili-sync-rs ./Linux-x86_64-bili-sync-rs + tar czvf ./bili-sync-rs-Linux-x86_64-musl.tar.gz -C ./target/x86_64-unknown-linux-musl/release/ ./bili-sync-rs docker build . -t bili-sync-rs-local --build-arg="TARGETPLATFORM=linux/amd64" just clean -run: - cd ./web && bun run build && cd .. - cargo run +build-docker-debug: build-debug + tar czvf ./bili-sync-rs-Linux-x86_64-musl.tar.gz -C ./target/x86_64-unknown-linux-musl/debug/ ./bili-sync-rs + docker build . -t bili-sync-rs-local --build-arg="TARGETPLATFORM=linux/amd64" + just clean -debug: - just run \ No newline at end of file +debug: build-frontend + cargo run