-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdeploy-exec
104 lines (90 loc) · 2.97 KB
/
deploy-exec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
set -o errexit
WORKDIR=$(pwd)
cd $WORKDIR
REPODIR="/tmp/jellyfin-plugin-repo"
version=$(echo -n $TAG | sed "s/v//g")
changetime=$(date +%Y-%m-%dT%H:%M:%SZ)
changelog=$(git show -s --format=%s)
targetAbi="10.8.0.0"
mirror_us="https://github.com/caryyu/jellyfin-plugin-repo/raw/master/Jellyfin.Plugin.OpenDouban.$version.zip"
DLL_PATH="$WORKDIR/Jellyfin.Plugin.OpenDouban/bin/Debug/net6.0/Jellyfin.Plugin.OpenDouban.dll"
PKG_NAME="$REPODIR/Jellyfin.Plugin.OpenDouban.$version.zip"
setup() {
echo -n ${SSH_PRIVKEY_GITHUB} | base64 -d > /tmp/github-privkey
chmod 400 /tmp/github-privkey
eval $(ssh-agent)
mkdir -p ~/.ssh
ssh-add -k /tmp/github-privkey
ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts
git clone [email protected]:caryyu/jellyfin-plugin-repo.git $REPODIR
cd $REPODIR
git remote -v
ls -la
zip -j ${PKG_NAME} ${DLL_PATH}
ls -la
cd $WORKDIR
}
change_manifest_file() {
local jsonfile=$1
local mirror=$2
echo "Update $jsonfile: version: $version"
cd $REPODIR
local isUpdate="false"
local versions=()
for row in $(cat $jsonfile | jq -r '.[0].versions[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
if [ "$version" == "$(_jq '.version')" ]; then
isUpdate="true"
versions+=("{
\"checksum\": \"$checksum\",
\"changelog\": \"$changelog\",
\"targetAbi\": \"$targetAbi\",
\"sourceUrl\": \"$mirror\",
\"timestamp\": \"$changetime\",
\"version\": \"$version\"
}")
else
versions+=("{
\"checksum\": \"$(_jq '.checksum')\",
\"changelog\": \"$(_jq '.changelog')\",
\"targetAbi\": \"$(_jq '.targetAbi')\",
\"sourceUrl\": \"$(_jq '.sourceUrl')\",
\"timestamp\": \"$(_jq '.timestamp')\",
\"version\": \"$(_jq '.version')\"
}")
fi
done
if [ "$isUpdate" == "false" ]; then
versions+=("{
\"checksum\": \"$checksum\",
\"changelog\": \"$changelog\",
\"targetAbi\": \"$targetAbi\",
\"sourceUrl\": \"$mirror\",
\"timestamp\": \"$changetime\",
\"version\": \"$version\"
}")
fi
JSON=[$(IFS=,; printf '%s' "${versions[*]}")]
cat $jsonfile | jq --argjson versions "$JSON" '.[0].versions = $versions' > /tmp/txt
mv /tmp/txt $jsonfile
cat $jsonfile
cd $WORKDIR
}
trigger_git_push() {
cd $REPODIR
git config --global push.default matching
git config --global user.email "[email protected]"
git config --global user.name "caryyu"
git stage .
git status
git commit -m "release jellyfin-plugin-douban $version"
git push origin
cd $WORKDIR
}
setup
checksum=$(cat $PKG_NAME | md5sum | cut -d' ' -f1)
change_manifest_file "manifest-us.json" $mirror_us
trigger_git_push