Live Video Payment Mechanism #2771
Workflow file for this run
This file contains 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
name: Build binaries | |
on: | |
pull_request: | |
push: | |
branches: | |
- ai-video | |
tags: | |
- "v*" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
linux-build: | |
name: Build binaries for ${{ matrix.target.GOOS }}-${{ matrix.target.type }}-${{ matrix.target.GOARCH }} | |
runs-on: ubuntu-20.04 | |
container: | |
image: ${{ matrix.target.container }} | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
strategy: | |
fail-fast: false | |
matrix: | |
target: | |
- GOOS: linux | |
GOARCH: amd64 | |
container: ubuntu:20.04 | |
type: cpu | |
# - GOOS: linux | |
# GOARCH: arm64 | |
# container: ubuntu-20.04 | |
# type: cpu | |
- GOOS: linux | |
GOARCH: amd64 | |
container: livepeerci/cuda:12.0.0-cudnn8-devel-ubuntu20.04 | |
type: gpu | |
# - GOOS: linux | |
# GOARCH: arm64 | |
# container: livepeerci/cuda:12.0.0-cudnn8-devel-ubuntu20.04 | |
# type: gpu | |
# - GOOS: windows | |
# GOARCH: amd64 | |
# container: ubuntu:22.04 | |
# type: cpu | |
steps: | |
- name: Setup ubuntu container | |
run: | | |
apt update | |
apt install -yqq build-essential make software-properties-common | |
add-apt-repository -y ppa:git-core/candidate | |
apt update && apt install -yqq git zip unzip zlib1g-dev zlib1g yasm | |
- name: Check out code | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
# Check https://github.com/livepeer/go-livepeer/pull/1891 | |
# for ref value discussion | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Set up go | |
id: go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.23.2 | |
cache: true | |
cache-dependency-path: go.sum | |
- name: Set build environment | |
run: | | |
echo "GOARCH=${{ matrix.target.GOARCH }}" >> $GITHUB_ENV | |
echo "GOOS=${{ matrix.target.GOOS }}" >> $GITHUB_ENV | |
echo "GO_BUILD_DIR=lp-builds/" >> $GITHUB_ENV | |
echo "PKG_CONFIG_PATH=/github/home/compiled/lib/pkgconfig" >> $GITHUB_ENV | |
echo "LP_BUILD_DIR=livepeer-${{ matrix.target.GOOS }}-${{ matrix.target.GOARCH }}" >> $GITHUB_ENV | |
mkdir -p lp-builds/ releases/ | |
- name: Set GPU build environment | |
if: matrix.target.type == 'gpu' | |
run: | | |
echo "CPATH=/usr/local/cuda_${{ matrix.target.GOARCH }}/include" >> $GITHUB_ENV | |
echo "LIBRARY_PATH=/usr/local/cuda_${{ matrix.target.GOARCH }}/lib64" >> $GITHUB_ENV | |
echo "CGO_LDFLAGS=-L/usr/local/cuda_${{ matrix.target.GOARCH }}/lib64" >> $GITHUB_ENV | |
echo "RELEASE_TAG=gpu" >> $GITHUB_ENV | |
echo "LP_BUILD_DIR=livepeer-${{ matrix.target.GOOS }}-gpu-${{ matrix.target.GOARCH }}" >> $GITHUB_ENV | |
- name: Install dependencies | |
run: | | |
apt update \ | |
&& apt install -yqq software-properties-common curl apt-transport-https lsb-release \ | |
&& curl -fsSl https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \ | |
&& add-apt-repository "deb https://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-14 main" \ | |
&& apt update \ | |
&& apt -yqq install \ | |
nasm clang-14 clang-tools-14 lld-14 build-essential pkg-config autoconf git python3 \ | |
gcc-mingw-w64 libgcc-9-dev-arm64-cross mingw-w64-tools gcc-mingw-w64-x86-64 \ | |
golang-goprotobuf-dev protobuf-compiler-grpc | |
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-14 30 \ | |
&& update-alternatives --install /usr/bin/clang clang /usr/bin/clang-14 30 \ | |
&& update-alternatives --install /usr/bin/ld ld /usr/bin/lld-14 30 | |
- name: Install go modules | |
if: steps.go.outputs.cache-hit != 'true' | |
run: go mod download | |
- name: Install ffmpeg | |
run: ./install_ffmpeg.sh | |
- name: Build binaries | |
env: | |
GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} | |
run: | | |
git config --global --add safe.directory '*' | |
./ci_env.sh make | |
- name: Archive binaries for windows | |
if: matrix.target.GOOS == 'windows' | |
run: | | |
mkdir -p "${GO_BUILD_DIR}/${LP_BUILD_DIR}/" | |
cd "$GO_BUILD_DIR/" | |
find . -type f -exec mv '{}' "$LP_BUILD_DIR/" \; | |
zip -9rq "../releases/$LP_BUILD_DIR.zip" ./ | |
- name: Archive binaries | |
if: matrix.target.GOOS != 'windows' | |
run: | | |
mkdir -p "${GO_BUILD_DIR}/${LP_BUILD_DIR}/" | |
cd "$GO_BUILD_DIR/" | |
find . -type f -exec mv '{}' "$LP_BUILD_DIR" \; | |
tar -czvf "../releases/$LP_BUILD_DIR.tar.gz" ./ | |
- name: Upload artifacts for cutting release | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-artifacts-${{ matrix.target.GOOS }}-${{ matrix.target.type }}-${{ matrix.target.GOARCH }} | |
path: releases/ | |
macos-build: | |
name: Build binaries for ${{ matrix.target.GOOS }}-${{ matrix.target.GOARCH }} | |
runs-on: ${{ matrix.target.runner }} | |
strategy: | |
fail-fast: false | |
matrix: | |
target: | |
- GOOS: darwin | |
GOARCH: amd64 | |
runner: macos-14-large | |
- GOOS: darwin | |
GOARCH: arm64 | |
runner: macos-14-xlarge | |
steps: | |
- name: Check out code | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
# Check https://github.com/livepeer/go-livepeer/pull/1891 | |
# for ref value discussion | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Set up go | |
id: go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.23.2 | |
cache: true | |
cache-dependency-path: go.sum | |
- name: Set build environment | |
run: | | |
echo "GOARCH=${{ matrix.target.GOARCH }}" >> $GITHUB_ENV | |
echo "GOOS=${{ matrix.target.GOOS }}" >> $GITHUB_ENV | |
echo "GO_BUILD_DIR=lp-builds/" >> $GITHUB_ENV | |
echo "LP_BUILD_DIR=livepeer-${{ matrix.target.GOOS }}-${{ matrix.target.GOARCH }}" >> $GITHUB_ENV | |
mkdir -p lp-builds/ releases/ | |
- name: Cache ffmpeg | |
id: cache-ffmpeg | |
uses: actions/cache@v4 | |
with: | |
path: ~/compiled | |
key: ${{ runner.os }}-${{ matrix.target.GOOS }}-${{ matrix.target.GOARCH }}-ffmpeg-${{ hashFiles('**/install_ffmpeg.sh') }} | |
- name: Install dependencies | |
run: brew install coreutils pkg-config | |
- name: Install go modules | |
# if: steps.go.outputs.cache-hit != 'true' | |
run: go mod download | |
- name: Install ffmpeg | |
if: steps.cache-ffmpeg.outputs.cache-hit != 'true' | |
run: ./install_ffmpeg.sh | |
- name: Build binaries | |
env: | |
GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} | |
run: | | |
git config --global --add safe.directory '*' | |
export PKG_CONFIG_PATH=~/compiled/lib/pkgconfig | |
./ci_env.sh make | |
- uses: actions-ecosystem/action-regex-match@v2 | |
id: match-tag | |
with: | |
text: ${{ github.ref_name }} | |
regex: '^(master|main|ai-video|v[0-9]+\.\d+\.\d+)$' | |
- name: Codesign and notarize binaries | |
if: steps.match-tag.outputs.match != '' && matrix.target.GOOS == 'darwin' | |
uses: livepeer/action-gh-codesign-apple@latest | |
with: | |
developer-certificate-id: ${{ secrets.CI_MACOS_CERTIFICATE_ID }} | |
developer-certificate-base64: ${{ secrets.CI_MACOS_CERTIFICATE_BASE64 }} | |
developer-certificate-password: ${{ secrets.CI_MACOS_CERTIFICATE_PASSWORD }} | |
app-notarization-email: ${{ secrets.CI_MACOS_NOTARIZATION_USER }} | |
app-notarization-password: ${{ secrets.CI_MACOS_NOTARIZATION_PASSWORD }} | |
app-notarization-team-id: ${{ secrets.CI_MACOS_NOTARIZATION_TEAM_ID }} | |
binary-path: "lp-builds/" | |
- name: Archive binaries | |
if: matrix.platform.name != 'windows' | |
run: | | |
mkdir -p "${GO_BUILD_DIR}/${LP_BUILD_DIR}/" | |
cd "$GO_BUILD_DIR/" | |
find . -type f -exec mv '{}' "$LP_BUILD_DIR" \; | |
tar -czvf "../releases/${LP_BUILD_DIR}.tar.gz" . | |
- name: Upload artifacts for cutting release | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-artifacts-${{ matrix.target.GOOS }}-${{ matrix.target.GOARCH }} | |
path: releases/ | |
upload: | |
name: Upload artifacts to google bucket | |
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository | |
permissions: | |
contents: "read" | |
id-token: "write" | |
runs-on: ubuntu-20.04 | |
needs: | |
- macos-build | |
- linux-build | |
steps: | |
- name: Check out code | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
# Check https://github.com/livepeer/go-livepeer/pull/1891 | |
# for ref value discussion | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Set up python | |
id: python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
cache: pip | |
cache-dependency-path: .github/requirements.txt | |
update-environment: true | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: release-artifacts-* | |
path: releases/ | |
merge-multiple: true | |
- name: Generate sha256 checksum and gpg signatures for release artifacts | |
uses: livepeer/action-gh-checksum-and-gpg-sign@latest | |
with: | |
artifacts-dir: releases | |
release-name: ${{ (github.ref_type == 'tag' && github.ref_name) || (github.event.pull_request.head.sha || github.sha) }} | |
gpg-key: ${{ secrets.CI_GPG_SIGNING_KEY }} | |
gpg-key-passphrase: ${{ secrets.CI_GPG_SIGNING_PASSPHRASE }} | |
- name: Generate branch manifest | |
id: branch-manifest | |
uses: livepeer/branch-manifest-action@latest | |
with: | |
project-name: livepeer | |
bucket-key: ${{ github.event.repository.name }} | |
use-prefix: false | |
- name: Authenticate to Google Cloud | |
id: auth | |
uses: google-github-actions/auth@v2 | |
with: | |
workload_identity_provider: ${{ secrets.CI_GOOGLE_WORKLOAD_IDENTITY_PROVIDER }} | |
service_account: ${{ secrets.CI_GOOGLE_SERVICE_ACCOUNT }} | |
- name: Upload release archives to Google Cloud | |
id: upload-archives | |
uses: google-github-actions/upload-cloud-storage@v2 | |
with: | |
path: "releases" | |
destination: "build.livepeer.live/${{ github.event.repository.name }}/${{ (github.ref_type == 'tag' && github.ref_name) || (github.event.pull_request.head.sha || github.sha) }}" | |
parent: false | |
process_gcloudignore: false | |
- name: Upload branch manifest file | |
id: upload-manifest | |
uses: google-github-actions/upload-cloud-storage@v2 | |
with: | |
path: ${{ steps.branch-manifest.outputs.manifest-file }} | |
destination: "build.livepeer.live/${{ github.event.repository.name }}/" | |
parent: false | |
process_gcloudignore: false | |
# Get the latest release tag | |
- name: Get latest tag | |
id: get-latest-tag | |
run: | | |
git fetch --tags | |
latest_tag=$(git tag -l "v*" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+-ai.[0-9]+$' | sort -V | tail -n 1) | |
echo "latest_tag=$latest_tag" >> $GITHUB_OUTPUT | |
echo "Latest tag: $latest_tag" | |
echo "GitHub Ref: ${{ github.ref }}" | |
# Update the latest release | |
- name: Upload release archives to Google Cloud stable folder | |
id: upload-archives-latest | |
if: ${{ github.ref == format('refs/tags/{0}', steps.get-latest-tag.outputs.latest_tag) }} | |
uses: google-github-actions/upload-cloud-storage@v2 | |
with: | |
path: "releases" | |
destination: "build.livepeer.live/${{ github.event.repository.name }}/ai-video/stable" | |
parent: false | |
process_gcloudignore: false | |
# Update the latest branch manifest | |
- name: Upload branch manifest file to Google Cloud stable folder | |
id: upload-manifest-latest | |
if: ${{ github.ref == format('refs/tags/{0}', steps.get-latest-tag.outputs.latest_tag) }} | |
uses: google-github-actions/upload-cloud-storage@v2 | |
with: | |
path: ${{ steps.branch-manifest.outputs.manifest-file }} | |
destination: "build.livepeer.live/${{ github.event.repository.name }}/ai-video/stable" | |
parent: false | |
process_gcloudignore: false | |
- name: Trigger discord webhook | |
shell: bash | |
env: | |
GITHUB_CONTEXT_JSON: ${{ toJson(github) }} | |
run: | | |
pip install -r .github/requirements.txt | |
python .github/discord-embed-webhook.py \ | |
--ref-name="${{ (github.ref_type == 'tag' && github.ref_name) || (github.event.pull_request.head.sha || github.sha) }}" \ | |
--discord-url="${{ secrets.DISCORD_URL }}" \ | |
--git-commit="$(git log -1 --pretty=format:'%s')" \ | |
--git-committer="$(git log -1 --pretty=format:'%an')" | |
- name: Notify new build upload | |
run: curl -X POST https://holy-bread-207a.livepeer.workers.dev |