aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/build-artifacts-manual.yml
blob: 873f03a427b0df7ef3c827a1f65b462a8c206716 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Build artifacts (manual)

on:
  workflow_dispatch:
    inputs:
      build_group:
        description: which artifacts to build
        required: true
        default: linux
        type: choice
        options:
          - linux
          - macos
          - all
      libghostty_optimize:
        description: libghostty-vt optimize mode for this build
        required: true
        default: ReleaseSafe
        type: choice
        options:
          - ReleaseSafe
          - ReleaseFast
          - ReleaseSmall
          - Debug

permissions:
  contents: read

env:
  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-unknown-linux-musl
            os: ubuntu-latest
            name: herdr-linux-x86_64
            group: linux
          - target: aarch64-unknown-linux-musl
            os: ubuntu-latest
            name: herdr-linux-aarch64
            group: linux
          - target: x86_64-apple-darwin
            os: macos-latest
            name: herdr-macos-x86_64
            group: macos
          - target: aarch64-apple-darwin
            os: macos-latest
            name: herdr-macos-aarch64
            group: macos

    if: ${{ inputs.build_group == 'all' || inputs.build_group == matrix.group }}
    runs-on: ${{ matrix.os }}
    env:
      LIBGHOSTTY_VT_OPTIMIZE: ${{ inputs.libghostty_optimize }}

    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Install Zig
        uses: mlugg/setup-zig@v2
        with:
          version: 0.15.2

      - name: Install Linux build tools
        if: runner.os == 'Linux'
        run: sudo apt-get update && sudo apt-get install -y cmake ninja-build musl-tools gcc-aarch64-linux-gnu crossbuild-essential-arm64

      - name: Install macOS build tools
        if: runner.os == 'macOS'
        run: brew install cmake ninja

      - name: Set Linux aarch64 linker
        if: matrix.target == 'aarch64-unknown-linux-musl'
        run: echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV

      - name: Remove Zig caches
        run: rm -rf .zig-cache vendor/libghostty-vt/.zig-cache vendor/libghostty-vt/zig-out

      - name: Build
        run: cargo build --release --locked --target ${{ matrix.target }}

      - name: Package artifact
        run: |
          cp target/${{ matrix.target }}/release/herdr ${{ matrix.name }}
          ./${{ matrix.name }} --version
          file ${{ matrix.name }} > BUILD_INFO.txt
          {
            echo "commit=$GITHUB_SHA"
            echo "target=${{ matrix.target }}"
            echo "libghostty_vt_optimize=$LIBGHOSTTY_VT_OPTIMIZE"
          } >> BUILD_INFO.txt
          python3 -c "import hashlib, pathlib; artifact = pathlib.Path('${{ matrix.name }}'); print(f'sha256={hashlib.sha256(artifact.read_bytes()).hexdigest()}  {artifact.name}')" >> BUILD_INFO.txt

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.name }}-${{ inputs.libghostty_optimize }}
          path: |
            ${{ matrix.name }}
            BUILD_INFO.txt
          retention-days: 7