Merge pull request #290 from peer-calls/jeremija/upgrade-pion #774
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
# This workflow will do a clean install of node and go dependencies, and run the CI scripts | |
name: Peer Calls CI | |
on: | |
push: | |
branches: '*' | |
tags: | |
- v4* | |
pull_request: | |
branches: [master] | |
env: | |
IMAGE_NAME: peer-calls | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: make lint | |
nodejs: | |
needs: | |
- lint | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: ["20.11"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- run: npm ci | |
- run: npm run ci | |
- name: Upload client-side artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
path: build | |
go: | |
runs-on: ubuntu-latest | |
needs: | |
- lint | |
strategy: | |
matrix: | |
go-version: ["1.21.6"] | |
services: | |
redis: | |
# Docker Hub image | |
image: redis | |
# Set health checks to wait until redis has started | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 6379:6379 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Go ${{ matrix.go-version }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- run: touch build/index.js build/style.css | |
- run: go test -p 1 ./... -race -coverprofile=coverage.out -v | |
- run: go tool cover -func=coverage.out | |
build: | |
runs-on: ubuntu-latest | |
needs: | |
- nodejs | |
- go | |
strategy: | |
matrix: | |
go-version: ["1.21.6"] | |
steps: | |
- name: Use Go ${{ matrix.go-version }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- uses: actions/checkout@v4 | |
- name: Download client-side artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build | |
path: build | |
- run: find build/ | |
- run: mkdir -p build/release | |
- run: echo "git_describe=$(git describe --always --tags)" >> $GITHUB_ENV | |
- run: echo $git_describe | |
- run: export GOOS=linux GOARCH=amd64; go build -ldflags "-X main.GitDescribe=$git_describe" -o build/release/peercalls.$GOOS.$GOARCH main.go | |
- run: export GOOS=linux GOARCH=arm; go build -ldflags "-X main.GitDescribe=$git_describe" -o build/release/peercalls.$GOOS.$GOARCH main.go | |
- run: export GOOS=darwin GOARCH=amd64; go build -ldflags "-X main.GitDescribe=$git_describe" -o build/release/peercalls.$GOOS.$GOARCH main.go | |
- run: export GOOS=windows GOARCH=amd64; go build -ldflags "-X main.GitDescribe=$git_describe" -o build/release/peercalls.$GOOS.$GOARCH.exe main.go | |
- name: Release | |
if: startsWith(github.ref, 'refs/tags/v') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
set -xeu | |
sha7=${GITHUB_SHA:7} | |
assets=() | |
cd build/release | |
for asset in ./*; do | |
archive=$asset.$git_describe.tar.gz | |
tar czvf $archive $asset | |
assets+=("$archive") | |
done | |
args=() | |
if [[ $git_describe =~ alpha|beta ]]; then | |
args+=("--prerelease") | |
fi | |
gh release create "${args[@]}" --target $GITHUB_SHA --generate-notes --title "PeerCalls $git_describe" "$git_describe" "${assets[@]}" | |
docker: | |
runs-on: ubuntu-latest | |
needs: | |
- nodejs | |
- go | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build image | |
run: docker build . --build-arg VERSION="$(git describe --always --tags --dirty)" --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" | |
- name: Log in to registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Push image | |
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master' | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
# Strip git ref prefix from version | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# Strip "v" prefix from tag name | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
# Use Docker `latest` tag convention | |
[ "$VERSION" == "master" ] && VERSION=latest | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION |