-
Notifications
You must be signed in to change notification settings - Fork 148
168 lines (146 loc) · 6.08 KB
/
Copy pathrelease.yaml
File metadata and controls
168 lines (146 loc) · 6.08 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# Copyright 2023 LiveKit, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Release
on:
push:
tags:
- v*
permissions:
contents: write
jobs:
# GoReleaser runs on macOS so the darwin binary builds natively (CoreAudio
# frameworks only exist on a Mac); zig still cross-compiles linux + windows
# from here. Produces all binaries, archives, checksums, and the GitHub
# release. Docker is handled by the separate job below (macOS has no Docker).
release:
name: Release
runs-on: macos-latest
steps:
- name: Checkout Git LFS
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
lfs: 'true'
# pkg/portaudio/pa_src holds the vendored PortAudio C source the cgo
# build links against.
submodules: true
- name: Verify version.go matches tag
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
CODE_VERSION=$(sed -n 's/.*Version = "\([^"]*\)".*/\1/p' version.go)
echo "Tag version: v$TAG_VERSION"
echo "Code version: $CODE_VERSION"
if [ "$TAG_VERSION" != "$CODE_VERSION" ]; then
echo "ERROR: Version mismatch!"
echo " Tag: v$TAG_VERSION"
echo " version.go: $CODE_VERSION"
exit 1
fi
echo "✓ Versions match: $CODE_VERSION"
- name: Verify server-sdk-go version
run: |
livekit_cli_ver=${GITHUB_REF#refs/tags/}
server_sdk_go_ver=$(git ls-remote --tags --sort='v:refname' https://github.com/livekit/server-sdk-go.git \
| awk -F'refs/tags/' '{print $2}' \
| grep -E '^v[0-9]+\.[0-9]+' \
| tail -n1)
livekit_cli_major_minor=$(echo "$livekit_cli_ver" | sed -E 's/^v([0-9]+\.[0-9]+)\..*/\1/')
server_sdk_go_major_minor=$(echo "$server_sdk_go_ver" | sed -E 's/^v([0-9]+\.[0-9]+)\..*/\1/')
echo "livekit-cli: $livekit_cli_ver ($livekit_cli_major_minor)"
echo "server-sdk-go: $server_sdk_go_ver ($server_sdk_go_major_minor)"
if [ "$livekit_cli_major_minor" != "$server_sdk_go_major_minor" ]; then
echo "version mismatch: livekit-cli ($livekit_cli_major_minor) ≠ server-sdk-go ($server_sdk_go_major_minor)"
exit 1
fi
echo "versions match ($livekit_cli_major_minor)"
- run: git lfs pull
- name: Fetch all tags
run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
go-version-file: go.mod
cache: true
- name: Install Zig
uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2
with:
version: 0.14.1
- name: Cache cross-compile inputs
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: .cross
key: cross-${{ runner.os }}-zig0.14.1-alsa1.2.12-${{ hashFiles('scripts/setup-cross.sh') }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # v7
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# goreleaser-action runs goreleaser via a Node wrapper that doesn't
# forward PWD; the .goreleaser.yaml CGO flags template {{ .Env.PWD }}
# to locate .cross/<target>. Provide it explicitly.
PWD: ${{ github.workspace }}
- name: Stage linux binaries for Docker
run: |
mkdir -p docker-bin
cp dist/lk-linux-amd64_*/lk docker-bin/lk_linux_amd64
cp dist/lk-linux-arm64_*/lk docker-bin/lk_linux_arm64
- name: Upload linux binaries
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: docker-bin
path: docker-bin/
if-no-files-found: error
# Build + push multi-arch Docker images on Linux (where the Docker daemon
# lives), reusing the cgo linux binaries staged by the release job.
docker:
name: Release to Docker
needs: release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Download linux binaries
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6
with:
name: docker-bin
path: .
- name: Restore executable bit
run: chmod +x lk_linux_amd64 lk_linux_arm64
- name: Docker meta
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
with:
images: livekit/livekit-cli
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
- name: Set up QEMU
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
- name: Login to DockerHub
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}