|
| 1 | +name: precompile |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + linux: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + env: |
| 13 | + MIX_ENV: prod |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + include: |
| 18 | + - elixir: "1.17.x" |
| 19 | + otp: "26.x" |
| 20 | + - elixir: "1.17.x" |
| 21 | + otp: "27.x" |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - uses: erlef/setup-beam@v1 |
| 26 | + with: |
| 27 | + otp-version: ${{ matrix.otp }} |
| 28 | + elixir-version: ${{ matrix.elixir }} |
| 29 | + |
| 30 | + - name: Cache musl cross-compilers |
| 31 | + id: cache-musl |
| 32 | + uses: actions/cache@v4 |
| 33 | + with: |
| 34 | + path: | |
| 35 | + x86_64-linux-musl-cross |
| 36 | + aarch64-linux-musl-cross |
| 37 | + key: musl-${{ runner.os }}-build |
| 38 | + |
| 39 | + - if: steps.cache-musl.outputs.cache-hit != 'true' |
| 40 | + name: Install musl cross-compilers |
| 41 | + run: | |
| 42 | + curl -fsSL https://more.musl.cc/11.2.1/x86_64-linux-musl/x86_64-linux-musl-cross.tgz | tar -xz |
| 43 | + curl -fsSL https://more.musl.cc/11.2.1/x86_64-linux-musl/aarch64-linux-musl-cross.tgz | tar -xz |
| 44 | +
|
| 45 | + - name: Install GNU cross-compilers |
| 46 | + run: | |
| 47 | + sudo apt-get update |
| 48 | + sudo apt-get install -y gcc make curl tar \ |
| 49 | + gcc-aarch64-linux-gnu \ |
| 50 | + gcc-arm-linux-gnueabihf |
| 51 | + echo "$PWD/x86_64-linux-musl-cross/bin" >> $GITHUB_PATH |
| 52 | + echo "$PWD/aarch64-linux-musl-cross/bin" >> $GITHUB_PATH |
| 53 | +
|
| 54 | + - run: mix deps.get |
| 55 | + |
| 56 | + - name: Pre-compile NIF artefacts |
| 57 | + run: | |
| 58 | + export ELIXIR_MAKE_CACHE_DIR=$PWD/cache |
| 59 | + mkdir -p "$ELIXIR_MAKE_CACHE_DIR" |
| 60 | + mix elixir_make.precompile |
| 61 | +
|
| 62 | + - uses: softprops/action-gh-release@v2 |
| 63 | + if: startsWith(github.ref, 'refs/tags/') |
| 64 | + with: |
| 65 | + files: cache/*.tar.gz |
| 66 | + |
| 67 | + macos: |
| 68 | + runs-on: macos-latest |
| 69 | + env: |
| 70 | + MIX_ENV: prod |
| 71 | + strategy: |
| 72 | + fail-fast: false |
| 73 | + matrix: |
| 74 | + include: |
| 75 | + - elixir: "1.17.x" |
| 76 | + otp: "26.x" |
| 77 | + - elixir: "1.17.x" |
| 78 | + otp: "27.x" |
| 79 | + steps: |
| 80 | + - uses: actions/checkout@v4 |
| 81 | + |
| 82 | + - uses: erlef/setup-beam@v1 |
| 83 | + with: |
| 84 | + otp-version: ${{ matrix.otp }} |
| 85 | + elixir-version: ${{ matrix.elixir }} |
| 86 | + |
| 87 | + - run: mix deps.get |
| 88 | + |
| 89 | + - name: Pre-compile NIF artefacts (universal — x86_64 + arm64) |
| 90 | + run: | |
| 91 | + export ELIXIR_MAKE_CACHE_DIR=$PWD/cache |
| 92 | + mkdir -p "$ELIXIR_MAKE_CACHE_DIR" |
| 93 | + mix elixir_make.precompile |
| 94 | +
|
| 95 | + - uses: softprops/action-gh-release@v2 |
| 96 | + if: startsWith(github.ref, 'refs/tags/') |
| 97 | + with: |
| 98 | + files: cache/*.tar.gz |
0 commit comments