|
| 1 | +amends "https://cdn.jsdelivr.net/gh/Paradox460/pkl-gha@9a8ef2e658223fd7cb08a68b5a63a44ec6566166/Workflow.pkl" |
| 2 | +import "https://cdn.jsdelivr.net/gh/Paradox460/pkl-gha@9a8ef2e658223fd7cb08a68b5a63a44ec6566166/Action.pkl" |
| 3 | + |
| 4 | +import "https://cdn.jsdelivr.net/gh/paradox460/shared-pkl@0c33020a8e18437752765a0483aeefbf3bb03fe5/gha/mise.pkl" |
| 5 | + |
| 6 | +name = "Build and release NIFs" |
| 7 | + |
| 8 | +on { |
| 9 | + push { |
| 10 | + tags = new Listing { "v*" } |
| 11 | + } |
| 12 | + workflow_dispatch {} |
| 13 | +} |
| 14 | + |
| 15 | +local job_matrix = new Dynamic { |
| 16 | + os = "ubuntu-22.04" |
| 17 | + `use-cross`= true |
| 18 | +} |
| 19 | + |
| 20 | +jobs { |
| 21 | + ["build_release"] = new { |
| 22 | + name = "NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }})" |
| 23 | + `runs-on` = "${{ matrix.job.os }}" |
| 24 | + strategy = new { |
| 25 | + `fail-fast` = false |
| 26 | + matrix = new { |
| 27 | + ["nif"] = new Listing { "2.15" } |
| 28 | + ["job"] = new Listing { |
| 29 | + (job_matrix) { target = "arm-unknown-linux-gnueabihf" } |
| 30 | + (job_matrix) { target = "aarch64-unknown-linux-gnu" } |
| 31 | + (job_matrix) { target = "aarch64-unknown-linux-musl" } |
| 32 | + (job_matrix) { target = "riscv64gc-unknown-linux-gnu" } |
| 33 | + (job_matrix) { target = "x86_64-unknown-linux-musl" } |
| 34 | + (job_matrix) { |
| 35 | + target = "aarch64-apple-darwin" |
| 36 | + os = "macos-13" |
| 37 | + `use-cross` = null |
| 38 | + } |
| 39 | + (job_matrix) { |
| 40 | + target = "x86_64-apple-darwin" |
| 41 | + os = "macos-13" |
| 42 | + `use-cross` = null |
| 43 | + } |
| 44 | + (job_matrix) { |
| 45 | + target = "x86_64-unknown-linux-gnu" |
| 46 | + `use-cross` = null |
| 47 | + } |
| 48 | + (job_matrix) { |
| 49 | + target = "x86_64-pc-windows-gnu" |
| 50 | + os = "windows-2019" |
| 51 | + `use-cross` = null |
| 52 | + } |
| 53 | + (job_matrix) { |
| 54 | + target = "x86_64-pc-windows-msvc" |
| 55 | + os = "windows-2019" |
| 56 | + `use-cross` = null |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | + permissions = new { |
| 62 | + contents = "write" |
| 63 | + `id-token` = "write" |
| 64 | + attestations = "write" |
| 65 | + } |
| 66 | + steps { |
| 67 | + Action.checkout |
| 68 | + new { |
| 69 | + name = "Extract Project Version" |
| 70 | + shell = "bash" |
| 71 | + run = #"echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)" >> $GITHUB_ENV"# |
| 72 | + } |
| 73 | + new { |
| 74 | + name = "Install rust toolchain" |
| 75 | + uses = "dtolnay/rust-toolchain@stable" |
| 76 | + with { |
| 77 | + ["toolchain"] = "stable" |
| 78 | + ["target"] = "${{ matrix.job.target }}" |
| 79 | + } |
| 80 | + } |
| 81 | + new { |
| 82 | + name = "Build" |
| 83 | + id = "build-crate" |
| 84 | + uses = "philss/rustler-precompiled-action@v1.1.4" |
| 85 | + with { |
| 86 | + ["project-name"] = "djot_nif" |
| 87 | + ["project-version"] = "${{ env.PROJECT_VERSION }}" |
| 88 | + ["target"] = "${{ matrix.job.target }}" |
| 89 | + ["nif-version"] = "${{ matrix.nif }}" |
| 90 | + ["use-cross"] = "${{ matrix.job.use-cross }}" |
| 91 | + ["project-dir"] = "native/djot_nif" |
| 92 | + } |
| 93 | + } |
| 94 | + new { |
| 95 | + name = "Artifact attestation" |
| 96 | + uses = "actions/attest-build-provenance@v1" |
| 97 | + with { |
| 98 | + ["subject-path"] = "${{ steps.build-crate.outputs.file-path }}" |
| 99 | + } |
| 100 | + } |
| 101 | + (Action.uploadArtitact) { |
| 102 | + name = "${{ steps.build-crate.outputs.file-name }}" |
| 103 | + path = "${{ steps.build-crate.outputs.file-path }}" |
| 104 | + } |
| 105 | + new { |
| 106 | + name = "Publish archives and packages" |
| 107 | + uses = "softprops/action-gh-release@v2" |
| 108 | + with { |
| 109 | + ["files"] = "${{ steps.build-crate.outputs.file-path }}" |
| 110 | + } |
| 111 | + `if` = "startsWith(github.ref, 'refs/tags/')" |
| 112 | + } |
| 113 | + } |
| 114 | + } |
| 115 | +} |
0 commit comments