name: Build and Test on: push: 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@v2 with: fetch-depth: 0 - uses: actions/setup-dotnet@v2 - 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@v2 with: fetch-depth: 0 - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.1 - 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@v2 with: name: WPF-Debug path: BililiveRecorder.WPF/bin/Debug - name: Upload Artifacts - Release uses: actions/upload-artifact@v2 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, win-x64] runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 - uses: actions/setup-dotnet@v2 - 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@v2 with: name: CLI-${{ matrix.rid }}-Debug path: BililiveRecorder.Cli/publish/${{ matrix.rid }}/Debug - name: Upload Artifacts - Release uses: actions/upload-artifact@v2 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@v2 with: fetch-depth: 0 - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - 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@v3 with: images: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - 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@v2 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 }}