Release Binaries #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Binaries | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Release tag to build binaries for (e.g., v0.6.11.2)' | |
| required: true | |
| type: string | |
| env: | |
| CARGO_INCREMENTAL: 0 | |
| CARGO_NET_RETRY: 10 | |
| RUST_BACKTRACE: short | |
| RUSTUP_MAX_RETRIES: 10 | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| - os: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ inputs.tag }} | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install OpenSSL (Ubuntu x86_64) | |
| if: matrix.target == 'x86_64-unknown-linux-gnu' | |
| run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config | |
| - name: Install cross (Linux aarch64) | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: cargo install cross --git https://github.com/cross-rs/cross | |
| - name: Cache Dependencies | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ matrix.target }} | |
| - name: Build (native) | |
| if: matrix.target != 'aarch64-unknown-linux-gnu' | |
| run: cargo build --release --package prisma-cli --features postgresql,mocking | |
| - name: Build (cross-compile Linux aarch64) | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: cross build --release --package prisma-cli --features postgresql,mocking --target ${{ matrix.target }} | |
| - name: Create zip (macOS/Linux native) | |
| if: matrix.target != 'aarch64-unknown-linux-gnu' | |
| run: | | |
| cd target/release | |
| zip prisma-cli-${{ matrix.target }}.zip prisma | |
| - name: Create zip (Linux cross-compiled) | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| zip prisma-cli-${{ matrix.target }}.zip prisma | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: prisma-cli-${{ matrix.target }} | |
| path: target/**/release/prisma-cli-${{ matrix.target }}.zip | |
| upload-release: | |
| name: Upload to Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Display structure of downloaded files | |
| run: find artifacts -type f -name "*.zip" | |
| - name: Upload release assets | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| for zip in $(find artifacts -type f -name "*.zip"); do | |
| echo "Uploading $zip" | |
| gh release upload ${{ inputs.tag }} "$zip" --repo ${{ github.repository }} --clobber | |
| done |