BililiveRecorder/.github/workflows/build.yml
genteure 72a90c890f misc: update github action workflows
- removed unused workflow
- changed actions to newest versions

ref: issue #456
2023-06-17 20:11:58 +08:00

172 lines
5.2 KiB
YAML

name: Build and Test
on:
push:
branches:
- "**"
pull_request:
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
test:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: actions/setup-dotnet@v3
- name: Make sure webui can be built
if: "${{ matrix.os == 'windows-latest' }}"
run: ./webui/build.ps1
- name: Make sure webui can be built
if: "${{ matrix.os == 'ubuntu-latest' }}"
run: ./webui/build.sh
- name: Run Tests - Debug
run: dotnet test -v m -c Debug
- name: Run Tests - Release
run: dotnet test -v m -c Release
build_wpf:
needs: test
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1
- name: Restore Packages
run: msbuild -t:restore /v:m BililiveRecorder.WPF/BililiveRecorder.WPF.csproj
- name: Build WPF - Debug
run: msbuild /nologo /v:m /p:Configuration="Debug" BililiveRecorder.WPF/BililiveRecorder.WPF.csproj
- name: Build WPF - Release
run: msbuild /nologo /v:m /p:Configuration="Release" BililiveRecorder.WPF/BililiveRecorder.WPF.csproj
- name: Upload Artifacts - Debug
uses: actions/upload-artifact@v3
with:
name: WPF-Debug
path: BililiveRecorder.WPF/bin/Debug
- name: Upload Artifacts - Release
uses: actions/upload-artifact@v3
with:
name: WPF-Release
path: BililiveRecorder.WPF/bin/Release
build_cli:
needs: test
strategy:
matrix:
rid: [any, linux-arm, linux-arm64, linux-x64, osx-x64, osx-arm64, win-x64]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: actions/setup-dotnet@v3
- name: Build WebUI
run: ./webui/build.sh
- name: Build CLI - Debug
if: ${{ matrix.rid == 'any' }}
run: dotnet publish -c Debug BililiveRecorder.Cli/BililiveRecorder.Cli.csproj
- name: Build CLI - Release
if: ${{ matrix.rid == 'any' }}
run: dotnet publish -c Release BililiveRecorder.Cli/BililiveRecorder.Cli.csproj
- name: Build CLI - Debug
if: ${{ matrix.rid != 'any' }}
run: dotnet publish -c Debug -r ${{ matrix.rid }} BililiveRecorder.Cli/BililiveRecorder.Cli.csproj
- name: Build CLI - Release
if: ${{ matrix.rid != 'any' }}
run: dotnet publish -c Release -r ${{ matrix.rid }} BililiveRecorder.Cli/BililiveRecorder.Cli.csproj
- name: Upload Artifacts - Debug
uses: actions/upload-artifact@v3
with:
name: CLI-${{ matrix.rid }}-Debug
path: BililiveRecorder.Cli/publish/${{ matrix.rid }}/Debug
- name: Upload Artifacts - Release
uses: actions/upload-artifact@v3
with:
name: CLI-${{ matrix.rid }}-Release
path: BililiveRecorder.Cli/publish/${{ matrix.rid }}/Release
build_docker:
needs: test
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=edge
type=ref,event=branch
type=ref,event=pr
- name: Build WebUI
run: ./webui/build.sh
- name: Build CLI
run: dotnet build -c Release -o ./BililiveRecorder.Cli/bin/docker_out BililiveRecorder.Cli/BililiveRecorder.Cli.csproj
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.GitHubActions
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}