This repository has been archived by the owner on Apr 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrdm
executable file
·115 lines (98 loc) · 3.08 KB
/
rdm
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
114
115
#!/usr/bin/env bash
## Environment Variables
REPO="Descendant/InOps"
ENVPATH="/var/virtualenv"
VERSION="0.2"
if [ ! -z "$1" ]
then
GITHUB_TOKEN="$1"
fi
if [ ! -z "$2" ]
then
REPO="$2"
fi
if [ ! -z "$3" ]
then
ENVPATH="$3"
fi
## End Environment Variables
function banner()
{
printf "\n"
printf "###################################\n"
printf "### ###\n"
printf "### Release Deploy Manager ###\n"
printf "### ###\n"
printf "### version ${VERSION} ###\n"
printf "### ###\n"
printf "###################################\n"
printf "\n"
}
function getReleaseCodename()
{
echo "Version (name)?"
read releaseCodename
}
function loadEnvironmentConfig()
{
if [[ ! -d $ENVPATH/bin ]]
then
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root to create the initial setup!"
exit 1
fi
mkdir -p /var/virtualenv
nix-env -iA nixos.python37
nix-env -iA nixos.python37Packages.pip
nix-env -iA nixos.python37Packages.virtualenv
nix-env -iA nixos.pipenv
virtualenv $ENVPATH
fi
source $ENVPATH/bin/activate
command -v githubrelease >/dev/null 2>&1 || pip install githubrelease
}
function getReleaseInfo()
{
echo "GitHub release name you desire?"
read releaseName
}
function verificationChecks()
{
printf "\n\n"
printf "Please ensure the following info is correct.\nDeploy will begin after you agree the info is correct.\n"
printf "Version name and tag will be set as $releaseCodename \n"
printf "GitHub release name will be $releaseName \n"
printf "All the assets you are willing to deploy are located in $PWD.\nYou also agree there is nothing else here but just the files you are willing to deploy.\n"
read -p "Are you sure? " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
}
function deployKeyCheck()
{
if [[ -z "${GITHUB_TOKEN}" ]]
then
echo ""
echo "Environment variable GITHUB_TOKEN has not been set or has not been passed as the first argument. The program cannot run without it."
echo "You can get your Token at GitHub Settings > Developer settings > Personal access tokens"
echo "Remember the token must at least have the following permissions in order to make the release:"
echo " admin:org, admin:org_hook, admin:public_key, admin:repo_hook, public_repo, repo_deployment "
echo "Program will now exit."
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
}
banner
getReleaseCodename
loadEnvironmentConfig
getReleaseInfo
verificationChecks
deployKeyCheck
printf "\n## RDM PRO Deploy Stage 1 begins at $(date) ##\n"
githubrelease --github-token "${GITHUB_TOKEN}" release $REPO create "${releaseCodename}"
githubrelease --github-token "${GITHUB_TOKEN}" release $REPO edit --tag-name "${releaseCodename}" --name "${releaseName}" "${releaseCodename}"
printf "\n## RDM PRO Deploy Stage 2 begins ##\n"
githubrelease --github-token "${GITHUB_TOKEN}" asset $REPO upload "${releaseCodename}" $PWD/*
printf "\n## RDM PRO Deploy finished at $(date) ##\n"
printf "\nHave a nice night!"