-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate_client_repo.sh
executable file
·91 lines (69 loc) · 2.43 KB
/
update_client_repo.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
83
84
85
86
87
88
89
90
91
#!/usr/bin/env bash
set -e
SERVICE=onepanel
#
# Language of the client repo (e.g. js, python, ...)
#
LANGUAGE=$1
#
# Temporary directory where the client will be built
#
TARGET_DIRECTORY=$2
#
# Branch which will be updated in the client repo
#
TARGET_BRANCH=$3
if [ x$TARGET_BRANCH == "x" ]; then
echo "Missing target branch!!!"
exit 1
fi
WORK_DIRECTORY=$PWD
declare -A releases
if [ $TARGET_BRANCH == "develop" ]; then
releases[$TARGET_BRANCH]="18.02.0-dev"
elif [ $TARGET_BRANCH == "release/*" ]; then
releases[$TARGET_BRANCH]=$( echo $TARGET_BRANCH | sed "s/release\/\(.*\)/\1/p" -n )
elif [ $TARGET_BRANCH == "master" ]; then
exit 0
else
releases[$TARGET_BRANCH]=$TARGET_BRANCH
fi
# Checkout the client repository which should be updated
git clone \
ssh://[email protected]:7999/vfs/${SERVICE}-${LANGUAGE}-client.git \
${TARGET_DIRECTORY}
rm -rf packages
for release_branch in "${!releases[@]}"; do
# Checkout the specific API version as worktree subdirectory
git worktree add build-"${releases[$release_branch]}" $release_branch
# Copy the codegen config file to workdir and set version
cp ${LANGUAGE}-config.json build-"${releases[$release_branch]}"/
sed -i "s/__PACKAGE_VERSION__/${releases[$release_branch]}/g" \
build-"${releases[$release_branch]}"/${LANGUAGE}-config.json
cd build-"${releases[$release_branch]}"
# Generate a combined swagger.json from yaml files
docker run --rm -e "CHOWNUID=${UID}" \
-v `pwd`:/swagger docker.onedata.org/swagger-aggregator:1.5.0
# Enter the generated client directory
cd $TARGET_DIRECTORY && \
git checkout $release_branch || git checkout -b $release_branch && \
cd -
# Build the javascript client from the current API version in the worktree
docker run --rm -e "CHOWNUID=${UID}" \
-v `pwd`:/swagger -t docker.onedata.org/swagger-codegen:VFS-3144 \
generate -i ./swagger.json -l ${LANGUAGE} -o ./generated-${LANGUAGE}/ \
-c ./${LANGUAGE}-config.json
# Copy the generated javascript code to the client repository working dir
cp -R generated-${LANGUAGE}/* $TARGET_DIRECTORY
# Commit&push the changes to the client repository
cd $TARGET_DIRECTORY
git add -A . && \
git commit -a -m "Auto update" \
&& git push origin $release_branch
cd -
cd ..
# Cleanup
rm -rf build-"${releases[$release_branch]}"
git worktree prune
done
rm -rf ${TARGET_DIRECTORY}