|
| 1 | +name: Release Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - 'src/**' |
| 8 | + - 'Cargo.toml' |
| 9 | + - 'Cargo.lock' |
| 10 | + - '.github/workflows/release-build.yml' |
| 11 | + |
| 12 | +env: |
| 13 | + CARGO_TERM_COLOR: always |
| 14 | + |
| 15 | +jobs: |
| 16 | + # Fetch contributor list via StackQL and upload as a workflow artifact so all |
| 17 | + # matrix build jobs can embed it into the binary at compile time. |
| 18 | + prepare: |
| 19 | + name: Prepare |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout repository |
| 23 | + uses: actions/checkout@v6 |
| 24 | + |
| 25 | + - name: Fetch contributors |
| 26 | + id: get-contributors |
| 27 | + uses: stackql/stackql-exec@v2.2.3 |
| 28 | + with: |
| 29 | + query_file_path: ci-scripts/get-contributors.iql |
| 30 | + query_output: csv |
| 31 | + |
| 32 | + - name: Save contributors CSV |
| 33 | + run: echo "${{ steps.get-contributors.outputs.stackql-query-results }}" > contributors.csv |
| 34 | + |
| 35 | + - name: Upload contributors artifact |
| 36 | + uses: actions/upload-artifact@v4 |
| 37 | + with: |
| 38 | + name: contributors-csv |
| 39 | + path: contributors.csv |
| 40 | + |
| 41 | + build: |
| 42 | + name: Build (${{ matrix.target }}) |
| 43 | + needs: prepare |
| 44 | + strategy: |
| 45 | + fail-fast: false |
| 46 | + matrix: |
| 47 | + include: |
| 48 | + - target: x86_64-unknown-linux-gnu |
| 49 | + os: ubuntu-latest |
| 50 | + artifact-name: stackql-deploy-linux-x86_64 |
| 51 | + archive: tar.gz |
| 52 | + use-cross: false |
| 53 | + |
| 54 | + - target: aarch64-unknown-linux-gnu |
| 55 | + os: ubuntu-latest |
| 56 | + artifact-name: stackql-deploy-linux-arm64 |
| 57 | + archive: tar.gz |
| 58 | + use-cross: true |
| 59 | + |
| 60 | + - target: x86_64-pc-windows-msvc |
| 61 | + os: windows-latest |
| 62 | + artifact-name: stackql-deploy-windows-x86_64 |
| 63 | + archive: zip |
| 64 | + use-cross: false |
| 65 | + |
| 66 | + - target: aarch64-apple-darwin |
| 67 | + os: macos-latest |
| 68 | + artifact-name: stackql-deploy-macos-arm64 |
| 69 | + archive: tar.gz |
| 70 | + use-cross: false |
| 71 | + |
| 72 | + - target: x86_64-apple-darwin |
| 73 | + os: macos-13 |
| 74 | + artifact-name: stackql-deploy-macos-x86_64 |
| 75 | + archive: tar.gz |
| 76 | + use-cross: false |
| 77 | + |
| 78 | + runs-on: ${{ matrix.os }} |
| 79 | + |
| 80 | + steps: |
| 81 | + - name: Checkout repository |
| 82 | + uses: actions/checkout@v6 |
| 83 | + |
| 84 | + - name: Download contributors CSV |
| 85 | + uses: actions/download-artifact@v4 |
| 86 | + with: |
| 87 | + name: contributors-csv |
| 88 | + |
| 89 | + - name: Install Rust toolchain |
| 90 | + uses: dtolnay/rust-toolchain@stable |
| 91 | + with: |
| 92 | + targets: ${{ matrix.target }} |
| 93 | + |
| 94 | + - name: Cache dependencies |
| 95 | + uses: Swatinem/rust-cache@v2 |
| 96 | + with: |
| 97 | + key: ${{ matrix.target }} |
| 98 | + |
| 99 | + - name: Install cross |
| 100 | + if: matrix.use-cross == true |
| 101 | + run: cargo install cross --git https://github.com/cross-rs/cross |
| 102 | + |
| 103 | + - name: Build (cross) |
| 104 | + if: matrix.use-cross == true |
| 105 | + run: cross build --release --target ${{ matrix.target }} |
| 106 | + |
| 107 | + - name: Build (native) |
| 108 | + if: matrix.use-cross == false |
| 109 | + run: cargo build --release --target ${{ matrix.target }} |
| 110 | + |
| 111 | + # Strip Linux and macOS binaries to reduce size. |
| 112 | + # Cross-compiled ARM64 Linux is stripped by cross automatically. |
| 113 | + - name: Strip binary (native Linux / macOS) |
| 114 | + if: matrix.os != 'windows-latest' && matrix.use-cross == false |
| 115 | + run: strip target/${{ matrix.target }}/release/stackql-deploy |
| 116 | + |
| 117 | + - name: Package (tar.gz) |
| 118 | + if: matrix.archive == 'tar.gz' |
| 119 | + run: | |
| 120 | + tar -czf ${{ matrix.artifact-name }}.tar.gz \ |
| 121 | + -C target/${{ matrix.target }}/release stackql-deploy |
| 122 | +
|
| 123 | + - name: Package (zip) — Windows |
| 124 | + if: matrix.archive == 'zip' |
| 125 | + shell: pwsh |
| 126 | + run: | |
| 127 | + Compress-Archive ` |
| 128 | + -Path target/${{ matrix.target }}/release/stackql-deploy.exe ` |
| 129 | + -DestinationPath ${{ matrix.artifact-name }}.zip |
| 130 | +
|
| 131 | + - name: Upload binary artifact |
| 132 | + uses: actions/upload-artifact@v4 |
| 133 | + with: |
| 134 | + name: ${{ matrix.artifact-name }} |
| 135 | + path: ${{ matrix.artifact-name }}.* |
| 136 | + if-no-files-found: error |
0 commit comments