|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: ['v*'] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: Build (${{ matrix.target }}) |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + defaults: |
| 13 | + run: |
| 14 | + shell: bash |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + include: |
| 18 | + - os: ubuntu-latest |
| 19 | + target: linux-x86_64 |
| 20 | + zig_target: x86_64-linux-musl |
| 21 | + ext: "" |
| 22 | + - os: ubuntu-latest |
| 23 | + target: linux-aarch64 |
| 24 | + zig_target: aarch64-linux-musl |
| 25 | + ext: "" |
| 26 | + - os: ubuntu-latest |
| 27 | + target: linux-riscv64 |
| 28 | + zig_target: riscv64-linux-musl |
| 29 | + ext: "" |
| 30 | + - os: macos-latest |
| 31 | + target: macos-aarch64 |
| 32 | + zig_target: aarch64-macos |
| 33 | + ext: "" |
| 34 | + - os: macos-latest |
| 35 | + target: macos-x86_64 |
| 36 | + zig_target: x86_64-macos |
| 37 | + ext: "" |
| 38 | + - os: windows-latest |
| 39 | + target: windows-x86_64 |
| 40 | + zig_target: x86_64-windows |
| 41 | + ext: ".exe" |
| 42 | + - os: windows-latest |
| 43 | + target: windows-aarch64 |
| 44 | + zig_target: aarch64-windows |
| 45 | + ext: ".exe" |
| 46 | + |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + |
| 50 | + - name: Install Zig 0.15.2 |
| 51 | + uses: mlugg/setup-zig@v2 |
| 52 | + with: |
| 53 | + version: 0.15.2 |
| 54 | + |
| 55 | + - name: Resolve build version |
| 56 | + id: version |
| 57 | + run: | |
| 58 | + if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then |
| 59 | + echo "value=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" |
| 60 | + else |
| 61 | + echo "value=dev" >> "$GITHUB_OUTPUT" |
| 62 | + fi |
| 63 | +
|
| 64 | + - name: Build ReleaseSmall |
| 65 | + run: zig build -Doptimize=ReleaseSmall -Dversion=${{ steps.version.outputs.value }} -Dtarget=${{ matrix.zig_target }} |
| 66 | + |
| 67 | + - name: Upload artifact |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: nullwatch-${{ matrix.target }} |
| 71 | + path: zig-out/bin/nullwatch${{ matrix.ext }} |
| 72 | + |
| 73 | + source: |
| 74 | + name: Prepare source archive |
| 75 | + runs-on: ubuntu-latest |
| 76 | + defaults: |
| 77 | + run: |
| 78 | + shell: bash |
| 79 | + |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@v4 |
| 82 | + |
| 83 | + - name: Create source archive |
| 84 | + run: | |
| 85 | + archive_name="nullwatch-source-${GITHUB_REF_NAME}.tar.gz" |
| 86 | + tar \ |
| 87 | + --exclude='.git' \ |
| 88 | + --exclude='.zig-cache' \ |
| 89 | + --exclude='zig-out' \ |
| 90 | + -czf "/tmp/${archive_name}" . |
| 91 | + mv "/tmp/${archive_name}" . |
| 92 | + echo "ARCHIVE_NAME=${archive_name}" >> "$GITHUB_ENV" |
| 93 | +
|
| 94 | + - name: Upload source archive |
| 95 | + uses: actions/upload-artifact@v4 |
| 96 | + with: |
| 97 | + name: nullwatch-source |
| 98 | + path: ${{ env.ARCHIVE_NAME }} |
| 99 | + |
| 100 | + release: |
| 101 | + needs: [build, source] |
| 102 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 103 | + runs-on: ubuntu-latest |
| 104 | + permissions: |
| 105 | + contents: write |
| 106 | + |
| 107 | + steps: |
| 108 | + - uses: actions/download-artifact@v4 |
| 109 | + |
| 110 | + - name: Rename binaries |
| 111 | + run: | |
| 112 | + mv nullwatch-linux-x86_64/nullwatch nullwatch-linux-x86_64.bin |
| 113 | + mv nullwatch-linux-aarch64/nullwatch nullwatch-linux-aarch64.bin |
| 114 | + mv nullwatch-linux-riscv64/nullwatch nullwatch-linux-riscv64.bin |
| 115 | + mv nullwatch-macos-aarch64/nullwatch nullwatch-macos-aarch64.bin |
| 116 | + mv nullwatch-macos-x86_64/nullwatch nullwatch-macos-x86_64.bin |
| 117 | + mv nullwatch-windows-x86_64/nullwatch.exe nullwatch-windows-x86_64.exe |
| 118 | + mv nullwatch-windows-aarch64/nullwatch.exe nullwatch-windows-aarch64.exe |
| 119 | +
|
| 120 | + - name: Create release |
| 121 | + uses: softprops/action-gh-release@v2 |
| 122 | + with: |
| 123 | + files: | |
| 124 | + nullwatch-linux-x86_64.bin |
| 125 | + nullwatch-linux-aarch64.bin |
| 126 | + nullwatch-linux-riscv64.bin |
| 127 | + nullwatch-macos-aarch64.bin |
| 128 | + nullwatch-macos-x86_64.bin |
| 129 | + nullwatch-windows-x86_64.exe |
| 130 | + nullwatch-windows-aarch64.exe |
| 131 | + nullwatch-source/*.tar.gz |
| 132 | + generate_release_notes: true |
0 commit comments