|
| 1 | +# Release Workflow - Build and publish release artifacts |
| 2 | +name: Release |
| 3 | + |
| 4 | +permissions: |
| 5 | + contents: write |
| 6 | + |
| 7 | +on: |
| 8 | + release: |
| 9 | + types: [published] |
| 10 | + |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + name: Test on ${{ matrix.os }} |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Setup Zig |
| 23 | + uses: mlugg/setup-zig@v2 |
| 24 | + with: |
| 25 | + version: 0.15.0 |
| 26 | + |
| 27 | + - name: Run Tests |
| 28 | + run: zig build test |
| 29 | + |
| 30 | + build-library: |
| 31 | + name: Build Library (${{ matrix.target }}) |
| 32 | + needs: test |
| 33 | + runs-on: ubuntu-latest |
| 34 | + strategy: |
| 35 | + matrix: |
| 36 | + target: |
| 37 | + - x86_64-windows |
| 38 | + - x86-windows |
| 39 | + - x86_64-linux |
| 40 | + - x86-linux |
| 41 | + - aarch64-linux |
| 42 | + - x86_64-macos |
| 43 | + - aarch64-macos |
| 44 | + - x86_64-freestanding |
| 45 | + - aarch64-freestanding |
| 46 | + steps: |
| 47 | + - name: Checkout |
| 48 | + uses: actions/checkout@v4 |
| 49 | + |
| 50 | + - name: Setup Zig |
| 51 | + uses: mlugg/setup-zig@v2 |
| 52 | + with: |
| 53 | + version: 0.15.0 |
| 54 | + |
| 55 | + - name: Build Library |
| 56 | + run: zig build -Doptimize=ReleaseSafe -Dtarget=${{ matrix.target }} |
| 57 | + |
| 58 | + - name: Rename Artifact (Windows) |
| 59 | + if: contains(matrix.target, 'windows') |
| 60 | + run: mv zig-out/lib/tui.lib tui-${{ matrix.target }}.lib |
| 61 | + |
| 62 | + - name: Rename Artifact (Unix) |
| 63 | + if: contains(matrix.target, 'windows') == false |
| 64 | + run: mv zig-out/lib/libtui.a libtui-${{ matrix.target }}.a |
| 65 | + |
| 66 | + - name: Upload Artifact |
| 67 | + run: gh release upload ${{ github.event.release.tag_name }} ${{ contains(matrix.target, 'windows') && format('tui-{0}.lib', matrix.target) || format('libtui-{0}.a', matrix.target) }} |
| 68 | + env: |
| 69 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
| 70 | + |
| 71 | + update-release: |
| 72 | + name: Update Release Description |
| 73 | + needs: test |
| 74 | + runs-on: ubuntu-latest |
| 75 | + steps: |
| 76 | + - name: Checkout |
| 77 | + uses: actions/checkout@v4 |
| 78 | + |
| 79 | + - name: Get Release URL |
| 80 | + id: get_url |
| 81 | + run: echo "url=https://github.com/${{ github.repository }}/archive/refs/tags/${{ github.event.release.tag_name }}.tar.gz" >> $GITHUB_OUTPUT |
| 82 | + |
| 83 | + - name: Setup Zig |
| 84 | + uses: mlugg/setup-zig@v2 |
| 85 | + with: |
| 86 | + version: 0.15.0 |
| 87 | + |
| 88 | + - name: Calculate Hash |
| 89 | + id: calc_hash |
| 90 | + run: | |
| 91 | + zig fetch ${{ steps.get_url.outputs.url }} |
| 92 | + HASH=$(zig fetch --save ${{ steps.get_url.outputs.url }} 2>&1 | grep -oP '(?<=hash: ).*' || echo "run-zig-fetch-to-get-hash") |
| 93 | + echo "hash=$HASH" >> $GITHUB_OUTPUT |
| 94 | +
|
| 95 | + - name: Update Release Body |
| 96 | + uses: softprops/action-gh-release@v1 |
| 97 | + with: |
| 98 | + token: ${{ secrets.GH_TOKEN }} |
| 99 | + body: | |
| 100 | + ${{ github.event.release.body }} |
| 101 | +
|
| 102 | + ## 📦 Installation |
| 103 | +
|
| 104 | + ### Option A — Automatic (Recommended) |
| 105 | +
|
| 106 | + ```bash |
| 107 | + zig fetch --save git+https://github.com/${{ github.repository }}.git#${{ github.event.release.tag_name }} |
| 108 | + ``` |
| 109 | +
|
| 110 | + ### Option B — Using Archive URL |
| 111 | +
|
| 112 | + ```bash |
| 113 | + zig fetch --save https://github.com/${{ github.repository }}/archive/refs/tags/${{ github.event.release.tag_name }}.tar.gz |
| 114 | + ``` |
| 115 | +
|
| 116 | + Then add to `build.zig`: |
| 117 | +
|
| 118 | + ```zig |
| 119 | + const tui_dep = b.dependency("tui", .{ |
| 120 | + .target = target, |
| 121 | + .optimize = optimize, |
| 122 | + }); |
| 123 | + exe.root_module.addImport("tui", tui_dep.module("tui")); |
| 124 | + ``` |
| 125 | +
|
| 126 | + ## 📥 Prebuilt Libraries |
| 127 | +
|
| 128 | + | Platform | Architecture | Download | |
| 129 | + |----------|--------------|----------| |
| 130 | + | Windows | x86_64 | [tui-x86_64-windows.lib](https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/tui-x86_64-windows.lib) | |
| 131 | + | Windows | x86 | [tui-x86-windows.lib](https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/tui-x86-windows.lib) | |
| 132 | + | Linux | x86_64 | [libtui-x86_64-linux.a](https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/libtui-x86_64-linux.a) | |
| 133 | + | Linux | x86 | [libtui-x86-linux.a](https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/libtui-x86-linux.a) | |
| 134 | + | Linux | aarch64 | [libtui-aarch64-linux.a](https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/libtui-aarch64-linux.a) | |
| 135 | + | macOS | x86_64 | [libtui-x86_64-macos.a](https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/libtui-x86_64-macos.a) | |
| 136 | + | macOS | aarch64 | [libtui-aarch64-macos.a](https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/libtui-aarch64-macos.a) | |
| 137 | + | Bare Metal | x86_64 | [libtui-x86_64-freestanding.a](https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/libtui-x86_64-freestanding.a) | |
| 138 | + | Bare Metal | aarch64 | [libtui-aarch64-freestanding.a](https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/libtui-aarch64-freestanding.a) | |
0 commit comments