From 13025ae05a4bd7887eb9aba669cf462e01fd3394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B1=B3?= Date: Tue, 9 Apr 2024 01:55:50 +0800 Subject: [PATCH] update --- .github/workflows/DDTV_CLI.yml | 34 ------- .github/workflows/DDTV_Core.yml | 36 ------- .../{DDTV_Dev_CLI.yml => DDTV_Dev.yml} | 96 ++++++++++++++++++- .github/workflows/DDTV_GUI.yml | 55 ----------- .github/workflows/DDTV_Release_CLI.yml | 62 ------------ .github/workflows/DDTV_WEB_Server.yml | 34 ------- 6 files changed, 94 insertions(+), 223 deletions(-) delete mode 100644 .github/workflows/DDTV_CLI.yml delete mode 100644 .github/workflows/DDTV_Core.yml rename .github/workflows/{DDTV_Dev_CLI.yml => DDTV_Dev.yml} (64%) delete mode 100644 .github/workflows/DDTV_GUI.yml delete mode 100644 .github/workflows/DDTV_Release_CLI.yml delete mode 100644 .github/workflows/DDTV_WEB_Server.yml diff --git a/.github/workflows/DDTV_CLI.yml b/.github/workflows/DDTV_CLI.yml deleted file mode 100644 index 25f43b8f0..000000000 --- a/.github/workflows/DDTV_CLI.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: DDTV_CLI - -on: - push: - branches: [ master ] - paths: - - 'DDTV_CLI/**' - - '.github/workflows/DDTV_CLI.yml' - - '!**/README.md' - pull_request: - branches: [ master ] - paths: - - 'DDTV_CLI/**' - - '.github/workflows/DDTV_CLI.yml' - - '!**/README.md' - -jobs: - build: - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v2 - - name: Setup .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '6.0.x' - - name: Restore dependencies - run: cd DDTV_CLI && dotnet restore - - name: Build - run: cd DDTV_CLI && dotnet build --no-restore diff --git a/.github/workflows/DDTV_Core.yml b/.github/workflows/DDTV_Core.yml deleted file mode 100644 index f012565f6..000000000 --- a/.github/workflows/DDTV_Core.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: DDTV_Core - -on: - push: - branches: [ master ] - paths: - - 'DDTV_Core/**' - - 'BiliAccount/**' - - '.github/workflows/DDTV_Core.yml' - - '!**/README.md' - pull_request: - branches: [ master ] - paths: - - 'DDTV_Core/**' - - 'BiliAccount/**' - - '.github/workflows/DDTV_Core.yml' - - '!**/README.md' - -jobs: - build: - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v2 - - name: Setup .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '6.0.x' - - name: Restore dependencies - run: cd DDTV_Core && dotnet restore - - name: Build - run: cd DDTV_Core && dotnet build --no-restore diff --git a/.github/workflows/DDTV_Dev_CLI.yml b/.github/workflows/DDTV_Dev.yml similarity index 64% rename from .github/workflows/DDTV_Dev_CLI.yml rename to .github/workflows/DDTV_Dev.yml index d30d5a79d..8c28c7689 100644 --- a/.github/workflows/DDTV_Dev_CLI.yml +++ b/.github/workflows/DDTV_Dev.yml @@ -1,4 +1,4 @@ -name: CLI_Dev +name: Dev on: push: @@ -8,11 +8,13 @@ on: paths: - 'CLI/**' - '.github/workflows/DDTV_Dev_CLI.yml' + - 'GUI/**' + - '.github/workflows/DDTV_Dev_GUI.yml' - '!**/README.md' workflow_dispatch: jobs: - build: + CLI: strategy: matrix: include: @@ -174,3 +176,93 @@ jobs: runtime: ${{ matrix.runtime }} image_id: ${{ contains(matrix.runtime, 'musl') && 'alpine' || 'debian' }} build-args: REPO=mcr.microsoft.com/dotnet/runtime-deps:${{ contains(matrix.runtime, 'musl') && '8.0-alpine' || '8.0' }} + + GUI: + strategy: + matrix: + include: + - os: windows-latest + runtime: win-x86 + - os: windows-latest + runtime: win-x64 + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Use .NET 8.x + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.x' + + - name: Download and extract latest release (Windows) + if: runner.os == 'Windows' + run: | + mkdir static + $header = @{ + Authorization = "Bearer ${{ secrets.GITHUB_TOKEN }}" + } + $url = Invoke-RestMethod -Uri https://api.github.com/repos/moehuhu/DDTV_GUI_React/releases/latest -Headers $header + $fileUrl = $url.assets | Where-Object { $_.name -match "ddtv-gui-react_v.*\.zip" } | Select-Object -ExpandProperty browser_download_url + Invoke-WebRequest -Uri $fileUrl -OutFile ddtv-gui-react.zip -Headers $header + Expand-Archive -Path ddtv-gui-react.zip -DestinationPath static + Remove-Item -Path ddtv-gui-react.zip + shell: powershell + + - name: Replace string with current date (Windows) + if: runner.os == 'Windows' + run: | + $beijingTime = [System.TimeZoneInfo]::ConvertTimeFromUtc((Get-Date).ToUniversalTime(), [System.TimeZoneInfo]::FindSystemTimeZoneById('China Standard Time')) + $current_date = $beijingTime.ToString("yyyy-MM-dd") + $current_time = $beijingTime.ToString("HH:mm:ss") + $combined_date_time = "$current_date $current_time" + Write-Output $combined_date_time + (Get-Content Core/Init.cs) -replace 'CompilationTime', $combined_date_time | Set-Content Core/Init.cs + + - name: Replace VerString (Windows) + if: runner.os == 'Windows' + run: | + $TAG_NAME = "${env:GITHUB_REF}".Replace("refs/tags/", "") + $VERSION_NUMBER = $TAG_NAME -replace ".*?(\d+\.\d+\.\d+).*", '$1' + $COMMIT_COUNT = git rev-list --count HEAD + $FINAL_VERSION = "$VERSION_NUMBER.$COMMIT_COUNT" + Write-Output $FINAL_VERSION + (Get-Content Core/Core.csproj) | Foreach-Object { $_ -replace "5.0.0.0", $FINAL_VERSION } | Set-Content Core/Core.csproj + (Get-Content CLI/CLI.csproj) | Foreach-Object { $_ -replace "5.0.0.0", $FINAL_VERSION } | Set-Content CLI/CLI.csproj + (Get-Content GUI/GUI.csproj) | Foreach-Object { $_ -replace "5.0.0.0", $FINAL_VERSION } | Set-Content GUI/GUI.csproj + + shell: pwsh + + - name: Build + run: cd GUI && dotnet publish --runtime ${{ matrix.runtime }} --configuration Release --self-contained true --output build_output + + - name: Copy static folder to build_output + run: cp -r static GUI/build_output/static + + - name: Copy ffmpeg.exe (Windows) + if: matrix.os == 'windows-latest' + run: | + mkdir GUI\\build_output\\plugins\\plugins\\ffmpeg + copy GUI\\plugins\\ffmpeg\\ffmpeg.exe GUI\\build_output\\plugins\\plugins\\ffmpeg\\ffmpeg.exe + + - name: Move all files to bin folder and create shortcut (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + Get-ChildItem -Path "GUI/build_output" | Move-Item -Destination "GUI/build_output/bin" + echo "Creating shortcut for GUI.exe" + $WshShell = New-Object -comObject WScript.Shell + $Shortcut = $WshShell.CreateShortcut("GUI\build_output\DDTV_GUI.lnk") + $Shortcut.TargetPath = "C:\Windows\explorer.exe" + $Shortcut.Arguments="bin\GUI.exe" + $Shortcut.Save() + + - name: Archive production artifacts + uses: actions/upload-artifact@v4 + with: + name: DDTV-GUI-${{ matrix.os }}-${{ matrix.runtime }} + path: GUI/build_output diff --git a/.github/workflows/DDTV_GUI.yml b/.github/workflows/DDTV_GUI.yml deleted file mode 100644 index 618683f5e..000000000 --- a/.github/workflows/DDTV_GUI.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: DDTV_GUI - -on: - push: - branches: [ master ] - paths: - - 'DDTV_GUI/**' - - '.github/workflows/DDTV_GUI.yml' - - '!**/README.md' - pull_request: - branches: [ master ] - paths: - - 'DDTV_GUI/**' - - '.github/workflows/DDTV_GUI.yml' - - '!**/README.md' - -jobs: - - build: - - strategy: - matrix: - configuration: [Release] - - runs-on: windows-latest # For a list of available runner types, refer to - # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on - - env: - Solution_Name: DDTV.sln # Replace with your solution name, i.e. MyWpfApp.sln. - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - # Install the .NET Core workload - - name: Install .NET Core - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 6.0.x - - # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - - name: Setup MSBuild.exe - uses: microsoft/setup-msbuild@v1.0.2 - - - name: Setup NuGet - uses: nuget/setup-nuget@v1 - - - name: Restore NuGet Packages - run: nuget restore $env:Solution_Name - - - name: Build App - run: cd DDTV_GUI && msbuild /property:Configuration=$env:Configuration /p:DebugType=None - env: - Configuration: ${{ matrix.configuration }} diff --git a/.github/workflows/DDTV_Release_CLI.yml b/.github/workflows/DDTV_Release_CLI.yml deleted file mode 100644 index 20ac9a640..000000000 --- a/.github/workflows/DDTV_Release_CLI.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Release CLI -on: - push: - tags: - - "Ver5*" -jobs: - build: - strategy: - matrix: - include: - - os: ubuntu-latest - runtime: linux-x64 - - os: ubuntu-latest - runtime: linux-arm - - os: windows-latest - runtime: win-x64 - - os: macOS-latest - runtime: osx-arm64 - - runs-on: ${{ matrix.os }} - permissions: - contents: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Use .NET 8.x - uses: actions/setup-dotnet@v3 - with: - dotnet-version: '8.x' - - - name: Build - run: cd CLI && dotnet publish --runtime ${{ matrix.runtime }} --configuration Release --self-contained true --output build_output - - - name: Copy ffmpeg.exe (Windows) - if: matrix.os == 'windows-latest' - run: | - mkdir CLI\\build_output\\plugins\\ffmpeg - copy CLI\\plugins\\ffmpeg\\ffmpeg.exe CLI\\build_output\\plugins\\ffmpeg\\ffmpeg.exe - - - name: Archive production artifacts - uses: actions/upload-artifact@v4 - with: - name: DDTV-CLI-${{ matrix.os }}-${{ matrix.runtime }} - path: CLI/build_output - - - name: Zip Artifacts - if: matrix.os != 'windows-latest' - run: | - cd CLI/build_output - zip -r ../../DDTV-CLI-${{ matrix.os }}-${{ matrix.runtime }}.zip * - - - name: Zip Artifacts (Windows) - if: matrix.os == 'windows-latest' - run: | - Compress-Archive -Path CLI\build_output\* -DestinationPath DDTV-CLI-${{ matrix.os }}-${{ matrix.runtime }}.zip - - - name: Upload Release Asset - id: upload-release-asset - uses: softprops/action-gh-release@v1 - with: - files: DDTV-CLI-${{ matrix.os }}-${{ matrix.runtime }}.zip diff --git a/.github/workflows/DDTV_WEB_Server.yml b/.github/workflows/DDTV_WEB_Server.yml deleted file mode 100644 index 65face6d7..000000000 --- a/.github/workflows/DDTV_WEB_Server.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: DDTV_WEB_Server - -on: - push: - branches: [ master ] - paths: - - 'DDTV_WEB_Server/**' - - '.github/workflows/DDTV_WEB_Server.yml' - - '!**/README.md' - pull_request: - branches: [ master ] - paths: - - 'DDTV_WEB_Server/**' - - '.github/workflows/DDTV_WEB_Server.yml' - - '!**/README.md' - -jobs: - build: - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v2 - - name: Setup .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '6.0.x' - - name: Restore dependencies - run: cd DDTV_WEB_Server && dotnet restore - - name: Build - run: cd DDTV_WEB_Server && dotnet build --no-restore