diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..8babc29f48 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,23 @@ +# This file is the top-most EditorConfig file +root = true + +# All Files +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true +end_of_line = lf + +# Makefiles +[Makefile] +indent_style = tab + +# YAML Files +[*.{yaml,sh}] +indent_size = 2 + +# Go source files +[*.go] +indent_style = tab diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000000..37a283a8a5 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,325 @@ +name: Build binaries + +on: + pull_request: + push: + branches: + - master + +jobs: + linux: + name: Build linux binaries + runs-on: ubuntu-18.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + # Needed for commands that depend on git tags + fetch-depth: 0 + # Check https://github.com/livepeer/go-livepeer/pull/1891 + # for ref value discussion + ref: ${{ github.event.pull_request.head.sha }} + + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: '1.17.6' + + - name: Cache go modules + id: cache-go-mod + uses: actions/cache@v2.1.5 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Cache ffmpeg + id: cache-ffmpeg + uses: actions/cache@v2.1.5 + with: + path: ~/compiled + key: ${{ runner.os }}-ffmpeg-${{ hashFiles('**/install_ffmpeg.sh') }} + restore-keys: | + ${{ runner.os }}-ffmpeg + + - name: Cache binaries + uses: actions/cache@v2.1.5 + with: + path: ~/build + key: ${{ runner.os }}-binaries-${{ github.sha }} + + - name: Install dependencies + run: | + sudo apt-get update \ + && sudo apt-get install -y software-properties-common curl apt-transport-https \ + && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 15CF4D18AF4F7421 \ + && sudo add-apt-repository "deb [arch=amd64] http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" \ + && sudo apt-get update \ + && sudo apt-get -y install clang-8 clang-tools-8 build-essential pkg-config autoconf git python + + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-8 30 \ + && sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8 30 + + - name: Install go modules + if: steps.cache-go-mod.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 + run: | + export PKG_CONFIG_PATH=~/compiled/lib/pkgconfig + ./ci_env.sh make + rm -rf ~/build && mkdir ~/build && mv livepeer* ~/build/ + env: + GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} + + - name: Upload build + run: cp ~/build/* . && ./upload_build.sh + env: + GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} + GCLOUD_KEY: ${{ secrets.GCLOUD_KEY }} + GCLOUD_SECRET: ${{ secrets.GCLOUD_SECRET }} + DISCORD_URL: ${{ secrets.DISCORD_URL }} + + - name: Upload artifacts for cutting release + uses: actions/upload-artifact@master + with: + name: release-artifacts + path: releases/ + + - name: Notify new build upload + run: curl -X POST https://holy-bread-207a.livepeer.workers.dev + + macos: + name: Build MacOS binaries + strategy: + matrix: + arch: + - amd64 + - arm64 + runs-on: macos-latest + steps: + - name: Set build environment + run: echo "GOARCH=${{ matrix.arch }}" >> $GITHUB_ENV + + - name: Checkout + uses: actions/checkout@v2 + with: + # Needed for commands that depend on git tags + fetch-depth: 0 + # Check https://github.com/livepeer/go-livepeer/pull/1891 + # for ref value discussion + ref: ${{ github.event.pull_request.head.sha }} + + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: '1.17.6' + + - name: Cache go modules + id: cache-go-mod + uses: actions/cache@v2.1.5 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-${{ matrix.arch }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.arch }}-go- + + - name: Cache ffmpeg + id: cache-ffmpeg + uses: actions/cache@v2.1.5 + with: + path: ~/compiled + key: ${{ runner.os }}-${{ matrix.arch }}-ffmpeg-${{ hashFiles('**/install_ffmpeg.sh') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.arch }}-ffmpeg + + - name: Install dependencies + run: brew install coreutils + + - name: Install go modules + if: steps.cache-go-mod.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 + run: | + export PKG_CONFIG_PATH=~/compiled/lib/pkgconfig + ./ci_env.sh make + env: + GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} + + - name: Upload build + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository + env: + GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} + GCLOUD_KEY: ${{ secrets.GCLOUD_KEY }} + GCLOUD_SECRET: ${{ secrets.GCLOUD_SECRET }} + DISCORD_URL: ${{ secrets.DISCORD_URL }} + run: ./upload_build.sh + + - name: Upload artifacts for cutting release + uses: actions/upload-artifact@master + with: + name: release-artifacts + path: releases/ + + windows: + name: Build windows binaries + runs-on: windows-latest + steps: + - name: configure git line endings + run: git config --global core.autocrlf false + + - uses: actions/checkout@v2 + with: + # Needed for commands that depend on git tags + fetch-depth: 0 + # Check https://github.com/livepeer/go-livepeer/pull/1891 + # for ref value discussion + ref: ${{ github.event.pull_request.head.sha }} + + - name: Setup Msys2 environment + uses: msys2/setup-msys2@v2 + with: + msystem: MSYS + + - name: Prepare mingw64 environment + shell: msys2 {0} + run: ./prepare_mingw64.sh + + - name: Build ffmpeg + shell: msys2 {0} + run: ./install_ffmpeg.sh + # For some reason the next step sometimes cannot find protoc + # - name: Install protoc + # uses: arduino/setup-protoc@v1 + # We do not just run `make` because it would also require protoc + # Due to the issue described above with finding protoc, for now we just specify the individual binaries + + - name: Build binaries + shell: msys2 {0} + run: ./ci_env.sh make livepeer livepeer_cli livepeer_bench livepeer_router + + - name: Upload build + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository + shell: msys2 {0} + env: + GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} + GCLOUD_KEY: ${{ secrets.GCLOUD_KEY }} + GCLOUD_SECRET: ${{ secrets.GCLOUD_SECRET }} + DISCORD_URL: ${{ secrets.DISCORD_URL }} + run: ./upload_build.sh + + - name: Upload artifacts for cutting release + uses: actions/upload-artifact@master + with: + name: release-artifacts + path: releases/ + + linux-tensorflow: + name: Build binaries for linux using tensorflow + runs-on: ubuntu-18.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + # Needed for commands that depend on git tags + fetch-depth: 0 + # Check https://github.com/livepeer/go-livepeer/pull/1891 + # for ref value discussion + ref: ${{ github.event.pull_request.head.sha }} + + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: '1.17.6' + + - name: Cache go modules + id: cache-go-mod + uses: actions/cache@v2.1.5 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Cache ffmpeg + id: cache-ffmpeg + uses: actions/cache@v2.1.5 + with: + path: ~/compiled + key: ${{ runner.os }}-ffmpeg-tensorflow-${{ hashFiles('**/install_ffmpeg.sh') }} + restore-keys: | + ${{ runner.os }}-ffmpeg-tensorflow + + - name: Cache binaries + uses: actions/cache@v2.1.5 + with: + path: ~/build + key: ${{ runner.os }}-binaries-tensorflow-${{ github.sha }} + + - name: Install dependencies + run: | + sudo apt-get update \ + && sudo apt-get install -y software-properties-common curl apt-transport-https \ + && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 15CF4D18AF4F7421 \ + && sudo add-apt-repository "deb [arch=amd64] http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" \ + && sudo apt-get update \ + && sudo apt-get -y install clang-8 clang-tools-8 build-essential pkg-config autoconf gnutls-dev git python + + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-8 30 \ + && sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8 30 + + LIBTENSORFLOW_VERSION=2.6.3 \ + && curl -LO https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-${LIBTENSORFLOW_VERSION}.tar.gz \ + && sudo tar -C /usr/local -xzf libtensorflow-gpu-linux-x86_64-${LIBTENSORFLOW_VERSION}.tar.gz \ + && sudo ldconfig + + - name: Install go modules + if: steps.cache-go-mod.outputs.cache-hit != 'true' + run: go mod download + + - name: Install ffmpeg + if: steps.cache-ffmpeg.outputs.cache-hit != 'true' + run: BUILD_TAGS=experimental ./install_ffmpeg.sh + + - name: Build binaries + run: | + export PKG_CONFIG_PATH=~/compiled/lib/pkgconfig + ./ci_env.sh make + rm -rf ~/build && mkdir ~/build && mv livepeer* ~/build/ + env: + GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} + + - name: Install libtensorflow + run: | + LIBTENSORFLOW_VERSION=2.6.3 \ + && curl -LO https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-${LIBTENSORFLOW_VERSION}.tar.gz \ + && sudo tar -C /usr/local -xzf libtensorflow-gpu-linux-x86_64-${LIBTENSORFLOW_VERSION}.tar.gz \ + && sudo ldconfig + + - name: Upload build + run: cp ~/build/* . && ./upload_build.sh + env: + GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} + GCLOUD_KEY: ${{ secrets.GCLOUD_KEY }} + GCLOUD_SECRET: ${{ secrets.GCLOUD_SECRET }} + DISCORD_URL: ${{ secrets.DISCORD_URL }} + RELEASE_TAG: 'tensorflow' + + - name: Upload artifacts for cutting release + uses: actions/upload-artifact@master + with: + name: release-artifacts + path: releases/ + + - name: Notify new build upload + run: curl -X POST https://holy-bread-207a.livepeer.workers.dev diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yaml similarity index 100% rename from .github/workflows/docker.yml rename to .github/workflows/docker.yaml diff --git a/.github/workflows/git.yml b/.github/workflows/git.yaml similarity index 100% rename from .github/workflows/git.yml rename to .github/workflows/git.yaml diff --git a/.github/workflows/linux-tensorflow.yml b/.github/workflows/linux-tensorflow.yml deleted file mode 100644 index d9ad635c7c..0000000000 --- a/.github/workflows/linux-tensorflow.yml +++ /dev/null @@ -1,102 +0,0 @@ -name: Linux Tensorflow Build -on: - pull_request: - push: - branches: - - master -jobs: - build: - runs-on: ubuntu-18.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - # Needed for commands that depend on git tags - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - name: Setup Go - uses: actions/setup-go@v2 - with: - go-version: '1.17.6' - - name: Cache go modules - id: cache-go-mod - uses: actions/cache@v2.1.5 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - name: Cache ffmpeg - id: cache-ffmpeg - uses: actions/cache@v2.1.5 - with: - path: ~/compiled - key: ${{ runner.os }}-ffmpeg-tensorflow-${{ hashFiles('**/install_ffmpeg.sh') }} - restore-keys: | - ${{ runner.os }}-ffmpeg-tensorflow - - name: Cache binaries - uses: actions/cache@v2.1.5 - with: - path: ~/build - key: ${{ runner.os }}-binaries-tensorflow-${{ github.sha }} - - name: Install dependencies - run: | - sudo apt-get update \ - && sudo apt-get install -y software-properties-common curl apt-transport-https \ - && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 15CF4D18AF4F7421 \ - && sudo add-apt-repository "deb [arch=amd64] http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" \ - && sudo apt-get update \ - && sudo apt-get -y install clang-8 clang-tools-8 build-essential pkg-config autoconf gnutls-dev git python - - sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-8 30 \ - && sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8 30 - - LIBTENSORFLOW_VERSION=2.6.3 \ - && curl -LO https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-${LIBTENSORFLOW_VERSION}.tar.gz \ - && sudo tar -C /usr/local -xzf libtensorflow-gpu-linux-x86_64-${LIBTENSORFLOW_VERSION}.tar.gz \ - && sudo ldconfig - - name: Install go modules - if: steps.cache-go-mod.outputs.cache-hit != 'true' - run: go mod download - - name: Install ffmpeg - if: steps.cache-ffmpeg.outputs.cache-hit != 'true' - run: BUILD_TAGS=experimental ./install_ffmpeg.sh - - name: Build binaries - run: | - export PKG_CONFIG_PATH=~/compiled/lib/pkgconfig - ./ci_env.sh make - rm -rf ~/build && mkdir ~/build && mv livepeer* ~/build/ - env: - GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} - upload: - runs-on: ubuntu-18.04 - needs: [build] - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - # Needed for commands that depend on git tags - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - name: Install libtensorflow - run: | - LIBTENSORFLOW_VERSION=2.6.3 \ - && curl -LO https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-${LIBTENSORFLOW_VERSION}.tar.gz \ - && sudo tar -C /usr/local -xzf libtensorflow-gpu-linux-x86_64-${LIBTENSORFLOW_VERSION}.tar.gz \ - && sudo ldconfig - - name: Cache binaries - uses: actions/cache@v2.1.5 - with: - path: ~/build - key: ${{ runner.os }}-binaries-tensorflow-${{ github.sha }} - - name: Upload build - run: cp ~/build/* . && ./upload_build.sh - env: - GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} - GCLOUD_KEY: ${{ secrets.GCLOUD_KEY }} - GCLOUD_SECRET: ${{ secrets.GCLOUD_SECRET }} - DISCORD_URL: ${{ secrets.DISCORD_URL }} - RELEASE_TAG: 'tensorflow' - - name: Notify new build upload - run: curl -X POST https://holy-bread-207a.livepeer.workers.dev diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml deleted file mode 100644 index 9dc05ae4c6..0000000000 --- a/.github/workflows/linux.yml +++ /dev/null @@ -1,146 +0,0 @@ -name: Linux Build -on: - pull_request: - push: - branches: - - master -jobs: - build: - runs-on: ubuntu-18.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - # Needed for commands that depend on git tags - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - name: Setup Go - uses: actions/setup-go@v2 - with: - go-version: '1.17.6' - - name: Cache go modules - id: cache-go-mod - uses: actions/cache@v2.1.5 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - name: Cache ffmpeg - id: cache-ffmpeg - uses: actions/cache@v2.1.5 - with: - path: ~/compiled - key: ${{ runner.os }}-ffmpeg-${{ hashFiles('**/install_ffmpeg.sh') }} - restore-keys: | - ${{ runner.os }}-ffmpeg - - name: Cache binaries - uses: actions/cache@v2.1.5 - with: - path: ~/build - key: ${{ runner.os }}-binaries-${{ github.sha }} - - name: Install dependencies - run: | - sudo apt-get update \ - && sudo apt-get install -y software-properties-common curl apt-transport-https \ - && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 15CF4D18AF4F7421 \ - && sudo add-apt-repository "deb [arch=amd64] http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" \ - && sudo apt-get update \ - && sudo apt-get -y install clang-8 clang-tools-8 build-essential pkg-config autoconf git python - - sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-8 30 \ - && sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8 30 - - name: Install go modules - if: steps.cache-go-mod.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 - run: | - export PKG_CONFIG_PATH=~/compiled/lib/pkgconfig - ./ci_env.sh make - rm -rf ~/build && mkdir ~/build && mv livepeer* ~/build/ - env: - GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} - test: - runs-on: ubuntu-18.04 - needs: build - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.sha }} - lfs: 'true' - - name: Setup Go - uses: actions/setup-go@v2 - with: - go-version: '1.17.6' - - name: Install protobuf - run: | - go install github.com/golang/protobuf/protoc-gen-go@v1.3.5 - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y protobuf-compiler - - name: Cache go modules - id: cache-go-mod - uses: actions/cache@v2.1.5 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - name: Cache ffmpeg - id: cache-ffmpeg - uses: actions/cache@v2.1.5 - with: - path: ~/compiled - key: ${{ runner.os }}-ffmpeg-${{ hashFiles('**/install_ffmpeg.sh') }} - restore-keys: | - ${{ runner.os }}-ffmpeg - - name: go fmt - run: | - go fmt ./... - git diff --exit-code - - name: Compile proto files - run: | - protoc --version - touch net/lp_rpc.proto net/redeemer.proto - make net/lp_rpc.pb.go net/redeemer.pb.go - git diff --exit-code - - name: Lint - run: | - export PKG_CONFIG_PATH=~/compiled/lib/pkgconfig - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.39.0 - golangci-lint run --disable-all --enable=gofmt --enable=vet --enable=golint --deadline=4m pm verification - - name: Run tests - shell: bash - run: | - export PKG_CONFIG_PATH=~/compiled/lib/pkgconfig - ./test.sh - upload: - runs-on: ubuntu-18.04 - needs: [build, test] - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - # Needed for commands that depend on git tags - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - name: Cache binaries - uses: actions/cache@v2.1.5 - with: - path: ~/build - key: ${{ runner.os }}-binaries-${{ github.sha }} - - name: Upload build - run: cp ~/build/* . && ./upload_build.sh - env: - GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} - GCLOUD_KEY: ${{ secrets.GCLOUD_KEY }} - GCLOUD_SECRET: ${{ secrets.GCLOUD_SECRET }} - DISCORD_URL: ${{ secrets.DISCORD_URL }} - - name: Notify new build upload - run: curl -X POST https://holy-bread-207a.livepeer.workers.dev diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml deleted file mode 100644 index f18de81048..0000000000 --- a/.github/workflows/mac.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: MacOS Build -on: - pull_request: - push: - branches: - - master -jobs: - build: - strategy: - matrix: - arch: - - amd64 - - arm64 - runs-on: macos-latest - steps: - - name: Set build environment - run: echo "GOARCH=${{ matrix.arch }}" >> $GITHUB_ENV - - name: Checkout - uses: actions/checkout@v2 - with: - # Needed for commands that depend on git tags - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - name: Setup Go - uses: actions/setup-go@v2 - with: - go-version: '1.17.6' - - name: Cache go modules - id: cache-go-mod - uses: actions/cache@v2.1.5 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-${{ matrix.arch }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.arch }}-go- - - name: Cache ffmpeg - id: cache-ffmpeg - uses: actions/cache@v2.1.5 - with: - path: ~/compiled - key: ${{ runner.os }}-${{ matrix.arch }}-ffmpeg-${{ hashFiles('**/install_ffmpeg.sh') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.arch }}-ffmpeg - - name: Install dependencies - run: brew install coreutils - - name: Install go modules - if: steps.cache-go-mod.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 - run: | - export PKG_CONFIG_PATH=~/compiled/lib/pkgconfig - ./ci_env.sh make - env: - GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} - - name: Upload build - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository - env: - GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} - GCLOUD_KEY: ${{ secrets.GCLOUD_KEY }} - GCLOUD_SECRET: ${{ secrets.GCLOUD_SECRET }} - DISCORD_URL: ${{ secrets.DISCORD_URL }} - run: ./upload_build.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000000..3072bd15b4 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,49 @@ +name: Create release on github + +on: + workflow_run: + workflows: + - Build binaries + types: + - "completed" + +jobs: + release: + runs-on: ubuntu-20.04 + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: checkout + uses: actions/checkout@master + with: + fetch-depth: 0 + ref: ${{ github.event.workflow_run.head_branch }} + + - name: Download artifacts from build stage + uses: dawidd6/action-download-artifact@v2 + with: + workflow: build.yaml + name: release-artifacts + path: releases/ + + - 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.event.workflow_run.head_branch }} + gpg-key: ${{ secrets.CI_GPG_SIGNING_KEY }} + gpg-key-passphrase: ${{ secrets.CI_GPG_SIGNING_PASSPHRASE }} + + - uses: actions-ecosystem/action-regex-match@v2 + id: match-tag + with: + text: ${{ github.event.workflow_run.head_branch }} + regex: '^v([0-9]+\.\d+\.\d+)$' + + - name: Release to github + uses: softprops/action-gh-release@v1 + if: ${{ steps.match-tag.outputs.match != '' }} + with: + generate_release_notes: true + tag_name: ${{ github.event.workflow_run.head_branch }} + files: | + releases/* diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000000..f538edb0b1 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,96 @@ +name: Trigger test suite + +on: + pull_request: + push: + branches: + - master + +jobs: + test: + runs-on: ubuntu-18.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} + lfs: 'true' + + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: '1.17.6' + + - name: Install protobuf + run: | + go install github.com/golang/protobuf/protoc-gen-go@v1.3.5 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y protobuf-compiler + + - name: Cache go modules + id: cache-go-mod + uses: actions/cache@v2.1.5 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Cache ffmpeg + id: cache-ffmpeg + uses: actions/cache@v2.1.5 + with: + path: ~/compiled + key: ${{ runner.os }}-ffmpeg-${{ hashFiles('**/install_ffmpeg.sh') }} + restore-keys: | + ${{ runner.os }}-ffmpeg + + - name: Install dependencies + run: | + sudo apt-get update \ + && sudo apt-get install -y software-properties-common curl apt-transport-https \ + && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 15CF4D18AF4F7421 \ + && sudo add-apt-repository "deb [arch=amd64] http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" \ + && sudo apt-get update \ + && sudo apt-get -y install clang-8 clang-tools-8 build-essential pkg-config autoconf git python + + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-8 30 \ + && sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8 30 + + - name: Install go modules + if: steps.cache-go-mod.outputs.cache-hit != 'true' + run: go mod download + + - name: Install ffmpeg + if: steps.cache-ffmpeg.outputs.cache-hit != 'true' + run: ./install_ffmpeg.sh + + - name: go fmt + run: | + go fmt ./... + git diff --exit-code + + - name: Compile proto files + run: | + protoc --version + touch net/lp_rpc.proto net/redeemer.proto + make net/lp_rpc.pb.go net/redeemer.pb.go + git diff --exit-code + + - name: Lint + run: | + export PKG_CONFIG_PATH=~/compiled/lib/pkgconfig + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.39.0 + golangci-lint run --disable-all --enable=gofmt --enable=vet --enable=golint --deadline=4m pm verification + + - name: Run tests + shell: bash + run: | + export PKG_CONFIG_PATH=~/compiled/lib/pkgconfig + ./test.sh diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index 95eaa84536..0000000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Windows Build -on: - pull_request: - push: - branches: - - master -jobs: - build: - runs-on: windows-latest - steps: - - name: configure git line endings - run: git config --global core.autocrlf false - - uses: actions/checkout@v2 - with: - # Needed for commands that depend on git tags - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - name: Setup Msys2 environment - uses: msys2/setup-msys2@v2 - with: - msystem: MSYS - - name: Prepare mingw64 environment - shell: msys2 {0} - run: ./prepare_mingw64.sh - - name: Build ffmpeg - shell: msys2 {0} - run: ./install_ffmpeg.sh - # For some reason the next step sometimes cannot find protoc - # - name: Install protoc - # uses: arduino/setup-protoc@v1 - # We do not just run `make` because it would also require protoc - # Due to the issue described above with finding protoc, for now we just specify the individual binaries - - name: Build binaries - shell: msys2 {0} - run: ./ci_env.sh make livepeer livepeer_cli livepeer_bench livepeer_router - - name: Upload build - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository - shell: msys2 {0} - env: - GHA_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} - GCLOUD_KEY: ${{ secrets.GCLOUD_KEY }} - GCLOUD_SECRET: ${{ secrets.GCLOUD_SECRET }} - DISCORD_URL: ${{ secrets.DISCORD_URL }} - run: ./upload_build.sh diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 38d5e2ab12..ffd26e4efa 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -8,6 +8,8 @@ #### General +- \#2282 Add checksums and gpg signature support with binary releases. (@hjpotter92) + #### Broadcaster #### Orchestrator diff --git a/cmd/livepeer_bench/livepeer_bench.go b/cmd/livepeer_bench/livepeer_bench.go old mode 100755 new mode 100644 diff --git a/go.mod b/go.mod index daad8e9847..ba802e5d7e 100644 --- a/go.mod +++ b/go.mod @@ -39,6 +39,7 @@ require ( golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect + golang.org/x/tools v0.1.9 // indirect google.golang.org/api v0.44.0 google.golang.org/grpc v1.38.0 pgregory.net/rapid v0.4.0 diff --git a/go.sum b/go.sum index e076d47e16..2de16dfa4c 100644 --- a/go.sum +++ b/go.sum @@ -419,8 +419,6 @@ github.com/livepeer/joy4 v0.1.2-0.20191121080656-b2fea45cbded h1:ZQlvR5RB4nfT+cO github.com/livepeer/joy4 v0.1.2-0.20191121080656-b2fea45cbded/go.mod h1:xkDdm+akniYxVT9KW1Y2Y7Hso6aW+rZObz3nrA9yTHw= github.com/livepeer/livepeer-data v0.4.11 h1:Sv+ss8e4vcscnMWLxcRJ2g3sNIHyQ3RzCtgEelfGPzw= github.com/livepeer/livepeer-data v0.4.11/go.mod h1:VIbJRdyH2Tas8EgLVkP79IPMepFDOv0dgHYLEZsCaf4= -github.com/livepeer/lpms v0.0.0-20220202164815-ec799c43e5fc h1:BFGTqR948H8U6Hw9uiorjMoM8qAdp3V1hPZAiJ6lO+o= -github.com/livepeer/lpms v0.0.0-20220202164815-ec799c43e5fc/go.mod h1:Hr/JhxxPDipOVd4ZrGYWrdJfpVF8/SEI0nNr2ctAlkM= github.com/livepeer/lpms v0.0.0-20220209162529-44fe3cdd2790 h1:ZArRP3s+eVBPc32Bj+T2+vptpfywqAxwmcC+o3/cVio= github.com/livepeer/lpms v0.0.0-20220209162529-44fe3cdd2790/go.mod h1:Hr/JhxxPDipOVd4ZrGYWrdJfpVF8/SEI0nNr2ctAlkM= github.com/livepeer/m3u8 v0.11.1 h1:VkUJzfNTyjy9mqsgp5JPvouwna8wGZMvd/gAfT5FinU= @@ -627,6 +625,7 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ= @@ -702,8 +701,9 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= +golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -749,6 +749,7 @@ golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLd golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -845,6 +846,7 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= @@ -856,8 +858,9 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -920,8 +923,9 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.2 h1:kRBLX7v7Af8W7Gdbbc908OJcdgtK8bOz9Uaj8/F1ACA= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.9 h1:j9KsMiaP1c3B0OTQGth0/k+miLGTgLsAFUCrF2vLcF8= +golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index e09a089d7e..aead7ddbc3 --- a/install.sh +++ b/install.sh @@ -1,11 +1,78 @@ #!/usr/bin/env bash -os=$([ $(uname | grep 'Darwin') ] && echo 'darwin' || echo 'linux'); -curl -s https://api.github.com/repos/livepeer/go-livepeer/releases/latest \ - | grep browser_download_url \ - | grep "${os}.tar" \ - | cut -d '"' -f 4 \ - | xargs -n 1 curl -L \ - | tar xz \ - && cp -R "livepeer_${os}/." /usr/local/bin \ - && rm -rf "livepeer_${os}"; +set -e + +PLATFORM="$([ $(uname | grep -i "Darwin") ] && echo 'darwin' || echo 'linux')" +VERSION="${1:-latest}" +GPG_VERIFICATION_KEY="A2F9039A8603C44C21414432A2224D4537874DB2" +LP_TMP_DIR="$(mktemp -d)" +GPG_VERIFY="${GPG_VERIFY:-true}" +SHA_VERIFY="${SHA_VERIFY:-true}" + +if ! command -v curl >/dev/null; then + echo >&2 "Could not find 'curl'. Please install and run the script again." + exit 1 +fi + +if ! command -v gpg >/dev/null; then + echo >&2 "Could not find 'gpg'. Signature verification will be skipped." + GPG_VERIFY="false" +fi + +if [[ "$VERSION" == "latest" ]]; then + VERSION="$(curl https://api.github.com/repos/livepeer/go-livepeer/releases/latest 2>/dev/null | grep -F '"name": "v' | cut -d '"' -f4)" +else + VERSION="v${VERSION}" +fi + +get_system_architecture() { + local arch="$(uname -m)" + case "$arch" in + aarch64 | aarch64_be | arm*) + arch="arm64" + ;; + x86_64) + arch="amd64" + ;; + esac + printf "%s" "$arch" +} + +get_archive_name() { + printf "livepeer-%s-%s.tar.gz" "$PLATFORM" "$(get_system_architecture)" +} + +get_download_url() { + printf "https://github.com/livepeer/go-livepeer/releases/download/${VERSION}" +} + +download_files() { + curl -sLO "$(get_download_url)/$(get_archive_name)" 2>/dev/null + curl -sLO "$(get_download_url)/${VERSION}_checksums.txt" 2>/dev/null + if [[ "$GPG_VERIFY" == "true" ]]; then + curl -sLO "$(get_download_url)/$(get_archive_name).sig" 2>/dev/null + fi +} + +verify_download() { + if [[ "$SHA_VERIFY" == "true" ]]; then + sha256sum --ignore-missing -c "${VERSION}_checksums.txt" + fi + if [[ "$GPG_VERIFY" == "true" ]]; then + gpg --keyserver keyserver.ubuntu.com --recv-keys "${GPG_VERIFICATION_KEY}" + gpg --verify "$(get_archive_name).sig" "$(get_archive_name)" + fi +} + +install_to_path() { + local archive_name="$(get_archive_name)" + tar xzf "${archive_name}" + mv "${archive_name%%.*}/*" /usr/local/bin/ +} + +cd "$LP_TMP_DIR" +download_files +verify_download +install_to_path +cd - +rm -rf "$LP_TMP_DIR" diff --git a/test.sh b/test.sh index b77eece224..422ee67dff 100755 --- a/test.sh +++ b/test.sh @@ -4,7 +4,7 @@ set -eux #Test script to run all the tests for continuous integration -go test ./... +go test -coverprofile cover.out ./... cd core # Be more strict with load balancer tests: run with race detector enabled diff --git a/upload_build.sh b/upload_build.sh index 057cdfed46..bc8e73aafd 100755 --- a/upload_build.sh +++ b/upload_build.sh @@ -5,6 +5,13 @@ set -e set -o nounset +BASE_DIR="$(realpath $(dirname "$0"))" + +cd "$BASE_DIR" +RELEASES_DIR="${BASE_DIR}/${RELEASES_DIR:-releases}/" + +mkdir -p "$RELEASES_DIR" + if [[ $(uname) == *"MSYS"* ]]; then PLATFORM="windows" EXT=".exe" @@ -12,10 +19,12 @@ else PLATFORM=$(uname | tr '[:upper:]' '[:lower:]') EXT="" if [[ -n "${RELEASE_TAG:-}" ]]; then - PLATFORM="$PLATFORM-$RELEASE_TAG" + PLATFORM="$PLATFORM-$RELEASE_TAG" fi fi + ARCH="$(uname -m)" + if [[ "${GOARCH:-}" != "" ]]; then ARCH="$GOARCH" fi @@ -33,7 +42,7 @@ fi BASE="livepeer-$PLATFORM-$ARCH" BRANCH="${TRAVIS_BRANCH:-unknown}" if [[ "${GHA_REF:-}" != "" ]]; then - BRANCH="$(echo $GHA_REF | sed 's/refs\/heads\///')" + BRANCH="$(echo $GHA_REF | sed 's:refs/heads/::')" fi VERSION="$(./print_version.sh)" if echo $VERSION | grep dirty; then @@ -59,22 +68,21 @@ CLI="./livepeer_cli${EXT}" BENCH="./livepeer_bench${EXT}" ROUTER="./livepeer_router${EXT}" -mkdir $BASE -cp $NODE $BASE -cp $CLI $BASE -cp $BENCH $BASE -cp $ROUTER $BASE +mkdir -p "${BASE_DIR}/$BASE" +cp "$NODE" "$CLI" "$BENCH" "$ROUTER" "${BASE_DIR}/$BASE" # do a basic upload so we know if stuff's working prior to doing everything else if [[ $PLATFORM == "windows" ]]; then - FILE=$BASE.zip - zip -r ./$FILE ./$BASE + FILE="$BASE.zip" + zip -r "${RELEASES_DIR}/$FILE" ./$BASE else - FILE=$BASE.tar.gz - tar -czvf ./$FILE ./$BASE + FILE="$BASE.tar.gz" + tar -czvf "${RELEASES_DIR}/$FILE" ./$BASE fi -FILE_SHA256=`shasum -a 256 ${FILE}` +cd "$RELEASES_DIR" + +FILE_SHA256=$(shasum -a 256 ${FILE}) if [[ "${GCLOUD_KEY:-}" == "" ]]; then echo "GCLOUD_KEY not found, not uploading to Google Cloud." @@ -85,9 +93,9 @@ fi bucket=build.livepeer.live resource="/${bucket}/${VERSION_AND_NETWORK}/${FILE}" contentType="application/x-compressed-tar" -dateValue=`date -R` +dateValue="$(date -R)" stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}" -signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${GCLOUD_SECRET} -binary | base64` +signature="$(echo -en ${stringToSign} | openssl sha1 -hmac ${GCLOUD_SECRET} -binary | base64)" fullUrl="https://storage.googleapis.com${resource}" # Failsafe - don't overwrite existing uploads! @@ -105,5 +113,8 @@ curl -X PUT -T "${FILE}" \ echo "upload done" -curl --fail -s -H "Content-Type: application/json" -X POST -d "{\"content\": \"Build succeeded ✅\nBranch: $BRANCH\nPlatform: $PLATFORM-$ARCH\nLast commit: $(git log -1 --pretty=format:'%s by %an')\nhttps://build.livepeer.live/$VERSION_AND_NETWORK/${FILE}\nSHA256:\n${FILE_SHA256}\"}" $DISCORD_URL +curl -X POST --fail -s \ + -H "Content-Type: application/json" \ + -d "{\"content\": \"Build succeeded ✅\nBranch: $BRANCH\nPlatform: $PLATFORM-$ARCH\nLast commit: $(git log -1 --pretty=format:'%s by %an')\nhttps://build.livepeer.live/$VERSION_AND_NETWORK/${FILE}\nSHA256:\n${FILE_SHA256}\"}" \ + $DISCORD_URL echo "done"