ci(release): upload into an existing release instead of creating a second one #3957
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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: Build | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| jobs: | |
| # Linux + Windows are cross-compiled with zig on (cheap) Linux runners, one | |
| # target per runner — a single runner compiling all four serializes ~560 C/C++ | |
| # translation units (webrtc APM + portaudio) per target onto 4 vCPUs. | |
| cross-build: | |
| name: Cross-build ${{ matrix.id }} (zig) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| id: [lk-linux-amd64, lk-linux-arm64, lk-windows-amd64, lk-windows-arm64] | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | |
| with: | |
| submodules: true | |
| - name: Set up Go | |
| uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7 | |
| with: | |
| go-version-file: go.mod | |
| # setup-go's default cache key is keyed only on OS/arch/go version/ | |
| # go.sum, so it collides with the Go Test workflow's. Test finishes | |
| # first, claims the key, and this job's save then fails with "Unable | |
| # to reserve cache" — leaving it to restore native-gcc `go test -race` | |
| # objects that no zig cross target can use. Own cache below instead. | |
| cache: false | |
| - name: Cache Go modules and build cache | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 | |
| with: | |
| path: | | |
| ~/go/pkg/mod | |
| ~/.cache/go-build | |
| # The version segment (go-v1-) gates the WHOLE cache: restore-keys is a | |
| # prefix, so on any exact-key miss it re-restores the newest matching | |
| # cache — a poisoned build cache keeps coming back until the prefix | |
| # itself changes. Bump v1->v2 to force a clean rebuild across all | |
| # targets. Keyed on go.sum (not cmd/pkg): the expensive webrtc/portaudio | |
| # C++ objects don't depend on Go source, and Go's build cache is | |
| # content-addressed, so it recompiles changed Go packages on its own. | |
| key: go-v1-${{ runner.os }}-${{ matrix.id }}-${{ hashFiles('go.sum') }} | |
| restore-keys: | | |
| go-v1-${{ runner.os }}-${{ matrix.id }}- | |
| - name: Install Zig | |
| uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2 | |
| with: | |
| version: 0.14.1 | |
| - name: Cache cross-compile inputs | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 | |
| with: | |
| path: .cross | |
| key: cross-${{ runner.os }}-${{ matrix.id }}-zig0.14.1-alsa1.2.12-${{ hashFiles('scripts/setup-cross.sh') }} | |
| - name: GoReleaser snapshot build | |
| uses: goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # v7 | |
| with: | |
| distribution: goreleaser | |
| version: latest | |
| # darwin is excluded here — it can't be cross-compiled from Linux | |
| # (no macOS SDK/CoreAudio); it builds natively in the macos job below. | |
| args: build --snapshot --clean --id ${{ matrix.id }} | |
| env: | |
| # 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: Verify linux binary runs | |
| if: matrix.id == 'lk-linux-amd64' | |
| run: | | |
| binary=$(find dist -type f -name lk -path '*linux*amd64*' | head -n1) | |
| test -n "$binary" || { echo "no linux/amd64 binary in dist/"; exit 1; } | |
| # Static-libgcc/libstdc++ binary should run on glibc 2.28+ Ubuntu runners. | |
| "$binary" --help > /dev/null | |
| # darwin builds natively on macOS — its cgo links the CoreAudio frameworks, | |
| # which only exist on a Mac. No zig needed. | |
| build-darwin: | |
| name: Build darwin (native) | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | |
| with: | |
| submodules: true | |
| - name: Set up Go | |
| uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7 | |
| with: | |
| go-version-file: go.mod | |
| # setup-go's `cache` defaults to true, which collides with test.yaml's | |
| # macos leg — that job wins the key and stores `-race` objects this | |
| # non-race build can't reuse. Own cache below. | |
| cache: false | |
| - name: Cache Go modules and build cache | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 | |
| with: | |
| # GOCACHE is under ~/Library/Caches on darwin, not ~/.cache. | |
| path: | | |
| ~/go/pkg/mod | |
| ~/Library/Caches/go-build | |
| key: go-v1-${{ runner.os }}-lk-darwin-${{ hashFiles('go.sum') }} | |
| restore-keys: | | |
| go-v1-${{ runner.os }}-lk-darwin- | |
| - name: Build and verify | |
| run: | | |
| # arm64 native — build and run. | |
| CGO_ENABLED=1 go build -o /tmp/lk ./cmd/lk | |
| /tmp/lk --help > /dev/null | |
| # amd64 (Intel) cross — Apple clang targets x86_64 from arm64; compile | |
| # only (can't run an x86_64 binary on the arm64 runner). | |
| CGO_ENABLED=1 GOARCH=amd64 go build -o /tmp/lk-amd64 ./cmd/lk |