diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6472816..7bf9bf4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -8,31 +8,16 @@ on: jobs: build: - strategy: - inputs: - dotnet-version: - required: false - default: "6.0.x" - description: "The .NET version to setup for the build" - type: string - dotnet-target: - required: false - default: "net6.0" - description: "The .NET target to set for JPRM" - type: string - runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3.1.0 - - - name: Setup .NET - uses: actions/setup-dotnet@45c9f236cf9a0c09d11298348f6ed06bd81914c0 # tag=v3.0.1 + - uses: actions/checkout@v3 + - name: Setup dotnet + uses: actions/setup-dotnet@v1 with: - dotnet-version: "${{ inputs.dotnet-version }}" + dotnet-version: 6.0.x - name: Build Jellyfin Plugin - uses: oddstr13/jellyfin-plugin-repository-manager@a7795e010e63a6dcbbd5e6d8274f801d021f1045 # tag=v0.5.0 + uses: oddstr13/jellyfin-plugin-repository-manager@v0.5.0 id: jprm with: - dotnet-target: "${{ inputs.dotnet-target }}" + dotnet-target: "net6.0" diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 7c82e04..087847c 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -6,126 +6,35 @@ on: jobs: build: - strategy: - inputs: - version: - required: true - type: string - is-unstable: - required: false - default: false - type: boolean - dotnet-version: - required: false - default: "6.0.x" - description: "The .NET version to setup for the build" - type: string - dotnet-target: - required: false - default: "net6.0" - description: "The .NET target to set for JPRM" - type: string - secrets: - deploy-host: - required: true - deploy-user: - required: true - deploy-key: - required: true - runs-on: ubuntu-latest + name: Build & Release + steps: - - name: Checkout Repository - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3.1.0 - - - name: Setup .NET - uses: actions/setup-dotnet@45c9f236cf9a0c09d11298348f6ed06bd81914c0 # tag=v3.0.1 + - uses: actions/checkout@v3 + - name: Setup dotnet + uses: actions/setup-dotnet@v1 with: - dotnet-version: "${{ inputs.dotnet-version }}" - - - name: Build Jellyfin Plugin - uses: oddstr13/jellyfin-plugin-repository-manager@a7795e010e63a6dcbbd5e6d8274f801d021f1045 # tag=v0.5.0 - id: jprm + dotnet-version: 6.0.x + - name: Restore nuget packages + run: dotnet restore Shokofin/Shokofin.csproj + - name: Setup python + uses: actions/setup-python@v2 with: - dotnet-target: "${{ inputs.dotnet-target }}" - - - name: Upload Artifact - uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=v3.1.0 + python-version: 3.8 + - name: Install JPRM + run: python -m pip install jprm + - name: Run JPRM + run: python build_plugin.py --version=${GITHUB_REF#refs/*/} + - name: Update release + uses: svenstaro/upload-release-action@v2 with: - name: build-artifact - retention-days: 30 - if-no-files-found: error - path: ${{ steps.jprm.outputs.artifact }} - - upload: - needs: - - build - runs-on: ubuntu-latest - steps: - - name: Download Artifact - uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # tag=v3.0.0 + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./artifacts/danmu_*.zip + tag: ${{ github.ref }} + file_glob: true + - name: Update manifest + uses: stefanzweifel/git-auto-commit-action@v4 with: - name: build-artifact - - - name: Prepare GH Release Assets - run: |- - for file in ./*; do - md5sum ${file#./} >> ${file%.*}.md5 - sha256sum ${file#./} >> ${file%.*}.sha256 - done - ls -l - - - name: Upload GH Release Assets - uses: shogo82148/actions-upload-release-asset@8dbaa4469aa7256e70624d72f2567fac8f5341b3 # tag=v1.6.2 - with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: ./* - - - name: Ensure Destination Path Exists - uses: appleboy/ssh-action@f9010ff7f1bbd7db1a0b4bab661437550cea20c0 # tag=v0.1.5 - if: ${{ contains(github.repository, 'jellyfin/') }} - with: - host: ${{ secrets.deploy-host }} - username: ${{ secrets.deploy-user }} - key: ${{ secrets.deploy-key }} - script_stop: true - script: |- - mkdir -p "/srv/repository/incoming/plugin/${{ github.repository }}/${{ inputs.version }}" || exit 1 - - - name: Upload Jellyfin Plugin Repository Assets - uses: burnett01/rsync-deployments@0dc935cdecc5f5e571865e60d2a6cdc673704823 # tag=5.2 - if: ${{ contains(github.repository, 'jellyfin/') }} - with: - switches: -vrptz - path: ./*.zip - remote_path: /srv/repository/incoming/plugin/${{ github.repository }}/${{ inputs.version }} - remote_host: ${{ secrets.deploy-host }} - remote_user: ${{ secrets.deploy-user }} - remote_key: ${{ secrets.deploy-key }} - - publish: - needs: - - upload - runs-on: ubuntu-latest - if: ${{ contains(github.repository, 'jellyfin/') }} - env: - JELLYFIN_REPO: "/srv/repository/mirror/releases/plugin/manifest-stable.json" - JELLYFIN_REPO_URL: "https://repo.jellyfin.org/releases/plugin/" - steps: - - name: Update Plugin Manifest - uses: appleboy/ssh-action@f9010ff7f1bbd7db1a0b4bab661437550cea20c0 # tag=v0.1.5 - with: - host: ${{ secrets.deploy-host }} - username: ${{ secrets.deploy-user }} - key: ${{ secrets.deploy-key }} - script_stop: true - envs: JELLYFIN_REPO,JELLYFIN_REPO_URL - script: |- - lockfile="/run/lock/jprm.lock" - pushd "/srv/repository/incoming/plugin/${{ github.repository }}/${{ inputs.version }}" || exit 1 - ( - flock -x 300 - jprm --verbosity=debug repo add --url="${JELLYFIN_REPO_URL}" "${JELLYFIN_REPO}" ./*.zip || exit 1 - ) 300>${lockfile} - popd || exit 1 - rm -r "/srv/repository/incoming/plugin/${{ github.repository }}/${{ inputs.version }}" || exit 1 + branch: master + commit_message: Update repo manifest + file_pattern: manifest.json diff --git a/build.yaml b/build.yaml index 2e3c3c7..d90bb03 100644 --- a/build.yaml +++ b/build.yaml @@ -1,16 +1,13 @@ ---- -name: "Template" +name: "Danmu" guid: "5B39DA44-5314-4940-8E26-54C821C17F86" -version: "1.0.0.0" +imageUrl: https://github.com/cxfksword/jellyfin-plugin-danmu/raw/main/doc/logo.png targetAbi: "10.8.0.0" -framework: "net6.0" -overview: "Short description about your plugin" +owner: "cxfksword" +overview: "jellyfin弹幕下载插件" description: > - This is a longer description that can span more than one - line and include details about your plugin. -category: "General" -owner: "jellyfin" + jellyfin的b站弹幕自动下载插件,会匹配b站番剧/电影视频,自动下载对应弹幕,并定时更新。 +category: "Metadata" artifacts: - - "Jellyfin.Plugin.Danmu.dll" + - "Danmu.dll" changelog: > - changelog + NA diff --git a/build_plugin.py b/build_plugin.py new file mode 100644 index 0000000..076a359 --- /dev/null +++ b/build_plugin.py @@ -0,0 +1,36 @@ +import os +import sys +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument('--version', required=True) +parser.add_argument('--prerelease') +opts = parser.parse_args() + +version = opts.version +prerelease = bool(opts.prerelease) + +artifact_dir = os.path.join(os.getcwd(), 'artifacts') +os.mkdir(artifact_dir) + +if prerelease: + jellyfin_repo_file = "./manifest-unstable.json" + version_list = version.split('.') + if len(version_list) == 3: + version_list.append('1') + else: + version_list[3] = str(int(version_list[3]) + 1) + version = '.'.join(version_list) +else: + jellyfin_repo_file = "./manifest.json" + +jellyfin_repo_url = "https://github.com/cxfksword/jellyfin-plugin-danmu/releases/download" + +zipfile = os.popen('jprm --verbosity=debug plugin build "." --output="%s" --version="%s" --dotnet-framework="net6.0"' % + (artifact_dir, version)).read().strip() + +os.system('jprm repo add --url=%s %s %s' % (jellyfin_repo_url, jellyfin_repo_file, zipfile)) + +os.system('sed -i "s/danmu\//%s\//" %s' % (version, jellyfin_repo_file)) + +print(version)