-
Notifications
You must be signed in to change notification settings - Fork 3
97 lines (87 loc) · 3.45 KB
/
release.yml
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
name: 3.Release New Version
on:
release:
types: [released]
permissions:
contents: read
packages: write
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Install deploy key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.DOCS_SSH_KEY }}
known_hosts: ${{ secrets.DOCS_KNOWN_HOST }}
- name: Deploy
if: github.repository == 'liplum-dev/mimir'
shell: bash
run: |
git clone --single-branch --branch main "https://github.com/Amazefcc233/mimir-docs" ~/deploy
cd ~/deploy
version=$(echo "${{ github.event.release.tag_name }}" | sed 's/v//g')
release_time=$(echo "${{ github.event.release.published_at }}" | sed 's/T/ /g' | sed 's/Z//g')
release_time=$(date -d "$release_time 8 hours" "+%Y-%m-%d %H:%M:%S")
release_note=$(echo "${{ github.event.release.body }}" | sed -n '/## 更改/,/## How to download/p' | sed '1d;$d')
apk_name=$(echo "${{ github.event.release.assets[0].name }}")
apk_url=$(echo "${{ github.event.release.assets[0].browser_download_url }}")
if [ -z "$apk_url" ]; then
apk_sha256=""
else
apk_sha256=$(curl -sL "$apk_url" | sha256sum | cut -d ' ' -f 1)
fi
ipa_name=$(echo "${{ github.event.release.assets[1].name }}")
ipa_url=$(echo "${{ github.event.release.assets[1].browser_download_url }}")
if [ -z "$ipa_url" ]; then
ipa_sha256=""
else
ipa_sha256=$(curl -sL "$ipa_url" | sha256sum | cut -d ' ' -f 1)
fi
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
mkdir -p "artifact/"
jq -n \
--arg version "$version" \
--arg release_time "$release_time" \
--arg release_note "$release_note" \
--arg apk_name "$apk_name" \
--arg apk_sha256 "$apk_sha256" \
--arg apk_url1 "$apk_url" \
--arg apk_url2 "https://mirror.ghproxy.com/$apk_url" \
--arg ipa_name "$ipa_name" \
--arg ipa_sha256 "$ipa_sha256" \
--arg ipa_url1 "$ipa_url" \
--arg ipa_url2 "https://mirror.ghproxy.com/$ipa_url" \
'
{
"version": $version,
"release_time": $release_time,
"release_note": $release_note,
"downloads": {
"Android": {
"name": $apk_name,
"default": "mirror",
"sha256": $apk_sha256,
"url": {
"official": $apk_url1,
"mirror": $apk_url2,
},
},
"iOS": {
"name": $ipa_name,
"default": "mirror",
"sha256": $ipa_sha256,
"url": {
"official": $ipa_url1,
"mirror": $ipa_url2,
}
}
}
}
' > "artifact/$version.json"
rm -f artifact/latest.json
ln -s "$version.json" "artifact/latest.json"
git add --all
git commit -m "Release New Version: $version"
git push "[email protected]:Amazefcc233/mimir-docs" main:main