Fix build

This commit is contained in:
cxfksword
2022-10-14 12:49:52 +08:00
parent cf8e8c94d7
commit e4b2edac4e
3 changed files with 36 additions and 71 deletions

View File

@@ -32,7 +32,7 @@ jobs:
- name: Install JPRM
run: python -m pip install jprm
- name: Run JPRM
run: python build_plugin.py --version=${GITHUB_REF#refs/*/}
run: chmod +x build_plugin.sh && build_plugin.sh ${GITHUB_REF#refs/*/}
- name: Update release
uses: svenstaro/upload-release-action@v2
with:

View File

@@ -1,70 +0,0 @@
import os
import sys
import argparse
import os.path
parser = argparse.ArgumentParser()
parser.add_argument('--version', required=True)
parser.add_argument('--prerelease')
opts = parser.parse_args()
version = opts.version
prerelease = bool(opts.prerelease)
tag = os.popen('git describe --abbrev=0').read().strip()
changelog = os.popen("git tag -l --format='%(contents)' " + tag).read().strip()
artifact_dir = os.path.join(os.getcwd(), 'artifacts')
os.mkdir(artifact_dir)
git_version = version
# .NET dll need major.minor[.build[.revision]] version format
if version.startswith('v'):
version = version.lstrip("v")
version_list = version.split('.')
if len(version_list) == 3:
version_list.append('0')
version = '.'.join(version_list)
if prerelease:
jellyfin_repo_file = "./manifest-unstable.json"
jellyfin_old_manifest = "https://github.com/cxfksword/jellyfin-plugin-danmu/releases/download/manifest/manifest-unstable.json"
else:
jellyfin_repo_file = "./manifest.json"
jellyfin_old_manifest = "https://github.com/cxfksword/jellyfin-plugin-danmu/releases/download/manifest/manifest.json"
# download old manifest
jellyfin_manifest_template = "./doc/manifest-template.json"
os.system('wget -q -O "%s" "%s" ' % (jellyfin_repo_file, jellyfin_old_manifest))
if not os.path.isfile(jellyfin_repo_file):
os.system('cp -f %s %s' % (jellyfin_manifest_template, jellyfin_repo_file))
# update change log
build_yaml_file = "./build.yaml"
with open(build_yaml_file, 'r') as file:
data = file.read()
data = data.replace("NA", changelog)
with open(build_yaml_file, 'w') as file:
file.write(data)
# build and generate new manifest
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' % (git_version, jellyfin_repo_file))
# 国内加速
jellyfin_repo_file_cn = jellyfin_repo_file.replace(".json", "_cn.json")
os.system('cp -f %s %s' % (jellyfin_repo_file, jellyfin_repo_file_cn))
os.system('sed -i "s/github.com/ghproxy.com\/https:\/\/github.com/g" "%s"' % (jellyfin_repo_file_cn))
print(version)

35
build_plugin.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
TAG=$1
WORK_DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
ARTIFACT_DIR=${ARTIFACT_DIR:-"${WORK_DIR}/artifacts"}
mkdir -p "${ARTIFACT_DIR}"
JELLYFIN_REPO_URL="https://github.com/cxfksword/jellyfin-plugin-danmu/releases/download"
JELLYFIN_MANIFEST="${WORK_DIR}/manifest.json"
JELLYFIN_MANIFEST_OLD="https://github.com/cxfksword/jellyfin-plugin-danmu/releases/download/manifest/manifest.json"
JELLYFIN_MANIFEST_TEMPLATE="${WORK_DIR}/doc/manifest-template.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
wget -q -O "$JELLYFIN_MANIFEST" "$JELLYFIN_MANIFEST_OLD"
if [ $? -ne 0 ]; then
cp -f "$JELLYFIN_MANIFEST_TEMPLATE" "$JELLYFIN_MANIFEST"
fi
# update change log from tag message
CHANGELOG=$(git tag -l --format='%(contents)' ${TAG})
sed -i '' "s#NA#$CHANGELOG#" $BUILD_YAML_FILE # -i '' for fix mac execute error
# build and generate new manifest
zipfile=$(jprm --verbosity=debug plugin build "." --output="${ARTIFACT_DIR}" --version="${VERSION}" --dotnet-framework="net6.0") && {
jprm --verbosity=debug repo add --url=${JELLYFIN_REPO_URL} "${JELLYFIN_MANIFEST}" "${zipfile}"
}
exit $?