Skip to content

Commit 5f43e9f

Browse files
committed
Use new build scripts
1 parent c5df952 commit 5f43e9f

File tree

9 files changed

+88
-303
lines changed

9 files changed

+88
-303
lines changed

.ci/build.sh

Lines changed: 50 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,104 @@
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"
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
1919
sudo apt-get install --yes libgtk2.0-0
20-
log_group_end
20+
pmd_ci_log_group_end
2121

22-
log_group_start "Determine project name + version"
23-
pmd_ci_maven_get_project_name
24-
local name="${RESULT}"
25-
pmd_ci_maven_get_project_version
26-
local version="${RESULT}"
27-
log_group_end
28-
29-
echo
30-
echo
31-
log_info "======================================================================="
32-
log_info "Building ${name} ${version}"
33-
log_info "======================================================================="
34-
pmd_ci_determine_build_env pmd/pmd-eclipse-plugin
3522
echo
23+
pmd_ci_maven_display_info_banner
24+
pmd_ci_utils_determine_build_env pmd/pmd-eclipse-plugin
3625
echo
3726

38-
if pmd_ci_is_fork_or_pull_request; then
39-
log_group_start "Build with mvnw"
40-
xvfb-run --auto-servernum ./mvnw clean verify -B -V -e
41-
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
4231
exit 0
4332
fi
4433

45-
# only builds on pmd/build-tools continue here
46-
log_group_start "Setup environment"
47-
# PMD_SF_USER, BINTRAY_USER, BINTRAY_APIKEY, GITHUB_OAUTH_TOKEN, GITHUB_BASE_URL
48-
pmd_ci_secrets_load_private_env
49-
pmd_ci_secrets_setup_ssh
34+
# only builds on pmd/pmd-eclipse-plugin continue here
35+
pmd_ci_log_group_start "Setup environment"
36+
pmd_ci_setup_secrets_private_env
37+
pmd_ci_setup_secrets_ssh
5038
pmd_ci_maven_setup_settings
51-
log_group_end
39+
pmd_ci_log_group_end
40+
41+
if pmd_ci_maven_isSnapshotBuild; then
42+
snapshot_build
43+
elif pmd_ci_maven_isReleaseBuild; then
44+
release_build
45+
else
46+
pmd_ci_log_error "Invalid combination: version=${PMD_CI_MAVEN_PROJECT_VERSION} branch=${PMD_CI_BRANCH} tag=${PMD_CI_TAG}"
47+
exit 1
48+
fi
49+
}
5250

53-
if [[ "${version}" == *-SNAPSHOT && "${PMD_CI_BRANCH}" != "" ]]; then
54-
log_group_start "Snapshot Build: ${version}"
55-
log_info "This is a snapshot build on branch ${PMD_CI_BRANCH} (version: ${version})"
51+
function snapshot_build() {
52+
pmd_ci_log_group_start "Snapshot Build: ${PMD_CI_MAVEN_PROJECT_VERSION}"
53+
pmd_ci_log_info "This is a snapshot build on branch ${PMD_CI_BRANCH} (version: ${PMD_CI_MAVEN_PROJECT_VERSION})"
5654

5755
# Uploading the update site to Bintray
58-
xvfb-run --auto-servernum ./mvnw clean verify -B -V -e -Psnapshot-properties -Prelease-composite
56+
xvfb-run --auto-servernum ./mvnw clean verify --show-version --errors --batch-mode \
57+
--no-transfer-progress \
58+
--activate-profiles snapshot-properties,release-composite
5959

6060
# Cleanup old snapshots
6161
(
6262
cd net.sourceforge.pmd.eclipse.p2updatesite
6363
./cleanup-bintray-snapshots.sh
6464
)
65-
log_group_end
65+
pmd_ci_log_group_end
66+
}
6667

67-
elif [[ "${version}" != *-SNAPSHOT && "${PMD_CI_TAG}" != "" ]]; then
68-
log_group_start "Release Build: ${version}"
69-
log_info "This is a release build for tag ${PMD_CI_TAG} (version: ${version})"
68+
function release_build() {
69+
pmd_ci_log_group_start "Release Build: ${PMD_CI_MAVEN_PROJECT_VERSION}"
70+
pmd_ci_log_info "This is a release build for tag ${PMD_CI_TAG} (version: ${PMD_CI_MAVEN_PROJECT_VERSION})"
7071

7172
# create a draft github release
72-
gh_releases_createDraftRelease "${PMD_CI_TAG}" "$(git rev-list -n 1 ${PMD_CI_TAG})"
73+
pmd_ci_gh_releases_createDraftRelease "${PMD_CI_TAG}" "$(git rev-list -n 1 "${PMD_CI_TAG}")"
7374
GH_RELEASE="$RESULT"
7475

7576
# Deploy the update site to bintray
76-
xvfb-run --auto-servernum ./mvnw clean verify -B -V -e -Prelease-composite
77+
xvfb-run --auto-servernum ./mvnw clean verify --show-version --errors --batch-mode \
78+
--no-transfer-progress \
79+
--activate-profiles release-composite
7780

7881
# Deploy to github releases
79-
gh_release_uploadAsset "$GH_RELEASE" "net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-${version}.zip"
82+
pmd_ci_gh_releases_uploadAsset "$GH_RELEASE" "net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-${PMD_CI_MAVEN_PROJECT_VERSION}.zip"
8083

8184
# extract the release notes
82-
RELEASE_NAME="PMD For Eclipse ${version} ($(date -u +%d-%B-%Y))"
85+
RELEASE_NAME="PMD For Eclipse ${PMD_CI_MAVEN_PROJECT_VERSION} ($(date -u +%d-%B-%Y))"
8386
BEGIN_LINE=$(grep -n "^## " ReleaseNotes.md|head -1|cut -d ":" -f 1)
8487
END_LINE=$(grep -n "^## " ReleaseNotes.md|head -2|tail -1|cut -d ":" -f 1)
8588
END_LINE=$((END_LINE - 1))
8689

8790
RELEASE_BODY="A new PMD for Eclipse plugin version has been released.
8891
It is available via the update site: https://dl.bintray.com/pmd/pmd-eclipse-plugin/updates/
8992
90-
$(cat ReleaseNotes.md|head -$END_LINE|tail -$((END_LINE - BEGIN_LINE)))
93+
$(head -$END_LINE ReleaseNotes.md | tail -$((END_LINE - BEGIN_LINE)))
9194
"
9295

93-
gh_release_updateRelease "$GH_RELEASE" "$RELEASE_NAME" "$RELEASE_BODY"
96+
pmd_ci_gh_releases_updateRelease "$GH_RELEASE" "$RELEASE_NAME" "$RELEASE_BODY"
9497

9598
# Publish release
96-
gh_release_publishRelease "$GH_RELEASE"
97-
98-
log_group_end
99-
100-
else
101-
log_error "Invalid combination: version=${version} branch=${PMD_CI_BRANCH} tag=${PMD_CI_TAG}"
102-
exit 1
103-
fi
104-
}
99+
pmd_ci_gh_releases_publishRelease "$GH_RELEASE"
105100

106-
function fetch_ci_scripts() {
107-
mkdir -p .ci/inc
108-
109-
for f in \
110-
logger.bash \
111-
utils.bash \
112-
openjdk.bash \
113-
secrets.bash \
114-
maven.bash \
115-
; do
116-
if [ ! -e .ci/inc/$f ]; then
117-
curl -sSL https://raw.githubusercontent.com/pmd/build-tools/master/.ci/inc/$f > .ci/inc/$f
118-
fi
119-
source .ci/inc/$f || exit 1
120-
done
101+
pmd_ci_log_group_end
121102
}
122103

123104
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)