From 0e7bd82bb10858ced6916e3469e4d11a694d441d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E5=BD=AA?= <1315508912@qq.com> Date: Sat, 16 Dec 2023 01:00:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 163 ++++++++++++++++++++++++++++++ .gitignore | 4 +- script/aria2.sh | 30 ++++++ script/ffmpeg.sh | 50 +++++++++ script/macos/package.sh | 11 +- script/pupnet/DownKyi.pupnet.conf | 25 +++-- script/pupnet/app.desktop | 13 +++ version.txt | 1 + 8 files changed, 279 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100755 script/aria2.sh create mode 100755 script/ffmpeg.sh create mode 100644 script/pupnet/app.desktop create mode 100644 version.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..09caf2c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,163 @@ +name: Build + +on: + push: + branches: + - main + tags: + - 'v*' + +jobs: + build-windows: + runs-on: windows-latest + strategy: + matrix: + cpu: [ x64, x86 ] + kind: [ zip ] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 6.0.x + - name: Read Version Text + id: version + uses: juliangruber/read-file-action@v1 + with: + path: version.txt + - name: Install Pupnet + run: | + dotnet tool install -g KuiperZone.PupNet + - name: Get Deps + run: | + .\ffmpeg.ps1 ${{ matrix.cpu }} + .\aria2.ps1 ${{ matrix.cpu }} + working-directory: ./script + - name: Package + run: | + pupnet DownKyi.pupnet.conf --app-version ${{ steps.version.outputs.content }} --kind ${{ matrix.kind }} -r win-${{ matrix.cpu }} -y + working-directory: ./script/pupnet + - name: Upload build artifacts ${{ matrix.kind }} + uses: actions/upload-artifact@v3 + with: + name: DownKyi-${{ steps.version.outputs.content }}-1.win-${{ matrix.cpu }}.${{ matrix.kind }} + path: script/pupnet/output/DownKyi-${{ steps.version.outputs.content }}-1.win-${{ matrix.cpu }}.${{ matrix.kind }} + - name: Release + uses: ncipollo/release-action@v1 + if: ${{ startsWith(github.ref, 'refs/tags/') }} + with: + allowUpdates: true + artifacts: script/pupnet/output/DownKyi-${{ steps.version.outputs.content }}-1.win-${{ matrix.cpu }}.${{ matrix.kind }} + build-linux: + runs-on: ubuntu-latest + strategy: + matrix: + cpu: [ x64 ] + kind: [ AppImage, deb, rpm ] + include: + - kind: AppImage + cpu: x64 + package-tail: .x86_64 + - kind: deb + cpu: x64 + package-tail: .x86_64 + - kind: rpm + cpu: x64 + package-tail: .x86_64 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 6.0.x + - name: Read Version Text + id: version + uses: juliangruber/read-file-action@v1 + with: + path: version.txt + - name: Install Pupnet + run: | + dotnet tool install -g KuiperZone.PupNet + - name: Get Deps + run: | + chmod +x ffmpeg.sh + chmod +x aria2.sh + .\ffmpeg.sh linux ${{ matrix.cpu }} + .\aria2.sh linux-${{ matrix.cpu }} + working-directory: ./script + - name: Package + run: | + pupnet DownKyi.pupnet.conf --app-version ${{ steps.version.outputs.content }} --kind ${{ matrix.kind }} -r linux-${{ matrix.cpu }} -y + working-directory: ./script/pupnet + - name: Upload build artifacts ${{ matrix.kind }} + uses: actions/upload-artifact@v3 + with: + name: DownKyi-${{ steps.version.outputs.content }}-1.${{ matrix.package-tail }}.${{ matrix.kind }} + path: script/pupnet/output/DownKyi-${{ steps.version.outputs.content }}-1.${{ matrix.package-tail }}.${{ matrix.kind }} + - name: Release + uses: ncipollo/release-action@v1 + if: ${{ startsWith(github.ref, 'refs/tags/') }} + with: + allowUpdates: true + artifacts: script/pupnet/output/DownKyi-${{ steps.version.outputs.content }}-1.${{ matrix.package-tail }}.${{ matrix.kind }} + build-macos: + runs-on: macos-latest + strategy: + matrix: + cpu: [ x64, arm64 ] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install Tool Via HomeBrew + run: | + export HOMEBREW_NO_AUTO_UPDATE=true + export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=true + brew install create-dmg tree + - name: Install .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 6.0.x + - name: Read Version Text + id: version + uses: juliangruber/read-file-action@v1 + with: + path: version.txt + - name: Get Deps + run: | + chmod +x ffmpeg.sh + .\ffmpeg.ps1 mac ${{ matrix.cpu }} + - name: Build ${{ matrix.cpu }} + run: | + dotnet restore + dotnet publish DownKyi.csproj --self-contained -r osx-${{ matrix.cpu }} -c Release -p:DebugType=None -p:DebugSymbols=false + - name: Package app + run: | + chmod +x package.sh + ./package.sh ${{ matrix.cpu }} + working-directory: ./script/macos + - name: Create DMG + run: + create-dmg \ + --hdiutil-quiet \ + --icon "哔哩下载姬.app" 165 175 \ + --icon-size 120 \ + --app-drop-link 495 175 \ + --window-size 660 400 \ + "DownKyi-${{ steps.version.outputs.content }}-osx-${{ matrix.cpu }}.dmg" "./哔哩下载姬.app" + working-directory: ./script/macos + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: DownKyi-${{ steps.version.outputs.content }}-osx-${{ matrix.cpu }}.dmg + path: script/macos/DownKyi-${{ steps.version.outputs.content }}-osx-${{ matrix.cpu }}.dmg + - name: Release + uses: ncipollo/release-action@v1 + if: ${{ startsWith(github.ref, 'refs/tags/') }} + with: + allowUpdates: true + artifacts: script/macos/DownKyi-${{ steps.version.outputs.content }}-osx-${{ matrix.cpu }}.dmg \ No newline at end of file diff --git a/.gitignore b/.gitignore index 16fa717..7979d7e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,12 +7,12 @@ */**/bin DownKyi.Core/Binary/* -!DownKyi.Core/Binary/osx-x64 -!DownKyi.Core/Binary/osx-arm64 !DownKyi.Core/Binary/osx-x64/aria2/ !DownKyi.Core/Binary/osx-arm64/aria2/ script/downloads script/pupnet/output +script/macos/*.dmg +script/macos/*.app *.sln.DotSettings.user \ No newline at end of file diff --git a/script/aria2.sh b/script/aria2.sh new file mode 100755 index 0000000..0ae1623 --- /dev/null +++ b/script/aria2.sh @@ -0,0 +1,30 @@ +#!/bin/bash +download_dir="./downloads" +save_path="../DownKyi.Core/Binary" + +if [ ! -d "$download_dir" ]; then + mkdir "$download_dir" +fi + +create_dir() { + if [ ! -d "$1" ]; then + mkdir -p "$1" + fi +} + +download_aria2() { + local download_url + local save + case $1 in + linux-x64) + save="$save_path/$1/aria2" + download_url="https://github.com/abcfy2/aria2-static-build/releases/download/1.37.0/aria2-x86_64-linux-musl_static.zip" + ;; + esac + + curl -kL "$download_url" -o "$download_dir/aria2.zip" + create_dir "$save" + unzip -d "$save" "$download_dir/aria2.zip" +} + +download_aria2 "$@" diff --git a/script/ffmpeg.sh b/script/ffmpeg.sh new file mode 100755 index 0000000..037a004 --- /dev/null +++ b/script/ffmpeg.sh @@ -0,0 +1,50 @@ +#!/bin/bash +os=$1 +arch=$2 + +ffmpeg_save_path="../DownKyi.Core/Binary" +download_dir="./downloads" + +create_dir() { + if [ ! -d "$1" ]; then + mkdir -p "$1" + fi +} + +download_ffmpeg_macos() { + local url="https://github.com/eugeneware/ffmpeg-static/releases/download/b4.4.1/darwin-$arch" + create_dir "$ffmpeg_save_path/osx-$arch/ffmpeg" + curl -kL "$url" -o "$ffmpeg_save_path/osx-$arch/ffmpeg/ffmpeg" + chmod +x "$ffmpeg_save_path/osx-$arch/ffmpeg/ffmpeg" +} + +download_ffmpeg_linux() { + local realArch="" + case $arch in + x64) + realArch="amd64" + ;; + arm64) + realArch="arm64" + ;; + esac + output=$ffmpeg_save_path/linux-x64/ffmpeg + local url="https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-4.4.1-${realArch}-static.tar.xz" + if [ ! -f "ffmpeg.tar.xz" ]; then + curl -kL $url -o "${download_dir}/ffmpeg.tar.xz" + fi + + if [ ! -d "$output" ]; then + mkdir -p "$output" + fi + tar -xf "${download_dir}/ffmpeg.tar.xz" --strip-components 1 -C "$output" '*/ffmpeg' + chmod +x "$output/ffmpeg" +} + +if [ "$os" == "mac" ]; then + download_ffmpeg_macos +elif [ "$os" == "linux" ]; then + download_ffmpeg_linux +else + echo "不支持的操作系统" +fi diff --git a/script/macos/package.sh b/script/macos/package.sh index 74b7e41..fa20c25 100755 --- a/script/macos/package.sh +++ b/script/macos/package.sh @@ -1,14 +1,13 @@ #!/bin/bash +arch=$1 APP_NAME="./哔哩下载姬.app" -DMG_NAME="./DownKyi.dmg" -PUBLISH_OUTPUT_DIRECTORY="../../DownKyi/bin/Release/net6.0/osx-x64/publish/." +PUBLISH_OUTPUT_DIRECTORY="../../DownKyi/bin/Release/net6.0/osx-$arch/publish/." INFO_PLIST="./Info.plist" ICON_FILE="./logo.icns" -if [ -d "$APP_NAME" ] -then - rm -rf "$APP_NAME" +if [ -d "$APP_NAME" ]; then + rm -rf "$APP_NAME" fi mkdir "$APP_NAME" @@ -20,5 +19,3 @@ mkdir "$APP_NAME/Contents/Resources" cp "$INFO_PLIST" "$APP_NAME/Contents/Info.plist" cp "$ICON_FILE" "$APP_NAME/Contents/Resources/$ICON_FILE" cp -a "$PUBLISH_OUTPUT_DIRECTORY" "$APP_NAME/Contents/MacOS" - -create-dmg --hdiutil-quiet --icon "哔哩下载姬.app" 165 175 --icon-size 120 --app-drop-link 495 175 --window-size 660 400 $DMG_NAME $APP_NAME \ No newline at end of file diff --git a/script/pupnet/DownKyi.pupnet.conf b/script/pupnet/DownKyi.pupnet.conf index d6930fa..5c089a6 100644 --- a/script/pupnet/DownKyi.pupnet.conf +++ b/script/pupnet/DownKyi.pupnet.conf @@ -6,11 +6,11 @@ AppShortSummary = Cross-platform deployment utility which packages your .NET pro AppLicenseId = GPL-3.0-or-later AppLicenseFile = ../../LICENSE -OutputDirectory = output/ + IconFiles = """ ../../DownKyi/Resources/favicon.ico """ - +DesktopFile = app.desktop # PUBLISHER PublisherName = yaobiao131 PublisherCopyright = Copyright (C) yaobiao131 2023 @@ -19,17 +19,24 @@ PublisherLinkUrl = https://github.com/yaobiao131/downkyicore PublisherEmail = contact@kuiper.zone DotnetProjectPath = ../../ +# Package Out +OutputDirectory = output/ +PackageName = DownKyi + +# AppImage +AppImageVersionOutput = true + # FLATPAK OPTIONS FlatpakPlatformRuntime = org.freedesktop.Platform FlatpakPlatformSdk = org.freedesktop.Sdk FlatpakPlatformVersion = 22.08 -FlatpakFinishArgs = """ - --socket=wayland - --socket=x11 - --filesystem=host - --share=network -""" -FlatpakBuilderArgs = +; FlatpakFinishArgs = """ +; --socket=wayland +; --socket=x11 +; --filesystem=host +; --share=network +; """ +; FlatpakBuilderArgs = DotnetPublishArgs = -p:Version=${APP_VERSION} --self-contained true -p:DebugType=None -p:DebugSymbols=false diff --git a/script/pupnet/app.desktop b/script/pupnet/app.desktop new file mode 100644 index 0000000..bfb3efb --- /dev/null +++ b/script/pupnet/app.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Type=Application +Name=${APP_FRIENDLY_NAME} +Icon=${APP_ID} +Comment=${APP_SHORT_SUMMARY} +Exec=env LANG=en_US.UTF-8 ${INSTALL_EXEC} +TryExec=${INSTALL_EXEC} +NoDisplay=${DESKTOP_NODISPLAY} +X-AppImage-Integrate=${DESKTOP_INTEGRATE} +Terminal=${DESKTOP_TERMINAL} +Categories=${PRIME_CATEGORY} +MimeType= +Keywords= \ No newline at end of file diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..afaf360 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +1.0.0 \ No newline at end of file