1414
1515name : Release
1616
17- # on events
1817on :
1918 push :
2019 tags :
2322permissions :
2423 contents : write
2524
26- # workflow tasks
2725jobs :
28- release :
29- name : Release
26+ create-release :
3027 runs-on : ubuntu-latest
3128 steps :
32- - name : Checkout Git LFS
33- uses : actions/checkout@v6
29+ - uses : actions/checkout@v6
3430 with :
3531 lfs : ' true'
36-
32+
3733 - name : Verify version.go matches tag
3834 run : |
3935 TAG_VERSION=${GITHUB_REF#refs/tags/v}
4743 exit 1
4844 fi
4945 echo "✓ Versions match: $CODE_VERSION"
50-
46+
5147 - name : Verify server-sdk-go version
5248 run : |
5349 livekit_cli_ver=${GITHUB_REF#refs/tags/}
@@ -65,29 +61,147 @@ jobs:
6561 fi
6662 echo "versions match ($livekit_cli_major_minor)"
6763
68- - run : git lfs pull
69-
70- - name : Fetch all tags
71- run : git fetch --force --tags
64+ - name : Create release
65+ env :
66+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
67+ run : |
68+ TAG="${GITHUB_REF#refs/tags/}"
69+ gh release create "$TAG" --draft --generate-notes --title "$TAG"
7270
73- - uses : actions/cache@v5
71+ build :
72+ needs : create-release
73+ strategy :
74+ fail-fast : false
75+ matrix :
76+ include :
77+ - os : macos-latest
78+ suffix : darwin_arm64
79+ - os : ubuntu-latest
80+ suffix : linux_amd64
81+ zig_target : x86_64-linux-gnu.2.28
82+ alsa_arch : amd64
83+ alsa_triple : x86_64-linux-gnu
84+ - os : ubuntu-latest
85+ suffix : linux_arm64
86+ zig_target : aarch64-linux-gnu.2.28
87+ alsa_arch : arm64
88+ alsa_triple : aarch64-linux-gnu
89+ goarch : arm64
90+ - os : ubuntu-latest
91+ suffix : linux_arm
92+ zig_target : arm-linux-gnueabihf.2.28
93+ alsa_arch : armhf
94+ alsa_triple : arm-linux-gnueabihf
95+ goarch : arm
96+ goarm : " 7"
97+ - os : ubuntu-latest
98+ suffix : windows_amd64
99+ zig_target : x86_64-windows-gnu
100+ goos : windows
101+ goarch : amd64
102+ - os : ubuntu-latest
103+ suffix : windows_arm64
104+ zig_target : aarch64-windows-gnu
105+ goos : windows
106+ goarch : arm64
107+ - os : ubuntu-latest
108+ suffix : windows_arm
109+ goos : windows
110+ goarch : arm
111+ goarm : " 7"
112+ runs-on : ${{ matrix.os }}
113+ steps :
114+ - uses : actions/checkout@v6
74115 with :
75- path : |
76- ~/go/pkg/mod
77- ~/go/bin
78- ~/.cache
79- key : livekit-cli
116+ lfs : ' true'
117+ submodules : true
118+
119+ - run : git lfs pull
80120
81121 - name : Set up Go
82122 uses : actions/setup-go@v6
83123 with :
84124 go-version : " 1.25"
85125
86- - name : Run GoReleaser
87- uses : goreleaser/goreleaser-action@v6
126+ - name : Install Zig
127+ if : matrix.zig_target
128+ uses : mlugg/setup-zig@v2
88129 with :
89- distribution : goreleaser
90- version : latest
91- args : release --clean
130+ version : 0.14.1
131+
132+ - name : Install ALSA headers
133+ if : matrix.alsa_arch
134+ run : |
135+ sudo dpkg --add-architecture ${{ matrix.alsa_arch }}
136+ if [ "${{ matrix.alsa_arch }}" != "amd64" ]; then
137+ CODENAME=$(lsb_release -cs)
138+ # Restrict existing sources to amd64 to avoid 404s for foreign arch
139+ for f in /etc/apt/sources.list.d/*.sources; do
140+ grep -q '^Architectures:' "$f" || sudo sed -i '/^Types:/a Architectures: amd64 i386' "$f"
141+ done
142+ # Add ports.ubuntu.com for the foreign architecture
143+ printf 'Types: deb\nURIs: http://ports.ubuntu.com/ubuntu-ports\nSuites: %s %s-updates\nComponents: main universe\nArchitectures: %s\nSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n' \
144+ "$CODENAME" "$CODENAME" "${{ matrix.alsa_arch }}" | sudo tee /etc/apt/sources.list.d/ports.sources
145+ fi
146+ sudo apt-get update
147+ sudo apt-get install -y libasound2-dev:${{ matrix.alsa_arch }}
148+
149+ - name : Generate Windows import libraries
150+ if : matrix.goos == 'windows' && matrix.zig_target
151+ run : |
152+ ZIG_LIB=$(zig env | jq -r '.lib_dir')
153+ echo "ZIG_LIB=${ZIG_LIB}" >> "$GITHUB_ENV"
154+ LIB_DIR="${ZIG_LIB}/libc/mingw/lib-common"
155+ # Zig bundles MinGW .def files but lld needs .a import libraries.
156+ # Go's compiled objects embed COFF /DEFAULTLIB directives (e.g. dbghelp,
157+ # bcrypt) that lld resolves directly, bypassing Zig's lazy .def→.a
158+ # generation. Pre-generate all import libraries so lld can find them.
159+ MACHINE=${{ matrix.goarch == 'amd64' && 'i386:x86-64' || 'arm64' }}
160+ for def in "${LIB_DIR}"/*.def; do
161+ lib=$(basename "$def" .def)
162+ [ -f "${LIB_DIR}/lib${lib}.a" ] && continue
163+ zig dlltool -d "$def" -l "${LIB_DIR}/lib${lib}.a" -m "$MACHINE" 2>/dev/null || true
164+ done
165+
166+ - name : Build
92167 env :
93- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
168+ CGO_ENABLED : ${{ (matrix.goos && !matrix.zig_target) && '0' || '1' }}
169+ CC : ${{ matrix.zig_target && format('zig cc -target {0}', matrix.zig_target) || '' }}
170+ CXX : ${{ matrix.zig_target && format('zig c++ -target {0}', matrix.zig_target) || '' }}
171+ # Zig uses its own sysroot; point it at the system ALSA headers and libraries
172+ CGO_CFLAGS : ${{ matrix.alsa_triple && format('-isystem /usr/include -isystem /usr/include/{0}', matrix.alsa_triple) || '' }}
173+ CGO_LDFLAGS : ${{ matrix.alsa_triple && format('-L/usr/lib/{0}', matrix.alsa_triple) || '' }}
174+ # -fms-extensions: enable __try/__except (SEH) used by WebRTC
175+ # -DNTDDI_VERSION: target Windows 10 base to skip WinRT includes absent from MinGW
176+ CGO_CXXFLAGS : ${{ matrix.goos == 'windows' && '-fms-extensions -DNTDDI_VERSION=0x0A000000' || '' }}
177+ GOOS : ${{ matrix.goos || '' }}
178+ GOARCH : ${{ matrix.goarch || '' }}
179+ GOARM : ${{ matrix.goarm || '' }}
180+ shell : bash
181+ run : |
182+ EXT=""; if [ "${GOOS:-}" = "windows" ]; then EXT=".exe"; fi
183+ TAGS=""
184+ if [ "$CGO_ENABLED" = "1" ]; then TAGS="-tags console"; fi
185+ # Force external linking for Windows so Go uses zig cc (CC) as the linker,
186+ # and add Zig's MinGW lib path so lld can find the generated import libraries.
187+ EXTLD=""
188+ if [ "${GOOS:-}" = "windows" ] && [ "$CGO_ENABLED" = "1" ]; then
189+ EXTLD="-linkmode=external -extldflags '-L${ZIG_LIB}/libc/mingw/lib-common'"
190+ fi
191+ go build $TAGS -ldflags "-w -s $EXTLD" -o "dist/lk${EXT}" ./cmd/lk
192+
193+ - name : Package and upload
194+ env :
195+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
196+ shell : bash
197+ run : |
198+ TAG="${GITHUB_REF#refs/tags/}"
199+ NAME="lk_${TAG}_${{ matrix.suffix }}"
200+ cp LICENSE dist/
201+ if [[ "${{ matrix.suffix }}" == windows_* ]]; then
202+ cd dist && zip "../${NAME}.zip" lk.exe LICENSE && cd ..
203+ gh release upload "$TAG" "${NAME}.zip" --clobber
204+ else
205+ tar -czf "${NAME}.tar.gz" -C dist lk LICENSE
206+ gh release upload "$TAG" "${NAME}.tar.gz" --clobber
207+ fi
0 commit comments