-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathfunction
More file actions
113 lines (102 loc) · 4.01 KB
/
function
File metadata and controls
113 lines (102 loc) · 4.01 KB
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
105
106
107
108
109
110
111
112
113
# Lets store all our function at one place
# set your gmail and email
git config --global user.email "$gmail"
git config --global user.name "$CIRRUS_REPO_OWNER"
# lets store some variables
github_repo="https://$CIRRUS_REPO_OWNER:$github_token@github.com/$CIRRUS_REPO_FULL_NAME"
progress=https://cirrus-ci.com/build/$CIRRUS_BUILD_ID
device_codename=$(grep unch /tmp/ci/build.sh -m 1 | cut -d ' ' -f 2 | cut -d _ -f 2 | cut -d - -f 1)
rom_name=$(grep init /tmp/ci/sync -m 1 | cut -d / -f 4)
upload_link=https://github.com/$CIRRUS_REPO_FULL_NAME
lunch_device=$(grep lunch /tmp/ci/build.sh -m 1 | cut -d ' ' -f 2)
branch_name=$(grep init /tmp/ci/sync | awk -F "-b " '{print $2}' | awk '{print $1}')
upload_type=3
# Compress function with pigz for faster compression
com () {
tar --use-compress-program="pigz -k -$2 " -cf $1.tar.gz $1
}
# install apt
install_apt () {
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
apt update && apt install -y wget pigz gh jq aria2
down https://emy.ehteshammalik4.workers.dev/gclone_setup || down https://emy.ehteshammalik4.workers.dev/gclone_setup
chmod 0775 gclone_setup && ./gclone_setup
}
# login in github before uploading
echo $github_token > mytoken.txt # login in github
gh auth login --with-token < mytoken.txt
# download ccache
down () {
SECONDS=0
time aria2c $1 -x16 -s50
}
# upload our rom zip
upload () {
case "$upload_type" in
1) # github
gh release create $rom_name --generate-notes --repo $upload_link
gh release upload --clobber $rom_name $1 --repo $upload_link
github_url=$upload_link/releases/download/$rom_name/$1
tg "Build Succeed!
Time Took: $(($SECONDS / 60))min and $(($SECONDS % 60))sec.
github link: $github_url"
;;
2) # gdrive
gclone copy $1 whoemi:$CIRRUS_REPO_OWNER/$device_codename/$rom_name/$branch_name -P
gdrive_url=https://emy.ehteshammalik4.workers.dev/$CIRRUS_REPO_OWNER/$device_codename/$rom_name/$branch_name/$1
tg "Build Succeed!
Time Took: $(($SECONDS / 60))min and $(($SECONDS % 60))sec.
gdrive link: $gdrive_url"
;;
3) # both
gclone copy $1 whoemi:$CIRRUS_REPO_OWNER/$device_codename/$rom_name -P
gh release create $rom_name --generate-notes --repo $upload_link
gh release upload --clobber $rom_name $1 --repo $upload_link
github_url=$upload_link/releases/download/$rom_name/$1
gdrive_url=https://emy.ehteshammalik4.workers.dev/$CIRRUS_REPO_OWNER/$device_codename/$rom_name/$branch_name/$1
tg "Build Succeed!
Time Took: $(($SECONDS / 60))min and $(($SECONDS % 60))sec.
gdrive link: $gdrive_url
github link: $github_url"
;;
*) # default is gdrive
gclone copy $1 whoemi:$CIRRUS_REPO_OWNER/$device_codename/$rom_name/$branch_name -P
gdrive_url=https://emy.ehteshammalik4.workers.dev/$CIRRUS_REPO_OWNER/$device_codename/$rom_name/$branch_name/$1
tg "Build Succeed!
Time Took: $(($SECONDS / 60))min and $(($SECONDS % 60))sec.
gdrive link: $gdrive_url"
esac
}
# upload our ccache
upload_ccache () {
SECONDS=0
gclone copy $1 whoemi:$device_codename/$rom_name/$branch_name -P
url=https://emy.ehteshammalik4.workers.dev/$device_codename/$rom_name/$branch_name/$1
}
# push to telegram
tg () {
curl -s "https://api.telegram.org/bot${bot_api}/sendmessage" --data "text=$1&chat_id=${chat_id}"
}
# sync time
sync_time () {
sync_time="`cat /tmp/sync_time.txt`"
rm -rf sync_time.txt
}
# check Build Number
check_build_type () {
last_dir=${PWD}
cd /tmp/ci
git show -s --format=%s | awk 'NF>1{print $NF}' > /tmp/last_value.txt # store last value from commit name
last_value="`cat /tmp/last_value.txt`" # store last value
case "$last_value" in
S|s|R|r)
build_type=$last_value
;;
*) # Lets make vendor as haven't stored any value in commit name
build_type=V
esac
cd $last_dir
rm -rf /tmp/last_* # clean up xD
}