-
Notifications
You must be signed in to change notification settings - Fork 4
/
release.sh
executable file
·74 lines (57 loc) · 2.72 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
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
#!/usr/bin/env bash
set -e
LINUX_BINARY="vet-linux_x64.zip"
MACOSX_BINARY="vet-macosx_x64.zip"
WINDOWS_BINARY="vet-windows_x64.zip"
GITHUB_CREDENTIALS=$(cat .github-credentials)
GITHUB_BASE_URL="https://api.github.com/repos/Cosium/vet"
CURRENT_VERSION=$(cat version.txt)
NEW_VERSION=$(echo ${CURRENT_VERSION} | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}')
echo "Releasing ${NEW_VERSION}"
echo "Checking jq presence"
jq --version > /dev/null
echo "Checked jq presence"
echo "Checking curl presence"
curl --version > /dev/null
echo "Checked curl presence"
echo "Bumping version.txt"
echo ${NEW_VERSION} > version.txt
git add version.txt
echo "Bumped version.txt"
echo "Bumping README.md"
README_CONTENT=$(cat README.md)
echo "${README_CONTENT/$CURRENT_VERSION/$NEW_VERSION}" > README.md
git add README.md
echo "Bumped README.md"
echo "Cleaning"
./gradlew clean
echo "Cleaned"
echo "Buiding binaries"
./gradlew -Pproject-version=${NEW_VERSION} binaries
echo "Built binaries"
echo "Uploading to sonatype repository"
./gradlew -Pproject-version=${NEW_VERSION} uploadArchives
echo "Uploaded to sonatype repository"
echo "Pushing to git"
git commit -m "Release ${NEW_VERSION}" && git tag ${NEW_VERSION}
git push && git push --tags
echo "Pushed to git"
echo "Uploading binaries to GitHub"
GITHUB_UPLOAD_URL=$(curl -u ${GITHUB_CREDENTIALS} -X POST -H "Content-Type: application/json" -d "{\"tag_name\": \"${NEW_VERSION}\", \"draft\": false}" ${GITHUB_BASE_URL}/releases | jq -r '.upload_url' | cut -d'{' -f 1)
echo "Uploading Linux binaries to GitHub"
curl -u ${GITHUB_CREDENTIALS} -H "Content-Type: application/zip" --data-binary @build/binaries/${LINUX_BINARY} ${GITHUB_UPLOAD_URL}?name=${LINUX_BINARY}
echo "Uploading MacOSX binaries to GitHub"
curl -u ${GITHUB_CREDENTIALS} -H "Content-Type: application/zip" --data-binary @build/binaries/${MACOSX_BINARY} ${GITHUB_UPLOAD_URL}?name=${MACOSX_BINARY}
echo "Uploading Windows binaries to GitHub"
curl -u ${GITHUB_CREDENTIALS} -H "Content-Type: application/zip" --data-binary @build/binaries/${WINDOWS_BINARY} ${GITHUB_UPLOAD_URL}?name=${WINDOWS_BINARY}
echo "Uploaded binaries to GitHub"
echo "Publishing Linux deb package"
distribution/deb/publish.sh ${NEW_VERSION} ${GITHUB_UPLOAD_URL}
echo "Published Linux deb file"
echo "Publishing Homebrew package"
distribution/homebrew/publish.sh ${NEW_VERSION} $(sha256sum build/binaries/${MACOSX_BINARY} | cut -d' ' -f 1)
echo "Published Homebrew package"
echo "Publishing Chocolatey package"
distribution/chocolatey/publish.sh ${NEW_VERSION} $(sha256sum build/binaries/${WINDOWS_BINARY} | cut -d' ' -f 1)
echo "Published Chocolatey package"
echo "Released ${NEW_VERSION}"