forked from zorn-v/nextcloud-social-login
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·43 lines (34 loc) · 1.93 KB
/
release.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
#!/bin/bash
GITHUB_REPO=zorn-v/nextcloud-social-login
APP_NAME=sociallogin
cd `dirname $0`
git diff --quiet --exit-code
[ $? != 0 ] && echo There is unstaged changes && exit 1
[ ! -f .credentials ] && echo No credentials file found && exit 1
. .credentials
[ -z "$GITHUB_TOKEN" ] && echo GITHUB_TOKEN var is missing. Go to https://github.com/settings/tokens get one and put it in .credentials && exit 1
[ -z "$NC_TOKEN" ] && echo NC_TOKEN var is missing. Go to https://apps.nextcloud.com/account/token get one and put it in .credentials && exit 1
VERSION=v`grep '<version>' appinfo/info.xml | sed 's/[^0-9.]//g'`
UPLOAD_URL=`curl -sH "Authorization: token $GITHUB_TOKEN" -d "{\"tag_name\":\"$VERSION\"}" https://api.github.com/repos/$GITHUB_REPO/releases | grep '"upload_url"' | sed 's/.*"\(https:.*\){.*/\1/'`
[ -z "$UPLOAD_URL" ] && echo Can not get upload url && exit 1
git checkout master
git pull origin master
git checkout -b release
git tag $VERSION
git log --format='%D- %s' | sed -e 's/HEAD -> release, //' -e 's/, origin\/master, origin\/HEAD, master//' -e 's/tag: v\([^-]*\)/\n## \1\n/' > CHANGELOG.md
git add CHANGELOG.md
sed -i '/<description><\/description>/ {
a <description><![CDATA[
r README.md
a ]]></description>
d
}' appinfo/info.xml
git commit -am 'Release'
git archive release --prefix=$APP_NAME/ -o release.tar.gz
git checkout master
git branch -D release
curl -sH "Authorization: token $GITHUB_TOKEN" -H 'Content-Type: application/octet-stream' --data-binary '@release.tar.gz' ${UPLOAD_URL}?name=release.tar.gz > /dev/null
DOWNLOAD_URL=https://github.com/$GITHUB_REPO/releases/download/$VERSION/release.tar.gz
SIG=`openssl dgst -sha512 -sign ~/.nextcloud/certificates/$APP_NAME.key release.tar.gz | openssl base64 -A`
curl -X POST -sH "Authorization: Token $NC_TOKEN" -H 'Content-Type: application/json' -d "{\"download\":\"$DOWNLOAD_URL\",\"signature\":\"$SIG\"}" https://apps.nextcloud.com/api/v1/apps/releases
rm -f release.tar.gz