ci: 修复并优化 ci 流程 (#269)

This commit is contained in:
ᴀᴍᴛᴏᴀᴇʀ
2025-02-19 14:33:47 +08:00
committed by GitHub
parent 42272b1294
commit 3eb2f0b14d
3 changed files with 29 additions and 15 deletions

View File

@@ -26,8 +26,13 @@ jobs:
key: ${{ runner.os }}-bun-${{ hashFiles('docs/bun.lockb') }} key: ${{ runner.os }}-bun-${{ hashFiles('docs/bun.lockb') }}
restore-keys: | restore-keys: |
${{ runner.os }}-bun- ${{ runner.os }}-bun-
- name: Build documentation - name: Build Frontend
run: bun run build run: bun run build
- name: Upload Web Build Artifact
uses: actions/upload-artifact@v4
with:
name: web-build
path: web/build
build: build:
name: Build bili-sync-rs for ${{ matrix.platform.release_for }} name: Build bili-sync-rs for ${{ matrix.platform.release_for }}
needs: build-frontend needs: build-frontend
@@ -63,6 +68,11 @@ jobs:
steps: steps:
- name: Checkout repo - name: Checkout repo
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Download Web Build Artifact
uses: actions/download-artifact@v4
with:
name: web-build
path: web/build
- name: Cache dependencies - name: Cache dependencies
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
- name: Install musl-tools - name: Install musl-tools
@@ -79,7 +89,6 @@ jobs:
- name: Package as archive - name: Package as archive
shell: bash shell: bash
run: | run: |
cp target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} ${{ matrix.platform.release_for }}-${{ matrix.platform.bin }}
cd target/${{ matrix.platform.target }}/release cd target/${{ matrix.platform.target }}/release
if [[ "${{ matrix.platform.target }}" == "x86_64-pc-windows-msvc" ]]; then if [[ "${{ matrix.platform.target }}" == "x86_64-pc-windows-msvc" ]]; then
7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} 7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
@@ -90,7 +99,5 @@ jobs:
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: bili-sync-rs-${{ matrix.platform.release_for }} name: bili-sync-rs-${{ matrix.platform.release_for }}
# contains raw binary and compressed archive
path: | path: |
${{ github.workspace }}/${{ matrix.platform.release_for }}-${{ matrix.platform.bin }}
${{ github.workspace }}/${{ matrix.platform.name }} ${{ github.workspace }}/${{ matrix.platform.name }}

View File

@@ -9,12 +9,12 @@ RUN apk update && apk add --no-cache \
tzdata \ tzdata \
ffmpeg ffmpeg
COPY ./*-bili-sync-rs ./targets/ COPY ./bili-sync-rs-Linux-*.tar.gz ./targets/
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ 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 \ else \
mv ./targets/Linux-aarch64-bili-sync-rs ./bili-sync-rs; \ tar xzvf ./targets/bili-sync-rs-Linux-aarch64-musl.tar.gz -C ./; \
fi fi
RUN rm -rf ./targets && chmod +x ./bili-sync-rs RUN rm -rf ./targets && chmod +x ./bili-sync-rs

View File

@@ -1,17 +1,24 @@
clean: 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 cargo build --target x86_64-unknown-linux-musl --release
build-debug: build-frontend
cargo build --target x86_64-unknown-linux-musl
build-docker: build 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" docker build . -t bili-sync-rs-local --build-arg="TARGETPLATFORM=linux/amd64"
just clean just clean
run: build-docker-debug: build-debug
cd ./web && bun run build && cd .. tar czvf ./bili-sync-rs-Linux-x86_64-musl.tar.gz -C ./target/x86_64-unknown-linux-musl/debug/ ./bili-sync-rs
cargo run docker build . -t bili-sync-rs-local --build-arg="TARGETPLATFORM=linux/amd64"
just clean
debug: debug: build-frontend
just run cargo run