build: update build script
This commit is contained in:
parent
3513da7f12
commit
7b92a811b2
|
@ -6,7 +6,7 @@ on:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
dotnet-version: 6.0.x
|
dotnet-version: 6.0.x
|
||||||
python-version: 3.8
|
python-version: 3.10
|
||||||
project: Jellyfin.Plugin.MetaShark/Jellyfin.Plugin.MetaShark.csproj
|
project: Jellyfin.Plugin.MetaShark/Jellyfin.Plugin.MetaShark.csproj
|
||||||
artifact: metashark
|
artifact: metashark
|
||||||
|
|
||||||
|
@ -23,6 +23,10 @@ jobs:
|
||||||
uses: actions/setup-dotnet@v3
|
uses: actions/setup-dotnet@v3
|
||||||
with:
|
with:
|
||||||
dotnet-version: ${{ env.dotnet-version }}
|
dotnet-version: ${{ env.dotnet-version }}
|
||||||
|
- name: Setup python
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.python-version }}
|
||||||
- name: Initialize workflow variables
|
- name: Initialize workflow variables
|
||||||
id: vars
|
id: vars
|
||||||
run: |
|
run: |
|
||||||
|
@ -41,28 +45,30 @@ jobs:
|
||||||
with:
|
with:
|
||||||
type: "zip"
|
type: "zip"
|
||||||
directory: "artifacts"
|
directory: "artifacts"
|
||||||
filename: "artifacts.zip"
|
filename: "${{ env.artifact }}_${{steps.vars.outputs.VERSION}}.zip"
|
||||||
exclusions: "*.json *.pdb"
|
exclusions: "*.json *.pdb"
|
||||||
- name: Setup python
|
- name: Generate manifest
|
||||||
uses: actions/setup-python@v2
|
run: cd artifacts && python3 ../generate_manifest.py ${{ env.artifact }}_${{steps.vars.outputs.VERSION}}.zip ${GITHUB_REF#refs/*/}
|
||||||
|
- name: Deploy to jellyfin release repo
|
||||||
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
python-version: ${{ env.python-version }}
|
deploy_key: ${{ secrets.PAT }}
|
||||||
- name: Install JPRM
|
external_repository: cxfksword/jellyfin-release
|
||||||
run: python -m pip install jprm
|
destination_dir: ${{ env.artifact }}
|
||||||
- name: Run JPRM
|
publish_branch: master
|
||||||
run: chmod +x ./build.sh && ./build.sh ${{ env.artifact }} ${{steps.vars.outputs.VERSION}} ${GITHUB_REF#refs/*/}
|
publish_dir: ./artifacts
|
||||||
- name: Publish 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: ./${{ env.artifact }}/${{ env.artifact }}_*.zip
|
file: ./artifacts/${{ env.artifact }}_*.zip
|
||||||
tag: ${{ github.ref }}
|
tag: ${{ github.ref }}
|
||||||
file_glob: true
|
file_glob: true
|
||||||
- name: Publish 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: ./manifest*.json
|
# file: ./artifacts/manifest*.json
|
||||||
tag: "manifest"
|
# tag: "manifest"
|
||||||
overwrite: true
|
# overwrite: true
|
||||||
file_glob: true
|
# file_glob: true
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
43
build.sh
43
build.sh
|
@ -1,43 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# $1 from github action
|
|
||||||
ARTIFACT=$1
|
|
||||||
VERSION=$2
|
|
||||||
TAG=$3
|
|
||||||
|
|
||||||
CURRENT_DATE=$(date +'%Y-%m-%dT%H:%M:%S')
|
|
||||||
WORK_DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
|
||||||
ARTIFACT_ZIP_FILE="${WORK_DIR}/artifacts/artifacts.zip"
|
|
||||||
ARTIFACT_META="${WORK_DIR}/build.meta.json"
|
|
||||||
|
|
||||||
JELLYFIN_REPO_URL="https://github.com/cxfksword/jellyfin-plugin-metashark/releases/download"
|
|
||||||
JELLYFIN_MANIFEST="${WORK_DIR}/manifest.json"
|
|
||||||
JELLYFIN_MANIFEST_CN="${WORK_DIR}/manifest_cn.json"
|
|
||||||
JELLYFIN_MANIFEST_OLD="https://github.com/cxfksword/jellyfin-plugin-metashark/releases/download/manifest/manifest.json"
|
|
||||||
|
|
||||||
# download old manifest
|
|
||||||
wget -q -O "$JELLYFIN_MANIFEST" "$JELLYFIN_MANIFEST_OLD"
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
rm -rf $JELLYFIN_MANIFEST
|
|
||||||
jprm repo init $WORK_DIR
|
|
||||||
fi
|
|
||||||
|
|
||||||
# update meta json message
|
|
||||||
cp -f "${ARTIFACT_META}" "${ARTIFACT_ZIP_FILE}.meta.json"
|
|
||||||
CHANGELOG=$(git tag -l --format='%(contents)' ${TAG})
|
|
||||||
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"
|
|
||||||
|
|
||||||
|
|
||||||
# generate new manifest
|
|
||||||
jprm --verbosity=debug repo add --url=${JELLYFIN_REPO_URL} "${JELLYFIN_MANIFEST}" "${ARTIFACT_ZIP_FILE}"
|
|
||||||
|
|
||||||
# fix menifest download url
|
|
||||||
sed -i "s@/${ARTIFACT}/@/$TAG/@" "$JELLYFIN_MANIFEST"
|
|
||||||
|
|
||||||
# 国内加速
|
|
||||||
cp -f "$JELLYFIN_MANIFEST" "$JELLYFIN_MANIFEST_CN"
|
|
||||||
sed -i "s@github.com@gh-proxy.com/https://github.com@g" "$JELLYFIN_MANIFEST_CN"
|
|
||||||
|
|
||||||
exit $?
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
from datetime import datetime
|
||||||
|
from urllib.request import urlopen
|
||||||
|
from urllib.error import HTTPError
|
||||||
|
|
||||||
|
def generate_manifest():
|
||||||
|
return [{
|
||||||
|
"guid": "9a19103f-16f7-4668-be54-9a1e7a4f7556",
|
||||||
|
"name": "MetaShark",
|
||||||
|
"description": "jellyfin电影元数据插件,影片信息只要从豆瓣获取,并由TMDB补充缺失的剧集数据。",
|
||||||
|
"overview": "jellyfin电影元数据插件",
|
||||||
|
"owner": "cxfksword",
|
||||||
|
"category": "Metadata",
|
||||||
|
"imageUrl": "https://github.com/cxfksword/jellyfin-plugin-metashark/raw/main/doc/logo.png",
|
||||||
|
"versions": []
|
||||||
|
}]
|
||||||
|
|
||||||
|
def generate_version(filepath, version, changelog):
|
||||||
|
return {
|
||||||
|
'version': f"{version}.0",
|
||||||
|
'changelog': changelog,
|
||||||
|
'targetAbi': '10.8.0.0',
|
||||||
|
'sourceUrl': f'https://github.com/cxfksword/jellyfin-plugin-metashark/releases/download/v{version}/metashark_{version}.0.zip',
|
||||||
|
'checksum': md5sum(filepath),
|
||||||
|
'timestamp': datetime.now().strftime('%Y-%m-%dT%H:%M:%S')
|
||||||
|
}
|
||||||
|
|
||||||
|
def md5sum(filename):
|
||||||
|
with open(filename, 'rb') as f:
|
||||||
|
return hashlib.md5(f.read()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
filename = sys.argv[1]
|
||||||
|
tag = sys.argv[2]
|
||||||
|
version = tag.removeprefix('v')
|
||||||
|
filepath = os.path.join(os.getcwd(), filename)
|
||||||
|
result = subprocess.run(['git', 'tag','-l','--format=%(contents)', tag, '-l'], stdout=subprocess.PIPE)
|
||||||
|
changelog = result.stdout.decode('utf-8').strip()
|
||||||
|
|
||||||
|
# 解析旧 manifest
|
||||||
|
try:
|
||||||
|
with urlopen('https://github.com/cxfksword/jellyfin-plugin-metashark/releases/download/manifest/maniest.json') as f:
|
||||||
|
manifest = json.load(f)
|
||||||
|
except HTTPError as err:
|
||||||
|
if err.code == 404:
|
||||||
|
manifest = generate_manifest()
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
|
# 追加新版本
|
||||||
|
manifest[0]['versions'].insert(0, generate_version(filepath, version, changelog))
|
||||||
|
|
||||||
|
with open('manifest.json', 'w') as f:
|
||||||
|
json.dump(manifest, f, indent=2)
|
||||||
|
|
||||||
|
# 国内加速
|
||||||
|
with open('manifest_cn.json', 'w') as f:
|
||||||
|
manifest_cn = json.dumps(manifest, indent=2)
|
||||||
|
manifest_cn = re.sub("github.com", "gh-proxy.com/https://github.com", manifest_cn)
|
||||||
|
f.write(manifest_cn)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in New Issue