2021-02-26 21:57:10 +08:00
|
|
|
name: Release
|
|
|
|
|
|
|
|
on:
|
|
|
|
release:
|
|
|
|
types: [published]
|
|
|
|
|
2021-03-10 18:14:57 +08:00
|
|
|
env:
|
|
|
|
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
|
|
|
|
DOTNET_CLI_TELEMETRY_OPTOUT: true
|
2022-06-04 14:16:20 +08:00
|
|
|
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
|
2021-06-07 22:02:48 +08:00
|
|
|
REGISTRY: ghcr.io
|
|
|
|
IMAGE_NAME: ${{ github.repository }}
|
2021-03-10 18:14:57 +08:00
|
|
|
|
2021-02-26 21:57:10 +08:00
|
|
|
jobs:
|
|
|
|
test:
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os: [windows-latest, ubuntu-latest]
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-06-17 20:11:58 +08:00
|
|
|
uses: actions/checkout@v3
|
2021-02-26 21:57:10 +08:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2022-06-04 03:39:33 +08:00
|
|
|
submodules: recursive
|
2022-05-26 23:11:37 +08:00
|
|
|
|
2023-06-17 20:11:58 +08:00
|
|
|
- uses: actions/setup-dotnet@v3
|
2022-05-26 23:11:37 +08:00
|
|
|
|
2022-06-04 03:39:33 +08:00
|
|
|
- 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
|
|
|
|
|
2022-05-26 23:11:37 +08:00
|
|
|
- name: Run Tests - Debug
|
|
|
|
run: dotnet test -v m -c Debug
|
|
|
|
- name: Run Tests - Release
|
|
|
|
run: dotnet test -v m -c Release
|
2021-02-26 21:57:10 +08:00
|
|
|
|
|
|
|
release_wpf:
|
2023-06-17 20:31:25 +08:00
|
|
|
needs: test # Tests must be passed before releasing
|
2021-02-26 21:57:10 +08:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
build_configuration: [Release]
|
|
|
|
runs-on: windows-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-06-17 20:11:58 +08:00
|
|
|
uses: actions/checkout@v3
|
2021-02-26 21:57:10 +08:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2022-06-04 03:39:33 +08:00
|
|
|
submodules: recursive
|
2021-02-26 22:30:10 +08:00
|
|
|
- name: Add msbuild to PATH
|
2023-06-17 20:11:58 +08:00
|
|
|
uses: microsoft/setup-msbuild@v1
|
2021-02-26 21:57:10 +08:00
|
|
|
- name: Restore Packages
|
2022-06-04 14:16:20 +08:00
|
|
|
run: msbuild -t:restore /v:m BililiveRecorder.WPF/BililiveRecorder.WPF.csproj
|
2021-02-26 21:57:10 +08:00
|
|
|
- name: Build WPF
|
2022-06-04 14:16:20 +08:00
|
|
|
run: msbuild /nologo /v:m /p:Configuration="${{ matrix.build_configuration }}" BililiveRecorder.WPF/BililiveRecorder.WPF.csproj
|
2021-05-14 17:08:37 +08:00
|
|
|
- name: Upload Build Artifacts
|
2023-06-17 20:11:58 +08:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-02-26 21:57:10 +08:00
|
|
|
with:
|
|
|
|
name: WPF-${{ matrix.build_configuration }}
|
|
|
|
path: BililiveRecorder.WPF/bin/${{ matrix.build_configuration }}
|
2021-05-14 17:08:37 +08:00
|
|
|
- name: Upload Packed Artifacts
|
2023-06-17 20:11:58 +08:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-05-14 17:08:37 +08:00
|
|
|
with:
|
|
|
|
name: WPF-NupkgReleases
|
|
|
|
path: BililiveRecorder.WPF/bin/NupkgReleases
|
|
|
|
- name: Pack Portable Zip File
|
2021-05-14 17:25:19 +08:00
|
|
|
run: |
|
|
|
|
cd BililiveRecorder.WPF/bin/${{ matrix.build_configuration }}
|
|
|
|
7z a BililiveRecorder-WPF-Portable.zip .
|
2021-05-14 17:08:37 +08:00
|
|
|
- name: Upload Portable Zip File
|
2023-10-27 23:03:56 +08:00
|
|
|
uses: shogo82148/actions-upload-release-asset@v1
|
2021-02-26 21:57:10 +08:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
upload_url: ${{ github.event.release.upload_url }}
|
2021-05-14 17:25:19 +08:00
|
|
|
asset_path: BililiveRecorder.WPF/bin/${{ matrix.build_configuration }}/BililiveRecorder-WPF-Portable.zip
|
2021-02-26 21:57:10 +08:00
|
|
|
asset_name: BililiveRecorder-WPF-Portable.zip
|
|
|
|
asset_content_type: application/zip
|
|
|
|
|
|
|
|
release_cli:
|
2023-06-17 20:31:25 +08:00
|
|
|
needs: test # Tests must be passed before releasing
|
2021-02-26 21:57:10 +08:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-06-14 19:41:29 +08:00
|
|
|
rid: [any, linux-arm, linux-arm64, linux-x64, osx-x64, osx-arm64, win-x64]
|
2021-02-26 21:57:10 +08:00
|
|
|
build_configuration: [Release]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-06-17 20:11:58 +08:00
|
|
|
uses: actions/checkout@v3
|
2021-02-26 21:57:10 +08:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2022-06-04 03:39:33 +08:00
|
|
|
submodules: recursive
|
|
|
|
|
2023-06-17 20:11:58 +08:00
|
|
|
- uses: actions/setup-dotnet@v3
|
2022-06-04 03:39:33 +08:00
|
|
|
|
|
|
|
- name: Build WebUI
|
|
|
|
run: ./webui/build.sh
|
|
|
|
|
2021-02-26 21:57:10 +08:00
|
|
|
- name: Build CLI
|
|
|
|
if: ${{ matrix.rid == 'any' }}
|
2021-02-26 22:25:35 +08:00
|
|
|
run: dotnet publish -c ${{ matrix.build_configuration }} BililiveRecorder.Cli/BililiveRecorder.Cli.csproj
|
2021-02-26 21:57:10 +08:00
|
|
|
- name: Build CLI
|
|
|
|
if: ${{ matrix.rid != 'any' }}
|
2021-02-26 22:25:35 +08:00
|
|
|
run: dotnet publish -c ${{ matrix.build_configuration }} -r ${{ matrix.rid }} BililiveRecorder.Cli/BililiveRecorder.Cli.csproj
|
2022-06-04 03:39:33 +08:00
|
|
|
|
2021-02-26 21:57:10 +08:00
|
|
|
- name: Upload Artifacts
|
2023-06-17 20:11:58 +08:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-02-26 21:57:10 +08:00
|
|
|
with:
|
|
|
|
name: CLI-${{ matrix.rid }}-${{ matrix.build_configuration }}
|
2022-07-07 21:44:07 +08:00
|
|
|
path: BililiveRecorder.Cli/publish/${{ matrix.rid }}/Release
|
2022-06-04 03:39:33 +08:00
|
|
|
|
2021-02-26 21:57:10 +08:00
|
|
|
- name: Pack Release Asset
|
|
|
|
run: |
|
2022-07-07 21:44:07 +08:00
|
|
|
cd BililiveRecorder.Cli/publish/${{ matrix.rid }}/Release
|
2022-07-07 22:00:07 +08:00
|
|
|
zip -r /tmp/CLI-${{ matrix.rid }}-${{ matrix.build_configuration }}.zip .
|
2022-06-04 03:39:33 +08:00
|
|
|
|
2021-02-26 21:57:10 +08:00
|
|
|
- name: Upload Release Asset
|
2023-10-27 23:03:56 +08:00
|
|
|
uses: shogo82148/actions-upload-release-asset@v1
|
2021-02-26 21:57:10 +08:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
upload_url: ${{ github.event.release.upload_url }}
|
2022-07-07 22:00:07 +08:00
|
|
|
asset_path: /tmp/CLI-${{ matrix.rid }}-${{ matrix.build_configuration }}.zip
|
2021-02-26 21:57:10 +08:00
|
|
|
asset_name: BililiveRecorder-CLI-${{ matrix.rid }}.zip
|
|
|
|
asset_content_type: application/zip
|
2021-06-07 22:02:48 +08:00
|
|
|
|
|
|
|
release_docker:
|
2023-06-17 20:31:25 +08:00
|
|
|
needs: test # Tests must be passed before releasing
|
2021-06-07 22:02:48 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2023-06-17 20:11:58 +08:00
|
|
|
uses: actions/checkout@v3
|
2021-06-07 22:02:48 +08:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2022-06-04 03:39:33 +08:00
|
|
|
submodules: recursive
|
2021-06-07 22:02:48 +08:00
|
|
|
- name: Set up QEMU
|
2023-06-17 20:11:58 +08:00
|
|
|
uses: docker/setup-qemu-action@v2
|
2021-06-07 22:02:48 +08:00
|
|
|
- name: Set up Docker Buildx
|
2023-06-17 20:11:58 +08:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2022-06-10 14:34:06 +08:00
|
|
|
|
2021-06-07 22:02:48 +08:00
|
|
|
# Login against a Docker registry except on PR
|
|
|
|
# https://github.com/docker/login-action
|
2022-05-19 18:11:03 +08:00
|
|
|
- name: Login to GitHub Container Registry
|
2021-06-07 22:02:48 +08:00
|
|
|
if: github.event_name != 'pull_request'
|
2022-05-19 18:11:03 +08:00
|
|
|
uses: docker/login-action@v2
|
2021-06-07 22:02:48 +08:00
|
|
|
with:
|
2022-05-19 18:11:03 +08:00
|
|
|
registry: ghcr.io
|
2021-06-07 22:02:48 +08:00
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
2022-05-19 18:11:03 +08:00
|
|
|
- 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 }}
|
2022-06-10 14:34:06 +08:00
|
|
|
|
2021-06-07 22:02:48 +08:00
|
|
|
# Extract metadata (tags, labels) for Docker
|
|
|
|
# https://github.com/docker/metadata-action
|
|
|
|
- name: Extract Docker metadata
|
|
|
|
id: meta
|
2023-06-17 20:11:58 +08:00
|
|
|
uses: docker/metadata-action@v4
|
2021-06-07 22:02:48 +08:00
|
|
|
with:
|
2022-05-19 18:11:03 +08:00
|
|
|
images: |
|
|
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
|
|
bililive/recorder
|
2022-06-10 14:34:06 +08:00
|
|
|
tags: |
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
type=semver,pattern={{major}}
|
|
|
|
|
2022-06-04 03:39:33 +08:00
|
|
|
- name: Build WebUI
|
|
|
|
run: ./webui/build.sh
|
2021-06-17 23:41:41 +08:00
|
|
|
- name: Build CLI
|
|
|
|
run: dotnet build -c Release -o ./BililiveRecorder.Cli/bin/docker_out BililiveRecorder.Cli/BililiveRecorder.Cli.csproj
|
2021-06-07 22:02:48 +08:00
|
|
|
# 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
|
2023-06-17 20:11:58 +08:00
|
|
|
uses: docker/build-push-action@v4
|
2021-06-07 22:02:48 +08:00
|
|
|
with:
|
|
|
|
context: .
|
2021-06-17 23:41:41 +08:00
|
|
|
file: ./Dockerfile.GitHubActions
|
|
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
2021-06-07 22:02:48 +08:00
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|