Update build script

This commit is contained in:
cxfksword 2022-10-25 16:43:09 +08:00
parent a964167a04
commit 7d14da34ae
9 changed files with 88 additions and 74 deletions

View File

@ -17,6 +17,6 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: dotnet restore run: dotnet restore
- name: Build - name: Build
run: dotnet build --configuration Release --no-restore run: dotnet build --no-restore
# - name: Test # - name: Test
# run: dotnet test --no-restore --verbosity normal # run: dotnet test --no-restore --verbosity normal

View File

@ -8,9 +8,7 @@ env:
dotnet-version: 6.0.x dotnet-version: 6.0.x
python-version: 3.8 python-version: 3.8
project: Jellyfin.Plugin.MetaShark/Jellyfin.Plugin.MetaShark.csproj project: Jellyfin.Plugin.MetaShark/Jellyfin.Plugin.MetaShark.csproj
branch: main
artifact: metashark artifact: metashark
manifest: https://github.com/cxfksword/jellyfin-plugin-metashark/releases/download/manifest/manifest.json
jobs: jobs:
build: build:
@ -25,8 +23,24 @@ jobs:
uses: actions/setup-dotnet@v3 uses: actions/setup-dotnet@v3
with: with:
dotnet-version: ${{ env.dotnet-version }} dotnet-version: ${{ env.dotnet-version }}
- name: Restore nuget packages - name: Initialize workflow variables
run: dotnet restore ${{ env.project }} # 需要指定项目要不然会同时build多个项目导致出错 id: vars
run: |
VERSION=$(echo "${GITHUB_REF#refs/*/}" | sed s/^v//)
VERSION="$VERSION.0"
echo ::set-output name=VERSION::${VERSION}
echo ::set-output name=APP_NAME::$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')
- name: Install dependencies
run: dotnet restore ${{ env.project }} --no-cache
- name: Build
run: dotnet publish --nologo --no-restore --configuration=Release --framework=net6.0 --output=artifacts -p:Version=${{steps.vars.outputs.VERSION}} ${{ env.project }}
- name: Compress build files
uses: thedoctor0/zip-release@main
with:
type: "zip"
directory: "artifacts"
filename: "artifacts.zip"
exclusions: "*.json *.pdb"
- name: Setup python - name: Setup python
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
@ -34,25 +48,19 @@ jobs:
- name: Install JPRM - name: Install JPRM
run: python -m pip install jprm run: python -m pip install jprm
- name: Run JPRM - name: Run JPRM
run: chmod +x ./build_plugin.sh && ./build_plugin.sh ${{ env.artifact }} ${GITHUB_REF#refs/*/} run: chmod +x ./build_plugin.sh && ./build_plugin.sh ${{ env.artifact }} ${{steps.vars.outputs.VERSION}} ${GITHUB_REF#refs/*/}
- name: Update release - name: Publish release
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./artifacts/${{ env.artifact }}_*.zip file: ./${{ env.artifact }}/${{ env.artifact }}_*.zip
tag: ${{ github.ref }} tag: ${{ github.ref }}
file_glob: true file_glob: true
- name: Update manifest - name: Publish manifest
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./*.json file: ./manifest*.json
tag: "manifest" tag: "manifest"
overwrite: true overwrite: true
file_glob: true file_glob: true
# - name: Update manifest
# uses: stefanzweifel/git-auto-commit-action@v4
# with:
# branch: ${{ env.branch }}
# commit_message: Update repo manifest
# file_pattern: "*.json"

3
.gitignore vendored
View File

@ -4,3 +4,6 @@ obj/
.idea/ .idea/
artifacts artifacts
**/.DS_Store **/.DS_Store
metashark/
manifest_cn.json
manifest.json

View File

@ -8,23 +8,29 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AnalysisMode>AllEnabledByDefault</AnalysisMode> <AnalysisMode>AllEnabledByDefault</AnalysisMode>
<CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AngleSharp" Version="0.17.1" /> <PackageReference Include="AngleSharp" Version="0.17.1" />
<PackageReference Include="AnitomySharp" Version="0.2.0" /> <PackageReference Include="AnitomySharp" Version="0.2.0" />
<PackageReference Include="Jellyfin.Controller" Version="10.8.0" /> <PackageReference Include="Newtonsoft.Json" Version="10.0.3">
<PackageReference Include="Jellyfin.Model" Version="10.8.0" /> <ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Jellyfin.Controller" Version="10.8.0">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Jellyfin.Model" Version="10.8.0">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -29,7 +29,7 @@ jellyfin电影元数据插件影片信息只要从豆瓣获取并由TMDB
```sh ```sh
$ dotnet restore $ dotnet restore
$ dotnet publish Jellyfin.Plugin.MetaShark/Jellyfin.Plugin.MetaShark.csproj $ dotnet publish -c Release Jellyfin.Plugin.MetaShark/Jellyfin.Plugin.MetaShark.csproj
``` ```
@ -37,7 +37,7 @@ $ dotnet publish Jellyfin.Plugin.MetaShark/Jellyfin.Plugin.MetaShark.csproj
1. Build the plugin 1. Build the plugin
2. Create a folder, like `metashark` and copy `bin/Release/Jellyfin.Plugin.MetaShark.dll` into it 2. Create a folder, like `metashark` and copy `bin/Release/net6.0/*.dll` into it
3. Move folder `metashark` to jellyfin `data/plugin` folder 3. Move folder `metashark` to jellyfin `data/plugin` folder

13
build.meta.json Normal file
View File

@ -0,0 +1,13 @@
{
"category": "Metadata",
"changelog": "NA",
"description": "jellyfin电影元数据插件影片信息只要从豆瓣获取并由TMDB补充缺失的季数据和剧集数据。",
"guid": "9a19103f-16f7-4668-be54-9a1e7a4f7556",
"imageUrl": "https://github.com/cxfksword/jellyfin-plugin-metashark/raw/main/doc/logo.png",
"name": "MetaShark",
"overview": "jellyfin电影元数据插件",
"owner": "cxfksword",
"targetAbi": "10.8.0.0",
"timestamp": "1970-01-01T00:00:00Z",
"version": "1.0.0.0"
}

View File

@ -1,15 +0,0 @@
name: "MetaShark"
guid: "9A19103F-16F7-4668-BE54-9A1E7A4F7556"
imageUrl: https://github.com/cxfksword/jellyfin-plugin-metashark/raw/main/doc/logo.png
version: "1.0.0.0"
targetAbi: "10.8.0.0"
framework: "net6.0"
owner: "cxfksword"
overview: "jellyfin电影元数据插件"
description: >
jellyfin电影元数据插件影片信息只要从豆瓣获取并由TMDB补充缺失的季数据和剧集数据。
category: "Metadata"
artifacts:
- "Jellyfin.Plugin.MetaShark.dll"
changelog: >
NA

27
build_plugin.sh Normal file → Executable file
View File

@ -2,21 +2,18 @@
# $1 from github action # $1 from github action
ARTIFACT=$1 ARTIFACT=$1
TAG=$2 VERSION=$2
TAG=$3
CURRENT_DATE=$(date +'%Y-%m-%dT%H:%M:%S')
WORK_DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P) WORK_DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
ARTIFACT_DIR="${WORK_DIR}/artifacts" ARTIFACT_ZIP_FILE="${WORK_DIR}/artifacts/artifacts.zip"
mkdir -p "${ARTIFACT_DIR}" ARTIFACT_META="${WORK_DIR}/build.meta.json"
JELLYFIN_REPO_URL="https://github.com/cxfksword/jellyfin-plugin-metashark/releases/download" JELLYFIN_REPO_URL="https://github.com/cxfksword/jellyfin-plugin-metashark/releases/download"
JELLYFIN_MANIFEST="${WORK_DIR}/manifest.json" JELLYFIN_MANIFEST="${WORK_DIR}/manifest.json"
JELLYFIN_MANIFEST_CN="${WORK_DIR}/manifest_cn.json" JELLYFIN_MANIFEST_CN="${WORK_DIR}/manifest_cn.json"
JELLYFIN_MANIFEST_OLD="https://github.com/cxfksword/jellyfin-plugin-metashark/releases/download/manifest/manifest.json" JELLYFIN_MANIFEST_OLD="https://github.com/cxfksword/jellyfin-plugin-metashark/releases/download/manifest/manifest.json"
BUILD_YAML_FILE="${WORK_DIR}/build.yaml"
VERSION=$(echo "$TAG" | sed s/^v//) # remove v prefix
VERSION="$VERSION.0" # .NET dll need major.minor[.build[.revision]] version format
# download old manifest # download old manifest
wget -q -O "$JELLYFIN_MANIFEST" "$JELLYFIN_MANIFEST_OLD" wget -q -O "$JELLYFIN_MANIFEST" "$JELLYFIN_MANIFEST_OLD"
@ -25,14 +22,16 @@ if [ $? -ne 0 ]; then
jprm repo init $WORK_DIR jprm repo init $WORK_DIR
fi fi
# update change log from tag message # update meta json message
cp -f "${ARTIFACT_META}" "${ARTIFACT_ZIP_FILE}.meta.json"
CHANGELOG=$(git tag -l --format='%(contents)' ${TAG}) CHANGELOG=$(git tag -l --format='%(contents)' ${TAG})
sed -i "s@NA@$CHANGELOG@" $BUILD_YAML_FILE # mac build need change to: -i '' sed -i "s@NA@$CHANGELOG@" "${ARTIFACT_ZIP_FILE}.meta.json"
sed -i "s@1.0.0.0@$VERSION@" "${ARTIFACT_ZIP_FILE}.meta.json"
sed -i "s@1970-01-01T00:00:00Z@$CURRENT_DATE@" "${ARTIFACT_ZIP_FILE}.meta.json"
# build and generate new manifest
zipfile=$(jprm --verbosity=debug plugin build "." --output="${ARTIFACT_DIR}" --version="${VERSION}" --dotnet-framework="net6.0") && { # generate new manifest
jprm --verbosity=debug repo add --url=${JELLYFIN_REPO_URL} "${JELLYFIN_MANIFEST}" "${zipfile}" jprm --verbosity=debug repo add --url=${JELLYFIN_REPO_URL} "${JELLYFIN_MANIFEST}" "${ARTIFACT_ZIP_FILE}"
}
# fix menifest download url # fix menifest download url
sed -i "s@/${ARTIFACT}@/$TAG@" "$JELLYFIN_MANIFEST" sed -i "s@/${ARTIFACT}@/$TAG@" "$JELLYFIN_MANIFEST"