forked from lcompilers/lpython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload_tarball.sh
executable file
·82 lines (61 loc) · 1.94 KB
/
upload_tarball.sh
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
#!/bin/bash
set -e
set -x
deploy_repo_pull="https://github.com/lfortran/tarballs"
deploy_repo_push="git@github.com:lfortran/tarballs.git"
if [[ $CI_COMMIT_TAG == "" ]]; then
# Development version
dest_dir="dev"
else
# Release version
dest_dir="release"
fi
lfortran_version=$(<version)
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
ssh-keyscan github.com >> ~/.ssh/known_hosts
eval "$(ssh-agent -s)"
D=`pwd`
mkdir $HOME/repos
cd $HOME/repos
git clone ${deploy_repo_pull} tarballs
cd tarballs/docs
mkdir -p ${dest_dir}
cp $D/dist/lfortran-${lfortran_version}.tar.gz ${dest_dir}/
python $D/ci/tarball_update_json.py ${dest_dir} ${lfortran_version} ${CI_COMMIT_SHA}
git config user.name "Deploy"
git config user.email "noreply@deploy"
COMMIT_MESSAGE="Deploying on $(date "+%Y-%m-%d %H:%M:%S")"
git add .
git commit -m "${COMMIT_MESSAGE}"
git show HEAD -p --stat
dest_commit=$(git show HEAD -s --format=%H)
if [[ ${CI_COMMIT_REF_NAME} != "master" && $CI_COMMIT_TAG == "" ]]; then
# We only execute the rest of master
echo "Not a master branch, not tagged, skipping..."
exit 0
fi
set +x
if [[ "${SSH_PRIVATE_KEY_TARBALL}" == "" ]]; then
echo "Note: SSH_PRIVATE_KEY_TARBALL is empty, skipping..."
exit 0
fi
# Generate the private/public key pair using:
#
# ssh-keygen -f deploy_key -N ""
#
# then set the $SSH_PRIVATE_KEY_TARBALL environment variable in the GitLab-CI
# to the base64 encoded private key (uncheck the "Masked" check box):
#
# cat deploy_key | base64 -w0
#
# and add the public key `deploy_key.pub` into the target git repository (with
# write permissions).
ssh-add <(echo "$SSH_PRIVATE_KEY_TARBALL" | base64 -d)
set -x
git push ${deploy_repo_push} master:master
echo "New commit pushed at:"
echo "https://github.com/lfortran/tarballs/commit/${dest_commit}"
echo "The tarball is available from:"
echo "https://lfortran.github.io/tarballs/${dest_dir}/lfortran-${lfortran_version}.tar.gz"