Bump version to 0.1.7 #9
Workflow file for this run
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: Build precompiled NIFs | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| jobs: | |
| create_release: | |
| name: Create GitHub release | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Create release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: gh release create "${{ github.ref_name }}" --repo "${{ github.repository }}" --title "${{ github.ref_name }}" --draft | |
| build_release: | |
| name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }}${{ matrix.job.variant && format(' ({0})', matrix.job.variant) || '' }} | |
| needs: create_release | |
| runs-on: ${{ matrix.job.os }} | |
| permissions: | |
| contents: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| nif: ["2.15"] | |
| job: | |
| - { target: aarch64-apple-darwin, os: macos-14 } | |
| - { target: aarch64-unknown-linux-gnu, os: ubuntu-22.04, use-cross: true } | |
| - { target: x86_64-apple-darwin, os: macos-14, rustflags: "-C target-cpu=x86-64" } | |
| - { target: x86_64-apple-darwin, os: macos-14, rustflags: "-C target-cpu=x86-64-v2", variant: v2 } | |
| - { target: x86_64-apple-darwin, os: macos-14, rustflags: "-C target-cpu=x86-64-v3", variant: v3 } | |
| - { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04, rustflags: "-C target-cpu=x86-64" } | |
| - { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04, rustflags: "-C target-cpu=x86-64-v2", variant: v2 } | |
| - { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04, rustflags: "-C target-cpu=x86-64-v3", variant: v3 } | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v6 | |
| - name: Extract project version | |
| shell: bash | |
| run: | | |
| echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)" >> $GITHUB_ENV | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| target: ${{ matrix.job.target }} | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| prefix-key: v0-precomp | |
| shared-key: ${{ matrix.job.target }}-${{ matrix.nif }}-${{ matrix.job.variant || 'base' }} | |
| - name: Install cross | |
| if: matrix.job.use-cross | |
| shell: bash | |
| run: cargo install cross --git https://github.com/cross-rs/cross | |
| - name: Build native library | |
| shell: bash | |
| run: | | |
| if [ -n "${{ matrix.job.rustflags }}" ]; then | |
| export RUSTFLAGS="${{ matrix.job.rustflags }}" | |
| fi | |
| if [ "${{ matrix.job.use-cross }}" = "true" ]; then | |
| RUSTLER_NIF_VERSION=${{ matrix.nif }} cross build --release --target ${{ matrix.job.target }} --package torque_nif | |
| else | |
| RUSTLER_NIF_VERSION=${{ matrix.nif }} cargo build --release --target ${{ matrix.job.target }} --package torque_nif | |
| fi | |
| - name: Package artifact | |
| shell: bash | |
| run: | | |
| TARGET=${{ matrix.job.target }} | |
| VERSION=${{ env.PROJECT_VERSION }} | |
| NIF=${{ matrix.nif }} | |
| if [[ "$TARGET" == *"darwin"* ]]; then | |
| LIB_FILE="target/${TARGET}/release/libtorque_nif.dylib" | |
| else | |
| LIB_FILE="target/${TARGET}/release/libtorque_nif.so" | |
| fi | |
| # RustlerPrecompiled expects the file inside the archive to match this name | |
| VARIANT="${{ matrix.job.variant }}" | |
| NIF_NAME="libtorque_nif-v${VERSION}-nif-${NIF}-${TARGET}" | |
| if [ -n "${VARIANT}" ]; then | |
| NIF_NAME="${NIF_NAME}--${VARIANT}" | |
| fi | |
| NIF_NAME="${NIF_NAME}.so" | |
| cp "${LIB_FILE}" "${NIF_NAME}" | |
| ARCHIVE_NAME="${NIF_NAME}.tar.gz" | |
| tar -czf "${ARCHIVE_NAME}" "${NIF_NAME}" | |
| echo "ARCHIVE_NAME=${ARCHIVE_NAME}" >> $GITHUB_ENV | |
| - name: Upload to GitHub release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: gh release upload "${{ github.ref_name }}" "${{ env.ARCHIVE_NAME }}" --clobber |