mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-12-25 11:54:43 +08:00
192 lines
6.4 KiB
YAML
192 lines
6.4 KiB
YAML
name: Release
|
|
|
|
on:
|
|
release:
|
|
types: [published]
|
|
|
|
env:
|
|
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
|
|
DOTNET_CLI_TELEMETRY_OPTOUT: true
|
|
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
|
|
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
|
|
|
|
release_wpf:
|
|
needs: test # Tests must be passed before releasing
|
|
strategy:
|
|
matrix:
|
|
build_configuration: [Release]
|
|
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
|
|
run: msbuild /nologo /v:m /p:Configuration="${{ matrix.build_configuration }}" BililiveRecorder.WPF/BililiveRecorder.WPF.csproj
|
|
- name: Upload Build Artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: WPF-${{ matrix.build_configuration }}
|
|
path: BililiveRecorder.WPF/bin/${{ matrix.build_configuration }}
|
|
- name: Upload Packed Artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: WPF-NupkgReleases
|
|
path: BililiveRecorder.WPF/bin/NupkgReleases
|
|
- name: Pack Portable Zip File
|
|
run: |
|
|
cd BililiveRecorder.WPF/bin/${{ matrix.build_configuration }}
|
|
7z a BililiveRecorder-WPF-Portable.zip .
|
|
- name: Upload Portable Zip File
|
|
uses: shogo82148/actions-upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ github.event.release.upload_url }}
|
|
asset_path: BililiveRecorder.WPF/bin/${{ matrix.build_configuration }}/BililiveRecorder-WPF-Portable.zip
|
|
asset_name: BililiveRecorder-WPF-Portable.zip
|
|
asset_content_type: application/zip
|
|
|
|
release_cli:
|
|
needs: test # Tests must be passed before releasing
|
|
strategy:
|
|
matrix:
|
|
rid: [any, linux-arm, linux-arm64, linux-x64, osx-x64, osx-arm64, win-x64]
|
|
build_configuration: [Release]
|
|
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
|
|
if: ${{ matrix.rid == 'any' }}
|
|
run: dotnet publish -c ${{ matrix.build_configuration }} BililiveRecorder.Cli/BililiveRecorder.Cli.csproj
|
|
- name: Build CLI
|
|
if: ${{ matrix.rid != 'any' }}
|
|
run: dotnet publish -c ${{ matrix.build_configuration }} -r ${{ matrix.rid }} BililiveRecorder.Cli/BililiveRecorder.Cli.csproj
|
|
|
|
- name: Upload Artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: CLI-${{ matrix.rid }}-${{ matrix.build_configuration }}
|
|
path: BililiveRecorder.Cli/publish/${{ matrix.rid }}/Release
|
|
|
|
- name: Pack Release Asset
|
|
run: |
|
|
cd BililiveRecorder.Cli/publish/${{ matrix.rid }}/Release
|
|
zip -r /tmp/CLI-${{ matrix.rid }}-${{ matrix.build_configuration }}.zip .
|
|
|
|
- name: Upload Release Asset
|
|
uses: shogo82148/actions-upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ github.event.release.upload_url }}
|
|
asset_path: /tmp/CLI-${{ matrix.rid }}-${{ matrix.build_configuration }}.zip
|
|
asset_name: BililiveRecorder-CLI-${{ matrix.rid }}.zip
|
|
asset_content_type: application/zip
|
|
|
|
release_docker:
|
|
needs: test # Tests must be passed before releasing
|
|
runs-on: ubuntu-latest
|
|
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
|
|
|
|
# Login against a Docker registry except on PR
|
|
# https://github.com/docker/login-action
|
|
- 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 }}
|
|
- name: Login to Docker Hub
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/login-action@v2
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_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 }}
|
|
bililive/recorder
|
|
tags: |
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=semver,pattern={{major}}
|
|
|
|
- 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 }}
|