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: aarch64-unknown-linux-gnu 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: Install cross compiler for aarch64 if: matrix.target == 'aarch64-unknown-linux-gnu' run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu - 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 (amd64) uses: actions/download-artifact@v4 with: name: x86_64-unknown-linux-musl path: artifacts/amd64 - name: Download Linux artifact (arm64) uses: actions/download-artifact@v4 with: name: aarch64-unknown-linux-gnu path: artifacts/arm64 - name: Prepare Docker context run: | mkdir -p docker/amd64 docker/arm64 tar -xzf artifacts/amd64/${{ env.BINARY_NAME }}-*.tar.gz -C docker/amd64 tar -xzf artifacts/arm64/${{ env.BINARY_NAME }}-*.tar.gz -C docker/arm64 - 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 platforms: linux/amd64,linux/arm64 push: true tags: | rustmailer/bichon:${{ github.ref_name }} rustmailer/bichon:latest build-args: | CRATE_VERSION=${{ github.ref_name }}