/
github_release_withjdk.sh
203 lines (135 loc) · 4.5 KB
/
github_release_withjdk.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/bash
function update_tag() {
echo "update tag " $1
git config --global user.email "my.gama.bot@gmail.com"
git config --global user.name "GAMA Bot"
git remote rm origin
git remote add origin https://gama-bot:$BOT_TOKEN@github.com/gama-platform/gama.git
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch origin
git checkout --track origin/master
git pull
git status
git push origin :refs/tags/$1
git tag -d $1
git tag -fa $1 -m "$1"
git push --tags -f
git ls-remote --tags origin
git show-ref --tags
}
set -e
echo "github_release_withjdk"
COMMIT=$@
REPO="gama-platform/gama"
RELEASE="1.8.2"
COMMIT="${COMMIT:0:7}"
BRANCH_NAME=$(echo $GITHUB_REF | cut -d'/' -f 3)
COMMIT=$(echo $GITHUB_SHA | cut -c1-8)
timestamp=$(date '+_%D')
SUFFIX=$timestamp'_'$COMMIT'.zip'
SUFFIX_MAC=$timestamp'_'$COMMIT'.dmg'
SUFFIX_DEB=$timestamp'_'$COMMIT'.deb'
echo $SUFFIX
n=0
RELEASEFILES[$n]="$thePATH-linux.gtk.x86_64.zip"
NEWFILES[$n]='GAMA_1.8.2_Linux'$SUFFIX
n=1
RELEASEFILES[$n]="$thePATH-macosx.cocoa.x86_64.dmg"
NEWFILES[$n]='GAMA_1.8.2_MacOS'$SUFFIX_MAC
n=2
RELEASEFILES[$n]="$thePATH-win32.win32.x86_64.zip"
NEWFILES[$n]='GAMA_1.8.2_Windows'$SUFFIX
n=3
RELEASEFILES[$n]="$thePATH-linux.gtk.x86_64_withJDK.zip"
NEWFILES[$n]='GAMA_1.8.2_Linux_with_JDK'$SUFFIX
n=4
RELEASEFILES[$n]="$thePATH-win32.win32.x86_64_withJDK.zip"
NEWFILES[$n]='GAMA_1.8.2_Windows_with_JDK'$SUFFIX
n=5
RELEASEFILES[$n]="$thePATH-macosx.cocoa.x86_64_withJDK.dmg"
NEWFILES[$n]='GAMA_1.8.2_MacOS_with_JDK'$SUFFIX_MAC
n=6
RELEASEFILES[$n]="$thePATH-macosx.cocoa.aarch64.dmg"
NEWFILES[$n]='GAMA_1.8.2_MacOS_M1'$SUFFIX_MAC
n=7
RELEASEFILES[$n]="$thePATH-macosx.cocoa.aarch64_withJDK.dmg"
NEWFILES[$n]='GAMA_1.8.2_MacOS_M1_with_JDK'$SUFFIX_MAC
n=8
RELEASEFILES[$n]="${{ github.workspace }}/gama-platform_1.8.2-1_amd64"
NEWFILES[$n]='GAMA_1.8.2_Linux'$SUFFIX_DEB
n=8
RELEASEFILES[$n]="${{ github.workspace }}/gama-platform-jdk_1.8.2-1_amd64"
NEWFILES[$n]='GAMA_1.8.2_Linux_with_JDK'$SUFFIX_DEB
i=0
for (( i=0; i<8; i++ ))
do
FILE="${RELEASEFILES[$i]}"
NFILE="${NEWFILES[$i]}"
ls -lh -- "$FILE"
echo "$NFILE"
done
LK1="https://api.github.com/repos/gama-platform/gama/releases/tags/$RELEASE"
echo "Getting info of release Continuous... "
RESULT1=`curl -s -X GET \
-H "Authorization: token $BOT_TOKEN" \
"$LK1"`
echo $RESULT1
json=$RESULT1
prop='id'
temp=`echo $json | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"//g' | grep -w $prop`
assets=`echo ${temp##*|}`
for theid in $assets; do
if [ "$theid" != "id:" ]; then
LK1="https://api.github.com/repos/gama-platform/gama/releases/$theid"
echo "Deleting release Continuous... "
RESULT1=`curl -s -X DELETE \
-H "Authorization: token $BOT_TOKEN" \
"$LK1"`
echo $RESULT1
break
fi
done
#update_tag $RELEASE
echo "Creating release Continuous... "
LK="https://api.github.com/repos/gama-platform/gama/releases"
RESULT=` curl -s -X POST \
-H "X-Parse-Application-Id: sensitive" \
-H "X-Parse-REST-API-Key: sensitive" \
-H "Authorization: token $BOT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"tag_name": "'$RELEASE'", "name":"Alpha Version 1.8.2 ('$COMMIT')","body":"Alpha release for GAMA 1.8.2, which adds compatibility with JDK 17 . Please test and report issues","draft": false,"prerelease": true}' \
"$LK"`
echo $RESULT
echo
echo "Getting info of $RELEASE tag..."
echo
LK="https://api.github.com/repos/gama-platform/gama/releases/tags/$RELEASE"
RESULT=` curl -s -X GET \
-H "X-Parse-Application-Id: sensitive" \
-H "X-Parse-REST-API-Key: sensitive" \
-H "Authorization: token $BOT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"value"}' \
"$LK"`
echo $RESULT
RELEASEID=`echo "$RESULT" | sed -ne 's/^ "id": \(.*\),$/\1/p'`
echo $RELEASEID
echo
echo "Upload new files..."
echo
for (( i=0; i<8; i++ ))
do
FILE="${RELEASEFILES[$i]}"
NFILE="${NEWFILES[$i]}"
FILENAME=`basename $FILE`
echo "Uploading $NFILE... "
LK="https://uploads.github.com/repos/gama-platform/gama/releases/$RELEASEID/assets?name=$NFILE"
RESULT=`curl -s -w "\n%{http_code}\n" \
-H "Authorization: token $BOT_TOKEN" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/zip" \
--data-binary "@$FILE" \
"$LK"`
echo $RESULT
done
echo DONE