From 81b2dd372cbd9e9bee9192147c8a6f6b5f119f09 Mon Sep 17 00:00:00 2001 From: rustmailer Date: Wed, 19 Nov 2025 02:23:44 +0800 Subject: [PATCH] update --- .github/workflows/release.yml | 176 ++++++++++++++++++++++++++++++++++ README.md | 0 docker/Dockerfile | 1 - 3 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml create mode 100644 README.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..83e2740 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,176 @@ +name: Release Bichon + +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' +env: + BINARY_NAME: bichon + +permissions: + contents: write + +jobs: + build: + name: Build ${{ matrix.target }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest + - target: x86_64-unknown-linux-musl + os: ubuntu-latest + - target: x86_64-apple-darwin + os: macos-latest + - target: x86_64-pc-windows-msvc + os: windows-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + target: ${{ matrix.target }} + override: true + + - name: Setup Node.js & pnpm + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install pnpm + run: npm install -g pnpm + + - name: Build frontend (web) + working-directory: ./web + run: | + pnpm install + pnpm run build + + - name: Install musl-tools (Linux musl only) + if: matrix.target == 'x86_64-unknown-linux-musl' + run: sudo apt-get update && sudo apt-get install -y musl-tools + + - name: Build Rust backend + run: cargo build --release --features vendored-openssl --target=${{ matrix.target }} + + - name: Strip binary (Linux and macOS) + if: matrix.os != 'windows-latest' + run: | + strip target/${{ matrix.target }}/release/${{ env.BINARY_NAME }} + + - name: Pack artifact (Linux/macOS) + if: matrix.os != 'windows-latest' + shell: bash + run: | + mkdir -p release + BINARY="target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}" + cp README.md LICENSE release/ + cp "$BINARY" release/ + tar -czvf "${{ env.BINARY_NAME }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz" -C release . + mv "${{ env.BINARY_NAME }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz" release/ + + - name: Upload build artifact + if: matrix.os != 'windows-latest' + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.target }} + path: release/${{ env.BINARY_NAME }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz + + - name: Create zip archive (Windows) + if: matrix.os == 'windows-latest' + shell: pwsh + run: | + mkdir -p release + $BINARY = "target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}.exe" + Copy-Item -Path $BINARY -Destination release/ + Copy-Item -Path README.md -Destination release/ + Copy-Item -Path LICENSE -Destination release/ + Compress-Archive -Path release\* -DestinationPath "release/${{ env.BINARY_NAME }}-${{ github.ref_name }}-${{ matrix.target }}.zip" -Force + + - name: Upload build artifact + if: matrix.os == 'windows-latest' + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.target }} + path: release/${{ env.BINARY_NAME }}-${{ github.ref_name }}-${{ matrix.target }}.zip + + release: + name: Create GitHub Release + needs: build + runs-on: ubuntu-latest + + steps: + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + pattern: "*" + merge-multiple: true + + - name: Flatten artifacts + run: | + mkdir -p artifacts + find artifacts -type f -name "*.zip" -exec mv {} artifacts/ \; + find artifacts -type f -name "*.tar.gz" -exec mv {} artifacts/ \; + + - name: Debug list files + run: ls -R artifacts + + - name: Generate SHA256 checksums + run: | + cd artifacts + sha256sum * > SHA256SUMS.txt + cat SHA256SUMS.txt + + - name: Publish GitHub Release + uses: softprops/action-gh-release@v2 + with: + name: "Release ${{ github.ref_name }}" + generate_release_notes: true + files: | + artifacts/* + docker: + name: Build and Push Docker Image + needs: [build, release] + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download Linux musl artifact + uses: actions/download-artifact@v4 + with: + name: x86_64-unknown-linux-musl + path: artifacts + + - name: Prepare Docker context + run: | + tar -xzf artifacts/${{ env.BINARY_NAME }}-*.tar.gz -C docker + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + 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: ./docker + push: true + tags: | + rustmailer/bichon:${{ github.ref_name }} + rustmailer/bichon:latest + build-args: | + CRATE_VERSION=${{ github.ref_name }} + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/docker/Dockerfile b/docker/Dockerfile index 302635d..8df0308 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -13,7 +13,6 @@ WORKDIR /opt/bichon # Copy compiled binary (ensure it's statically linked or compatible with bullseye) COPY bichon /opt/bichon/bichon COPY LICENSE /opt/bichon/ -COPY license.html /opt/bichon/ # Set proper permissions RUN chmod +x /opt/bichon/bichon