-
Notifications
You must be signed in to change notification settings - Fork 3
/
upgradeeformnugets.sh
executable file
·128 lines (112 loc) · 4.92 KB
/
upgradeeformnugets.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
GIT_STATUS=`git status | grep "nothing to commit, working tree clean" | wc -l`
if (( "$GIT_STATUS" > 0 )); then
git checkout master
git pull
cd ServiceBackendConfigurationPlugin
CURRENT_NUMBER_OF_COMMITS=`git log --oneline | wc -l`
PACKAGES=('Microting.eForm' 'Microting.eFormApi.BasePn' 'Microting.EformBackendConfigurationBase' 'Microting.ItemsPlanningBase' 'SendGrid' 'ChemicalsBase' 'Microting.EformAngularFrontendBase' 'Microting.eFormCaseTemplateBase')
PROJECT_NAME='ServiceBackendConfigurationPlugin.csproj'
REPOSITORY='eform-service-backend-configuration-plugin'
for PACKAGE_NAME in ${PACKAGES[@]}; do
OLD_VERSION=`dotnet list package | grep "$PACKAGE_NAME " | grep -oP ' \d\.\d+\.\d.*' | grep -oP ' \d.* \b' | xargs`
dotnet add $PROJECT_NAME package $PACKAGE_NAME
NEW_VERSION=`dotnet list package | grep "$PACKAGE_NAME " | grep -oP ' \d\.\d+\.\d.*$' | grep -oP '\d\.\d+\.\d.*$' | grep -oP ' \d\.\d+\.\d.*$' | xargs`
if [ $NEW_VERSION != $OLD_VERSION ]; then
echo "We have a new version of $PACKAGE_NAME, so creating github issue and do a commit message to close that said issue"
RESULT=`curl -X "POST" "https://api.github.com/repos/microting/$REPOSITORY/issues?state=all" \
-H "Cookie: logged_in=no" \
-H "Authorization: token $CHANGELOG_GITHUB_TOKEN" \
-H "Content-Type: text/plain; charset=utf-8" \
-d $'{
"title": "Bump '$PACKAGE_NAME' from '$OLD_VERSION' to '$NEW_VERSION'",
"body": "TBD",
"assignees": [
"renemadsen"
],
"labels": [
".NET",
"backend",
"enhancement"
]
}'`
ISSUE_NUMBER=`echo $RESULT | grep -oP 'number": \d+,' | grep -oP '\d+'`
git add .
git commit -a -m "closes #$ISSUE_NUMBER"
fi
done
NEW_NUMBER_OF_COMMITS=`git log --oneline | wc -l`
if (( $NEW_NUMBER_OF_COMMITS > $CURRENT_NUMBER_OF_COMMITS )); then
CURRENT_GITVERSION=`git tag --sort=-creatordate | cut -d "v" -f 2 | sed -n 1p`
MAJOR_VERSION=`echo $CURRENT_GITVERSION | cut -d "." -f 1`
MINOR_VERSION=`echo $CURRENT_GITVERSION | cut -d "." -f 2`
BUILD_VERSION=`echo $CURRENT_GITVERSION | cut -d "." -f 3`
BUILD_VERSION=$(($BUILD_VERSION + 1))
NEW_GIT_VERSION="v$MAJOR_VERSION.$MINOR_VERSION.$BUILD_VERSION"
git tag "$NEW_GIT_VERSION"
git push --tags
git push
echo "Updated Microting eForm to ${EFORM_VERSION} and pushed new version ${NEW_GIT_VERSION}"
else
echo "nothing to do, everything is up to date."
fi
cd ..
else
echo "Working tree is not clean, so we are not going to upgrade. Clean, before doing upgrade!"
fi
GIT_STATUS=`git status | grep "nothing to commit, working tree clean" | wc -l`
if (( "$GIT_STATUS" > 0 )); then
git checkout master
git pull
cd ci
cd eformparsed
CURRENT_NUMBER_OF_COMMITS=`git log --oneline | wc -l`
PACKAGES=('Microting.eForm' 'Microting.EformBackendConfigurationBase' 'Microting.ItemsPlanningBase' 'Microting.Rebus' 'Microting.Rebus.Castle.Windsor' 'Microting.Rebus.RabbitMq')
PROJECT_NAME='eformparsed.csproj'
REPOSITORY='eform-service-backend-configuration-plugin'
for PACKAGE_NAME in ${PACKAGES[@]}; do
OLD_VERSION=`dotnet list package | grep "$PACKAGE_NAME " | grep -oP ' \d\.\d+\.\d.*' | grep -oP ' \d.* \b' | xargs`
dotnet add $PROJECT_NAME package $PACKAGE_NAME
NEW_VERSION=`dotnet list package | grep "$PACKAGE_NAME " | grep -oP ' \d\.\d+\.\d.*$' | grep -oP '\d\.\d+\.\d.*$' | grep -oP ' \d\.\d+\.\d.*$' | xargs`
if [ $NEW_VERSION != $OLD_VERSION ]; then
echo "We have a new version of $PACKAGE_NAME, so creating github issue and do a commit message to close that said issue"
RESULT=`curl -X "POST" "https://api.github.com/repos/microting/$REPOSITORY/issues?state=all" \
-H "Cookie: logged_in=no" \
-H "Authorization: token $CHANGELOG_GITHUB_TOKEN" \
-H "Content-Type: text/plain; charset=utf-8" \
-d $'{
"title": "Bump '$PACKAGE_NAME' from '$OLD_VERSION' to '$NEW_VERSION'",
"body": "TBD",
"assignees": [
"renemadsen"
],
"labels": [
".NET",
"backend",
"enhancement"
]
}'`
ISSUE_NUMBER=`echo $RESULT | grep -oP 'number": \d+,' | grep -oP '\d+'`
git add .
git commit -a -m "closes #$ISSUE_NUMBER"
fi
done
NEW_NUMBER_OF_COMMITS=`git log --oneline | wc -l`
if (( $NEW_NUMBER_OF_COMMITS > $CURRENT_NUMBER_OF_COMMITS )); then
CURRENT_GITVERSION=`git tag --sort=-creatordate | cut -d "v" -f 2 | sed -n 1p`
MAJOR_VERSION=`echo $CURRENT_GITVERSION | cut -d "." -f 1`
MINOR_VERSION=`echo $CURRENT_GITVERSION | cut -d "." -f 2`
BUILD_VERSION=`echo $CURRENT_GITVERSION | cut -d "." -f 3`
BUILD_VERSION=$(($BUILD_VERSION + 1))
NEW_GIT_VERSION="v$MAJOR_VERSION.$MINOR_VERSION.$BUILD_VERSION"
git tag "$NEW_GIT_VERSION"
git push --tags
git push
echo "Updated Microting eForm to ${EFORM_VERSION} and pushed new version ${NEW_GIT_VERSION}"
cd ..
else
echo "nothing to do, everything is up to date."
fi
else
echo "Working tree is not clean, so we are not going to upgrade. Clean, before doing upgrade!"
fi