179 lines
5.3 KiB
YAML
179 lines
5.3 KiB
YAML
name: Build
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- main
|
|
jobs:
|
|
build_and_test:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ windows-latest, ubuntu-latest, macos-latest ]
|
|
steps:
|
|
- name: Get the sources
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Setup .NET Core
|
|
uses: actions/setup-dotnet@v1
|
|
with:
|
|
dotnet-version: 6.0.x
|
|
|
|
- name: Clean
|
|
run: dotnet clean --configuration Release && dotnet nuget locals all --clear
|
|
|
|
- name: Install dependencies
|
|
run: dotnet restore
|
|
|
|
- name: Build
|
|
run: dotnet build --configuration Release --no-restore
|
|
|
|
- name: Test
|
|
run: dotnet test --no-restore --verbosity normal
|
|
build_and_upload:
|
|
name: Build & Upload Develop Artifacts
|
|
needs: build_and_test
|
|
runs-on: ${{ matrix.os }}
|
|
if: github.event_name == 'push' && !contains(github.event.head_commit.message, '[no build]')
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-latest
|
|
kind: linux
|
|
target: linux-x64
|
|
- os: ubuntu-latest
|
|
kind: linux
|
|
target: linux-arm
|
|
- os: windows-latest
|
|
kind: windows
|
|
target: win-x64
|
|
- os: macos-latest
|
|
kind: macOS
|
|
target: osx-x64
|
|
- os: macos-latest
|
|
kind: macOS
|
|
target: osx-arm64
|
|
steps:
|
|
- name: Get the sources
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch_depth: 0
|
|
|
|
- name: Setup .NET Core
|
|
uses: actions/setup-dotnet@v1
|
|
with:
|
|
dotnet-version: 6.0.x
|
|
|
|
- name: Clean
|
|
run: dotnet clean --configuration Release && dotnet nuget locals all --clear
|
|
|
|
- name: Install dependencies
|
|
run: dotnet restore
|
|
|
|
- name: Build
|
|
shell: bash
|
|
run: |
|
|
# Define some variables for things we need
|
|
tag=$(git describe --tags --abbrev=0)
|
|
tag2="${tag:1}"
|
|
short=$(git rev-parse --short HEAD)
|
|
final="${tag2/alpha/$short}"
|
|
release_name="ErsatzTV-$final-${{ matrix.target }}"
|
|
|
|
# Build everything
|
|
dotnet publish ErsatzTV/ErsatzTV.csproj --framework net6.0 --runtime "${{ matrix.target }}" -c Release -o "$release_name" /property:InformationalVersion="$final-${{ matrix.target }}" /property:EnableCompressionInSingleFile=true /property:DebugType=Embedded /property:PublishSingleFile=true --self-contained true
|
|
|
|
# Pack files
|
|
if [ "${{ matrix.target }}" == "win-x64" ]; then
|
|
7z a -tzip "${release_name}.zip" "./${release_name}/*"
|
|
else
|
|
tar czvf "${release_name}.tar.gz" "$release_name"
|
|
fi
|
|
|
|
# Delete output directory
|
|
rm -r "$release_name"
|
|
- name: Upload
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
path: |
|
|
ErsatzTV*.zip
|
|
ErsatzTV*.tar.gz
|
|
build_and_push:
|
|
name: Build & Publish to Docker Hub
|
|
needs: build_and_test
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'push' && !contains(github.event.head_commit.message, '[no build]')
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Extract Git Tag
|
|
shell: bash
|
|
run: |
|
|
tag=$(git describe --tags --abbrev=0)
|
|
tag2="${tag:1}"
|
|
short=$(git rev-parse --short HEAD)
|
|
final="${tag2/alpha/$short}"
|
|
echo "GIT_TAG=${final}" >> $GITHUB_ENV
|
|
|
|
- name: Set up Docker Buildx Base
|
|
uses: docker/setup-buildx-action@v1
|
|
id: builder-base
|
|
|
|
- name: Set up Docker Buildx NVIDIA
|
|
uses: docker/setup-buildx-action@v1
|
|
id: builder-nvidia
|
|
|
|
- name: Set up Docker Buildx VAAPI
|
|
uses: docker/setup-buildx-action@v1
|
|
id: builder-vaapi
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
|
|
|
- name: Build and push base
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
builder: ${{ steps.builder-base.outputs.name }}
|
|
context: .
|
|
file: ./docker/Dockerfile
|
|
push: true
|
|
build-args: |
|
|
INFO_VERSION=${{ env.GIT_TAG }}-docker
|
|
tags: |
|
|
jasongdove/ersatztv:develop
|
|
jasongdove/ersatztv:${{ github.sha }}
|
|
|
|
- name: Build and push nvidia
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
builder: ${{ steps.builder-nvidia.outputs.name }}
|
|
context: .
|
|
file: ./docker/nvidia/Dockerfile
|
|
push: true
|
|
build-args: |
|
|
INFO_VERSION=${{ env.GIT_TAG }}-docker-nvidia
|
|
tags: |
|
|
jasongdove/ersatztv:develop-nvidia
|
|
jasongdove/ersatztv:${{ github.sha }}-nvidia
|
|
|
|
- name: Build and push vaapi
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
builder: ${{ steps.builder-vaapi.outputs.name }}
|
|
context: .
|
|
file: ./docker/vaapi/Dockerfile
|
|
push: true
|
|
build-args: |
|
|
INFO_VERSION=${{ env.GIT_TAG }}-docker-vaapi
|
|
tags: |
|
|
jasongdove/ersatztv:develop-vaapi
|
|
jasongdove/ersatztv:${{ github.sha }}-vaapi
|