-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
executable file
·133 lines (106 loc) · 4.74 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
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
#!/bin/bash
set -e
source .travis/logger.sh
echo "BUILD: $BUILD"
RELEASE_VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1)
echo "RELEASE_VERSION: $RELEASE_VERSION"
if [ "${BUILD}" = "deploy" ]; then
# Deploy to ossrh has already been done with the usual build. See build-deploy.sh
(
# disable fast fail, exit immediately, in this subshell
set +e
# The site has been built before, the files have already been uploaded to sourceforge.
# Since this is a release, making the binary the new default file...
log_info "Selecting pmd-bin-${RELEASE_VERSION} as default on sourceforge.net..."
curl -H "Accept: application/json" -X PUT -d "default=windows&default=mac&default=linux&default=bsd&default=solaris&default=others" \
-d "api_key=${PMD_SF_APIKEY}" https://sourceforge.net/projects/pmd/files/pmd/${RELEASE_VERSION}/pmd-bin-${RELEASE_VERSION}.zip
if [ $? -ne 0 ]; then
log_error "Couldn't select latest binary as default on sourceforge.net"
else
log_info "pmd-bin-${RELEASE_VERSION} is now the default download option."
fi
true
)
# renders, and skips the first 6 lines - the Jekyll front-matter
RENDERED_RELEASE_NOTES=$(bundle exec .travis/render_release_notes.rb docs/pages/release_notes.md | tail -n +6)
# Assumes, the release has already been created by travis github releases provider
RELEASE_ID=$(curl -s -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" https://api.github.com/repos/pmd/pmd/releases/tags/pmd_releases/${RELEASE_VERSION}|jq ".id")
RELEASE_NAME="PMD ${RELEASE_VERSION} ($(date -u +%d-%B-%Y))"
RELEASE_BODY="$RENDERED_RELEASE_NOTES"
RELEASE_BODY="${RELEASE_BODY//'\'/\\\\}"
RELEASE_BODY="${RELEASE_BODY//$'\r'/}"
RELEASE_BODY="${RELEASE_BODY//$'\n'/\\r\\n}"
RELEASE_BODY="${RELEASE_BODY//'"'/\\\"}"
cat > release-edit-request.json <<EOF
{
"name": "$RELEASE_NAME",
"body": "$RELEASE_BODY"
}
EOF
log_info "Updating release at https://api.github.com/repos/pmd/pmd/releases/${RELEASE_ID}..."
RESPONSE=$(curl -i -s -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" -H "Content-Type: application/json" --data "@release-edit-request.json" -X PATCH https://api.github.com/repos/pmd/pmd/releases/${RELEASE_ID})
if [[ "$RESPONSE" != *"HTTP/1.1 200"* ]]; then
log_error "Github Request failed!"
echo "Request:"
cat release-edit-request.json
echo
echo "Response:"
echo "$RESPONSE"
else
log_success "Update OK"
fi
fi
if [ "${BUILD}" = "doc" ]; then
echo -e "\n\n"
log_info "Adding the new doc to pmd.github.io..."
# clone pmd.github.io. Note: This uses the ssh key setup earlier
# In order to speed things up, we use a sparse checkout - no need to checkout all directories here
mkdir pmd.github.io
(
cd pmd.github.io
git init
git config user.name "Travis CI (pmd-bot)"
git config user.email "[email protected]"
git config core.sparsecheckout true
git remote add origin [email protected]:pmd/pmd.github.io.git
echo "/latest/" > .git/info/sparse-checkout
echo "/sitemap.xml" >> .git/info/sparse-checkout
git pull --depth=1 origin master
log_info "Copying documentation from ../docs/pmd-doc-${RELEASE_VERSION}/ to pmd-${RELEASE_VERSION}/ ..."
rsync -ah --stats ../docs/pmd-doc-${RELEASE_VERSION}/ pmd-${RELEASE_VERSION}/
git status
echo "Executing: git add pmd-${RELEASE_VERSION}"
git add pmd-${RELEASE_VERSION}
echo "Executing: git commit..."
git commit -q -m "Added pmd-${RELEASE_VERSION}"
log_info "Copying pmd-${RELEASE_VERSION} to latest ..."
git rm -qr latest
cp -a pmd-${RELEASE_VERSION} latest
echo "Executing: git add latest"
git add latest
echo "Executing: git commit..."
git commit -q -m "Copying pmd-${RELEASE_VERSION} to latest"
log_info "Generating sitemap.xml"
../.travis/sitemap_generator.sh > sitemap.xml
echo "Executing: git add sitemap.xml"
git add sitemap.xml
echo "Executing: git commit..."
git commit -q -m "Generated sitemap.xml"
echo "Executing: git push origin master"
git push origin master
)
(
echo -e "\n\n"
# disable fast fail, exit immediately, in this subshell
set +e
log_info "Uploading the new release to pmd.sourceforge.net which serves as an archive..."
.travis/travis_wait "rsync -ah --stats docs/pmd-doc-${RELEASE_VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/pmd-${RELEASE_VERSION}/"
if [ $? -ne 0 ]; then
log_error "Uploading documentation to pmd.sourceforge.net failed..."
log_error "Please upload manually (PMD Version: ${RELEASE_VERSION})"
else
log_success "The documentation is now available under http://pmd.sourceforge.net/pmd-${RELEASE_VERSION}/"
fi
true
)
fi