Skip to content

Commit 3c46cc8

Browse files
committed
Merge branch 'master' into deprecations
2 parents 32840c9 + 461504e commit 3c46cc8

File tree

64 files changed

+1075
-589
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1075
-589
lines changed

.ci/build.sh

Lines changed: 217 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,269 @@
11
#!/usr/bin/env bash
22

3-
source $(dirname $0)/inc/github-releases-api.bash || exit 1
4-
53
# Exit this script immediately if a command/function exits with a non-zero status.
64
set -e
75

8-
function build() {
9-
fetch_ci_scripts
6+
SCRIPT_INCLUDES="log.bash utils.bash setup-secrets.bash openjdk.bash maven.bash sourceforge-api.bash github-releases-api.bash"
7+
# shellcheck source=inc/fetch_ci_scripts.bash
8+
source "$(dirname "$0")/inc/fetch_ci_scripts.bash" && fetch_ci_scripts
109

11-
log_group_start "Install OpenJDK"
10+
function build() {
11+
pmd_ci_log_group_start "Install OpenJDK"
1212
pmd_ci_openjdk_install_adoptopenjdk 8
1313
pmd_ci_openjdk_setdefault 8
14-
log_group_end
14+
pmd_ci_log_group_end
1515

16-
log_group_start "Install xvfb"
16+
pmd_ci_log_group_start "Install xvfb"
1717
#see https://github.com/GabrielBB/xvfb-action
1818
sudo apt-get install --yes xvfb
19-
log_group_end
20-
21-
log_group_start "Determine project name + version"
22-
pmd_ci_maven_get_project_name
23-
local name="${RESULT}"
24-
pmd_ci_maven_get_project_version
25-
local version="${RESULT}"
26-
log_group_end
19+
sudo apt-get install --yes libgtk2.0-0
20+
pmd_ci_log_group_end
2721

2822
echo
29-
echo
30-
log_info "======================================================================="
31-
log_info "Building ${name} ${version}"
32-
log_info "======================================================================="
33-
pmd_ci_determine_build_env pmd/pmd-eclipse-plugin
34-
echo
23+
pmd_ci_maven_display_info_banner
24+
pmd_ci_utils_determine_build_env pmd/pmd-eclipse-plugin
3525
echo
3626

37-
if pmd_ci_is_fork_or_pull_request; then
38-
log_group_start "Build with mvnw"
39-
xvfb-run --auto-servernum ./mvnw clean verify -B -V -e
40-
log_group_end
27+
if pmd_ci_utils_is_fork_or_pull_request; then
28+
pmd_ci_log_group_start "Build with mvnw"
29+
xvfb-run --auto-servernum ./mvnw clean verify --show-version --errors --batch-mode --no-transfer-progress
30+
pmd_ci_log_group_end
4131
exit 0
4232
fi
4333

44-
# only builds on pmd/build-tools continue here
45-
log_group_start "Setup environment"
46-
# PMD_SF_USER, BINTRAY_USER, BINTRAY_APIKEY, GITHUB_OAUTH_TOKEN, GITHUB_BASE_URL
47-
pmd_ci_secrets_load_private_env
48-
pmd_ci_secrets_setup_ssh
34+
# stop early for invalid maven version and branch/tag combination
35+
pmd_ci_maven_verify_version || exit 0
36+
37+
# only builds on pmd/pmd-eclipse-plugin continue here
38+
pmd_ci_log_group_start "Setup environment"
39+
pmd_ci_setup_secrets_private_env
40+
pmd_ci_setup_secrets_ssh
4941
pmd_ci_maven_setup_settings
50-
log_group_end
42+
pmd_ci_log_group_end
43+
44+
if pmd_ci_maven_isSnapshotBuild; then
45+
snapshot_build
46+
elif pmd_ci_maven_isReleaseBuild; then
47+
release_build
48+
else
49+
pmd_ci_log_error "Invalid combination: version=${PMD_CI_MAVEN_PROJECT_VERSION} branch=${PMD_CI_BRANCH} tag=${PMD_CI_TAG}"
50+
exit 1
51+
fi
52+
}
53+
54+
function snapshot_build() {
55+
pmd_ci_log_group_start "Snapshot Build: ${PMD_CI_MAVEN_PROJECT_VERSION}"
56+
pmd_ci_log_info "This is a snapshot build on branch ${PMD_CI_BRANCH} (version: ${PMD_CI_MAVEN_PROJECT_VERSION})"
5157

52-
if [[ "${version}" == *-SNAPSHOT && "${PMD_CI_BRANCH}" != "" ]]; then
53-
log_group_start "Snapshot Build: ${version}"
54-
log_info "This is a snapshot build on branch ${PMD_CI_BRANCH} (version: ${version})"
58+
# Build and upload the update site to Bintray
59+
xvfb-run --auto-servernum ./mvnw clean verify --show-version --errors --batch-mode \
60+
--no-transfer-progress \
61+
--activate-profiles snapshot-properties,release-composite
5562

56-
# Uploading the update site to Bintray
57-
xvfb-run --auto-servernum ./mvnw clean verify -B -V -e -Psnapshot-properties -Prelease-composite
63+
local qualifiedVersion
64+
qualifiedVersion="$(basename net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-*.zip)"
65+
qualifiedVersion="${qualifiedVersion%.zip}"
66+
qualifiedVersion="${qualifiedVersion#net.sourceforge.pmd.eclipse.p2updatesite-}"
67+
mv "net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-${qualifiedVersion}.zip" "net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-SNAPSHOT.zip"
68+
pmd_ci_sourceforge_uploadFile "pmd-eclipse/zipped" "net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-SNAPSHOT.zip"
5869

5970
# Cleanup old snapshots
6071
(
6172
cd net.sourceforge.pmd.eclipse.p2updatesite
6273
./cleanup-bintray-snapshots.sh
6374
)
64-
log_group_end
75+
pmd_ci_log_group_end
6576

66-
elif [[ "${version}" != *-SNAPSHOT && "${PMD_CI_TAG}" != "" ]]; then
67-
log_group_start "Release Build: ${version}"
68-
log_info "This is a release build for tag ${PMD_CI_TAG} (version: ${version})"
77+
pmd_ci_log_group_start "Add snapshot to update site"
78+
pmd_ci_log_info "Updating pmd-eclipse-plugin-p2-site..."
79+
prepare_local_p2_site
80+
(
81+
cd current-p2-site
82+
83+
rm -rf snapshot
84+
unzip -q -d snapshot "../net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-SNAPSHOT.zip"
85+
echo "This is a Eclipse Update Site for the [PMD Eclipse Plugin](https://github.com/pmd/pmd-eclipse-plugin/) ${PMD_CI_MAVEN_PROJECT_VERSION}.
86+
87+
Use <https://pmd.github.io/pmd-eclipse-plugin-p2-site/snapshot/> to install the plugin with the Eclipse Update Manager.
88+
89+
<dl>
90+
<dt>Feature ID</dt>
91+
<dd>net.sourceforge.pmd.eclipse</dd>
92+
<dt>Version</dt>
93+
<dd>${qualifiedVersion}</dd>
94+
</dl>
95+
96+
" > snapshot/index.md
97+
git add snapshot
98+
99+
# create a new single commit
100+
git checkout --orphan=gh-pages-2
101+
git commit -a -m "Update pmd/pmd-eclipse-plugin-p2-site"
102+
git push --force origin gh-pages-2:gh-pages
103+
pmd_ci_log_success "Successfully updated https://pmd.github.io/pmd-eclipse-plugin-p2-site/"
104+
)
69105

106+
pmd_ci_log_group_end
107+
}
108+
109+
function release_build() {
110+
pmd_ci_log_group_start "Release Build: ${PMD_CI_MAVEN_PROJECT_VERSION}"
111+
pmd_ci_log_info "This is a release build for tag ${PMD_CI_TAG} (version: ${PMD_CI_MAVEN_PROJECT_VERSION})"
112+
113+
# Build and deploy the update site to bintray
114+
xvfb-run --auto-servernum ./mvnw clean verify --show-version --errors --batch-mode \
115+
--no-transfer-progress \
116+
--activate-profiles release-composite
117+
pmd_ci_log_group_end
118+
119+
pmd_ci_log_group_start "Update Github Releases"
70120
# create a draft github release
71-
gh_releases_createDraftRelease "${PMD_CI_TAG}" "$(git rev-list -n 1 ${PMD_CI_TAG})"
121+
pmd_ci_gh_releases_createDraftRelease "${PMD_CI_TAG}" "$(git rev-list -n 1 "${PMD_CI_TAG}")"
72122
GH_RELEASE="$RESULT"
73123

74-
# Deploy the update site to bintray
75-
xvfb-run --auto-servernum ./mvnw clean verify -B -V -e -Prelease-composite
76-
77124
# Deploy to github releases
78-
gh_release_uploadAsset "$GH_RELEASE" "net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-${version}.zip"
125+
pmd_ci_gh_releases_uploadAsset "$GH_RELEASE" "net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-${PMD_CI_MAVEN_PROJECT_VERSION}.zip"
79126

80127
# extract the release notes
81-
RELEASE_NAME="PMD For Eclipse ${version} ($(date -u +%d-%B-%Y))"
128+
RELEASE_NAME="PMD For Eclipse ${PMD_CI_MAVEN_PROJECT_VERSION}"
82129
BEGIN_LINE=$(grep -n "^## " ReleaseNotes.md|head -1|cut -d ":" -f 1)
83130
END_LINE=$(grep -n "^## " ReleaseNotes.md|head -2|tail -1|cut -d ":" -f 1)
84131
END_LINE=$((END_LINE - 1))
85132

86133
RELEASE_BODY="A new PMD for Eclipse plugin version has been released.
87-
It is available via the update site: https://dl.bintray.com/pmd/pmd-eclipse-plugin/updates/
134+
It is available via the update site: https://pmd.github.io/pmd-eclipse-plugin-p2-site/
88135
89-
$(cat ReleaseNotes.md|head -$END_LINE|tail -$((END_LINE - BEGIN_LINE)))
136+
$(head -$END_LINE ReleaseNotes.md | tail -$((END_LINE - BEGIN_LINE)))
90137
"
91138

92-
gh_release_updateRelease "$GH_RELEASE" "$RELEASE_NAME" "$RELEASE_BODY"
139+
pmd_ci_gh_releases_updateRelease "$GH_RELEASE" "$RELEASE_NAME" "$RELEASE_BODY"
93140

94-
# Publish release
95-
gh_release_publishRelease "$GH_RELEASE"
141+
# Upload it to sourceforge
142+
pmd_ci_sourceforge_uploadFile "pmd-eclipse/zipped" "net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-${PMD_CI_MAVEN_PROJECT_VERSION}.zip"
96143

97-
log_group_end
144+
# Create sourceforge blog entry
145+
pmd_ci_sourceforge_createDraftBlogPost "$RELEASE_NAME released" "$RELEASE_BODY" "pmd-eclipse-plugin,release"
146+
local sf_blog_url="${RESULT}"
147+
pmd_ci_log_group_end
98148

99-
else
100-
log_error "Invalid combination: version=${version} branch=${PMD_CI_BRANCH} tag=${PMD_CI_TAG}"
101-
exit 1
102-
fi
149+
pmd_ci_log_group_start "Add new release to update site"
150+
pmd_ci_log_info "Updating pmd-eclipse-plugin-p2-site..."
151+
prepare_local_p2_site
152+
(
153+
cd current-p2-site
154+
155+
unzip -q -d "${PMD_CI_MAVEN_PROJECT_VERSION}" "net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-${PMD_CI_MAVEN_PROJECT_VERSION}.zip"
156+
git add "${PMD_CI_MAVEN_PROJECT_VERSION}"
157+
regenerate_metadata
158+
159+
# create a new single commit
160+
git checkout --orphan=gh-pages-2
161+
git commit -a -m "Update pmd/pmd-eclipse-plugin-p2-site"
162+
git push --force origin gh-pages-2:gh-pages
163+
pmd_ci_log_success "Successfully updated https://pmd.github.io/pmd-eclipse-plugin-p2-site/"
164+
)
165+
pmd_ci_log_group_end
166+
167+
# Publish release - this sends out notifications on github
168+
pmd_ci_gh_releases_publishRelease "$GH_RELEASE"
169+
# Publish sourceforge blog entry
170+
pmd_ci_sourceforge_publishBlogPost "${sf_blog_url}"
103171
}
104172

105-
function fetch_ci_scripts() {
106-
mkdir -p .ci/inc
107-
108-
for f in \
109-
logger.bash \
110-
utils.bash \
111-
openjdk.bash \
112-
secrets.bash \
113-
maven.bash \
114-
; do
115-
if [ ! -e .ci/inc/$f ]; then
116-
curl -sSL https://raw.githubusercontent.com/pmd/build-tools/master/.ci/inc/$f > .ci/inc/$f
117-
fi
118-
source .ci/inc/$f || exit 1
173+
174+
function prepare_local_p2_site() {
175+
pmd_ci_log_info "Preparing local copy of p2-site..."
176+
rm -rf current-p2-site
177+
mkdir current-p2-site
178+
(
179+
cd current-p2-site
180+
git init -q --initial-branch=gh-pages
181+
git config user.name "PMD CI (pmd-bot)"
182+
git config user.email "[email protected]"
183+
git remote add origin [email protected]:pmd/pmd-eclipse-plugin-p2-site.git
184+
git pull --rebase origin gh-pages
185+
)
186+
}
187+
188+
function regenerate_metadata() {
189+
pmd_ci_log_info "Regenerating metadata for p2-site..."
190+
local releases=($(find . -maxdepth 1 -type d -regex "\./[0-9]+\.[0-9]+\.[0-9]+\..*" -printf '%f\n'| tr '.' '\0' | sort -t '\0' -k1,1nr -k2,2nr -k3,3nr -k4dr |awk -F '\0' '{printf "%s.%s.%s.%s\n", $1, $2, $3, $4}'))
191+
# remove old releases
192+
for i in "${releases[@]:5}"; do
193+
pmd_ci_log_info "Removing old release $i..."
194+
rm -rf "$i"
195+
done
196+
releases=("${releases[@]:0:5}")
197+
198+
# regenerate metadata
199+
local now
200+
now=$(date +%s000)
201+
local children=""
202+
local children_index=""
203+
for i in "${releases[@]}"; do
204+
children="${children} <child location=\"$i\"/>\n"
205+
children_index="${children_index} * [$i]($i/)\n"
206+
echo "This is a Eclipse Update Site for the [PMD Eclipse Plugin](https://github.com/pmd/pmd-eclipse-plugin/) ${i}.
207+
208+
Use <https://pmd.github.io/pmd-eclipse-plugin-p2-site/${i}/> to install the plugin with the Eclipse Update Manager.
209+
210+
<dl>
211+
<dt>Feature ID</dt>
212+
<dd>net.sourceforge.pmd.eclipse</dd>
213+
<dt>Version</dt>
214+
<dd>${i}</dd>
215+
</dl>
216+
217+
" > "$i"/index.md
218+
219+
git add "$i"/index.md
119220
done
221+
222+
local site_name="PMD for Eclipse - Update Site"
223+
local artifactsTemplate="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
224+
<?compositeArtifactRepository version=\"1.0.0\"?>
225+
<repository name=\"${site_name}\" type=\"org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository\" version=\"1.0.0\">
226+
<properties size=\"2\">
227+
<property name=\"p2.timestamp\" value=\"${now}\"/>
228+
<property name=\"p2.atomic.composite.loading\" value=\"true\"/>
229+
</properties>
230+
<children size=\"${#releases[@]}\">
231+
${children} </children>
232+
</repository>"
233+
echo -e "${artifactsTemplate}" > compositeArtifacts.xml
234+
235+
local contentTemplate="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
236+
<?compositeMetadataRepository version=\"1.0.0\"?>
237+
<repository name=\"${site_name}\" type=\"org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository\" version=\"1.0.0\">
238+
<properties size=\"2\">
239+
<property name=\"p2.timestamp\" value=\"${now}\"/>
240+
<property name=\"p2.atomic.composite.loading\" value=\"true\"/>
241+
</properties>
242+
<children size=\"${#releases[@]}\">
243+
${children} </children>
244+
</repository>"
245+
echo -e "${contentTemplate}" > compositeContent.xml
246+
247+
# p2.index
248+
local p2_index="version = 1
249+
metadata.repository.factory.order = compositeContent.xml,\!
250+
artifact.repository.factory.order = compositeArtifacts.xml,\!"
251+
echo -e "${p2_index}" > p2.index
252+
253+
# regenerate index.md
254+
echo -e "This is a composite Eclipse Update Site for the [PMD Eclipse Plugin](https://github.com/pmd/pmd-eclipse-plugin/).
255+
256+
Use <https://pmd.github.io/pmd-eclipse-plugin-p2-site/> to install the plugin with the Eclipse Update Manager.
257+
258+
----
259+
260+
Versions available at <https://pmd.github.io/pmd-eclipse-plugin-p2-site/>:
261+
262+
${children_index}
263+
264+
For older versions, see <https://sourceforge.net/projects/pmd/files/pmd-eclipse/zipped/>
265+
266+
" > index.md
120267
}
121268

122269
build

.ci/files/id_rsa.gpg

-2.5 KB
Binary file not shown.

.ci/files/id_rsa.pub

Lines changed: 0 additions & 1 deletion
This file was deleted.

.ci/files/maven-settings.xml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.ci/files/private-env.gpg

-356 Bytes
Binary file not shown.

.ci/inc/fetch_ci_scripts.bash

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
function fetch_ci_scripts() {
4+
local inc_dir
5+
local inc_url
6+
inc_dir="$(dirname "$0")/inc"
7+
inc_url="${PMD_CI_SCRIPTS_URL:-https://raw.githubusercontent.com/pmd/build-tools/master/scripts}/inc"
8+
9+
mkdir -p "${inc_dir}"
10+
11+
for f in ${SCRIPT_INCLUDES}; do
12+
if [ ! -e "${inc_dir}/$f" ]; then
13+
curl -sSL "${inc_url}/$f" > "${inc_dir}/$f"
14+
fi
15+
[ "$PMD_CI_DEBUG" = "true" ] && echo "loading ${inc_dir}/$f in ${MODULE:-$0}"
16+
# shellcheck source=/dev/null
17+
source "${inc_dir}/$f" || exit 1
18+
done
19+
}

0 commit comments

Comments
 (0)