|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build (${{ matrix.target }}) |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + - os: ubuntu-latest |
| 20 | + target: x86_64-linux |
| 21 | + artifact: zfetch-x86_64-linux |
| 22 | + - os: ubuntu-latest |
| 23 | + target: aarch64-linux |
| 24 | + artifact: zfetch-aarch64-linux |
| 25 | + - os: macos-latest |
| 26 | + target: x86_64-macos |
| 27 | + artifact: zfetch-x86_64-macos |
| 28 | + - os: macos-latest |
| 29 | + target: aarch64-macos |
| 30 | + artifact: zfetch-aarch64-macos |
| 31 | + - os: windows-latest |
| 32 | + target: x86_64-windows |
| 33 | + artifact: zfetch-x86_64-windows |
| 34 | + |
| 35 | + steps: |
| 36 | + - name: Checkout |
| 37 | + uses: actions/checkout@v4 |
| 38 | + |
| 39 | + - name: Setup Zig |
| 40 | + uses: mlugg/setup-zig@v1 |
| 41 | + with: |
| 42 | + version: 0.14.0 |
| 43 | + |
| 44 | + - name: Build |
| 45 | + run: zig build -Dtarget=${{ matrix.target }} -Doptimize=ReleaseFast |
| 46 | + |
| 47 | + - name: Create archive (Unix) |
| 48 | + if: runner.os != 'Windows' |
| 49 | + run: | |
| 50 | + cd zig-out/bin |
| 51 | + tar -czvf ../../${{ matrix.artifact }}.tar.gz zfetch* |
| 52 | +
|
| 53 | + - name: Create archive (Windows) |
| 54 | + if: runner.os == 'Windows' |
| 55 | + run: | |
| 56 | + cd zig-out/bin |
| 57 | + Compress-Archive -Path zfetch* -DestinationPath ../../${{ matrix.artifact }}.zip |
| 58 | +
|
| 59 | + - name: Upload artifact |
| 60 | + uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: ${{ matrix.artifact }} |
| 63 | + path: | |
| 64 | + ${{ matrix.artifact }}.tar.gz |
| 65 | + ${{ matrix.artifact }}.zip |
| 66 | +
|
| 67 | + release: |
| 68 | + name: Create Release |
| 69 | + needs: build |
| 70 | + runs-on: ubuntu-latest |
| 71 | + steps: |
| 72 | + - name: Checkout |
| 73 | + uses: actions/checkout@v4 |
| 74 | + |
| 75 | + - name: Download all artifacts |
| 76 | + uses: actions/download-artifact@v4 |
| 77 | + with: |
| 78 | + path: artifacts |
| 79 | + |
| 80 | + - name: List artifacts |
| 81 | + run: find artifacts -type f |
| 82 | + |
| 83 | + - name: Create Release |
| 84 | + uses: softprops/action-gh-release@v1 |
| 85 | + with: |
| 86 | + generate_release_notes: true |
| 87 | + files: | |
| 88 | + artifacts/**/*.tar.gz |
| 89 | + artifacts/**/*.zip |
| 90 | + env: |
| 91 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments