|
| 1 | +name: Build NIF |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - "native/**" |
| 9 | + - ".github/workflows/release.yml" |
| 10 | + tags: |
| 11 | + - "*" |
| 12 | + |
| 13 | +jobs: |
| 14 | + build-release: |
| 15 | + name: NIF |
| 16 | + runs-on: ${{ matrix.job.os }} |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + nif: |
| 21 | + - 2.15 |
| 22 | + job: |
| 23 | + - { target: aarch64-apple-darwin, os: macos-11 } |
| 24 | + - { target: aarch64-unknown-linux-gnu, os: ubuntu-20.04, use-cross: true } |
| 25 | + - { target: aarch64-unknown-linux-musl, os: ubuntu-20.04, rustflags: "-C target-feature=-crt-static", use-cross: true } |
| 26 | + - { target: x86_64-apple-darwin, os: macos-11 } |
| 27 | + - { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04, rustflags: "-C target-feature=+fxsr,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+fma" } |
| 28 | + - { target: x86_64-unknown-linux-musl, os: ubuntu-20.04, rustflags: "-C target-feature=-crt-static", use-cross: true } |
| 29 | + steps: |
| 30 | + - name: Checkout Repository |
| 31 | + uses: actions/checkout@v3 |
| 32 | + |
| 33 | + - name: Extract Version |
| 34 | + run: | |
| 35 | + echo "VERSION=$(awk -F '"' '/version/ {print $2}' mix.exs)" >> $GITHUB_ENV |
| 36 | +
|
| 37 | + - name: Rustc Flags |
| 38 | + if: ${{ matrix.job.rustflags }} |
| 39 | + run: | |
| 40 | + echo "RUSTFLAGS=${{ matrix.job.rustflags }}" >> $GITHUB_ENV |
| 41 | +
|
| 42 | + - name: Add target |
| 43 | + run: | |
| 44 | + rustup target add ${{ matrix.job.target }} |
| 45 | +
|
| 46 | + - uses: Swatinem/rust-cache@v2 |
| 47 | + with: |
| 48 | + prefix-key: sql-parser |
| 49 | + shared-key: ${{ matrix.job.target }}-${{ matrix.nif }} |
| 50 | + workspaces: | |
| 51 | + native/sql_parser |
| 52 | +
|
| 53 | + - name: Build NIFs |
| 54 | + id: build-crate |
| 55 | + uses: philss/rustler-precompiled-action@v1.1.0 |
| 56 | + with: |
| 57 | + project-name: sql_parser |
| 58 | + project-version: ${{ env.VERSION }} |
| 59 | + target: ${{ matrix.job.target }} |
| 60 | + nif-version: ${{ matrix.nif }} |
| 61 | + use-cross: ${{ matrix.job.use-cross }} |
| 62 | + cross-version: ${{ matrix.job.cross-version || 'v0.2.4' }} |
| 63 | + project-dir: native/sql_parser |
| 64 | + cargo-args: ${{ matrix.job.cargo-args }} |
| 65 | + variant: ${{ matrix.job.variant }} |
| 66 | + |
| 67 | + - name: Upload Artifacts |
| 68 | + uses: actions/upload-artifact@v3 |
| 69 | + with: |
| 70 | + name: ${{ steps.build-crate.outputs.file-name }} |
| 71 | + path: ${{ steps.build-crate.outputs.file-path }} |
| 72 | + |
| 73 | + - name: Publish Archives |
| 74 | + if: startsWith(github.ref, 'refs/tags/') |
| 75 | + uses: softprops/action-gh-release@v1 |
| 76 | + with: |
| 77 | + files: | |
| 78 | + ${{ steps.build-crate.outputs.file-path }} |
0 commit comments