|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
3 | | -source $(dirname $0)/inc/github-releases-api.bash || exit 1 |
4 | | - |
5 | 3 | # Exit this script immediately if a command/function exits with a non-zero status. |
6 | 4 | set -e |
7 | 5 |
|
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 |
10 | 9 |
|
11 | | - log_group_start "Install OpenJDK" |
| 10 | +function build() { |
| 11 | + pmd_ci_log_group_start "Install OpenJDK" |
12 | 12 | pmd_ci_openjdk_install_adoptopenjdk 8 |
13 | 13 | pmd_ci_openjdk_setdefault 8 |
14 | | - log_group_end |
| 14 | + pmd_ci_log_group_end |
15 | 15 |
|
16 | | - log_group_start "Install xvfb" |
| 16 | + pmd_ci_log_group_start "Install xvfb" |
17 | 17 | #see https://github.com/GabrielBB/xvfb-action |
18 | 18 | sudo apt-get install --yes xvfb |
19 | 19 | sudo apt-get install --yes libgtk2.0-0 |
20 | | - log_group_end |
| 20 | + pmd_ci_log_group_end |
21 | 21 |
|
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 |
35 | 22 | echo |
| 23 | + pmd_ci_maven_display_info_banner |
| 24 | + pmd_ci_utils_determine_build_env pmd/pmd-eclipse-plugin |
36 | 25 | echo |
37 | 26 |
|
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 |
42 | 31 | exit 0 |
43 | 32 | fi |
44 | 33 |
|
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 |
50 | 38 | 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 | +} |
52 | 50 |
|
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})" |
56 | 54 |
|
57 | 55 | # 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 |
59 | 59 |
|
60 | 60 | # Cleanup old snapshots |
61 | 61 | ( |
62 | 62 | cd net.sourceforge.pmd.eclipse.p2updatesite |
63 | 63 | ./cleanup-bintray-snapshots.sh |
64 | 64 | ) |
65 | | - log_group_end |
| 65 | + pmd_ci_log_group_end |
| 66 | +} |
66 | 67 |
|
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})" |
70 | 71 |
|
71 | 72 | # 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}")" |
73 | 74 | GH_RELEASE="$RESULT" |
74 | 75 |
|
75 | 76 | # 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 |
77 | 80 |
|
78 | 81 | # 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" |
80 | 83 |
|
81 | 84 | # 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))" |
83 | 86 | BEGIN_LINE=$(grep -n "^## " ReleaseNotes.md|head -1|cut -d ":" -f 1) |
84 | 87 | END_LINE=$(grep -n "^## " ReleaseNotes.md|head -2|tail -1|cut -d ":" -f 1) |
85 | 88 | END_LINE=$((END_LINE - 1)) |
86 | 89 |
|
87 | 90 | RELEASE_BODY="A new PMD for Eclipse plugin version has been released. |
88 | 91 | It is available via the update site: https://dl.bintray.com/pmd/pmd-eclipse-plugin/updates/ |
89 | 92 |
|
90 | | -$(cat ReleaseNotes.md|head -$END_LINE|tail -$((END_LINE - BEGIN_LINE))) |
| 93 | +$(head -$END_LINE ReleaseNotes.md | tail -$((END_LINE - BEGIN_LINE))) |
91 | 94 | " |
92 | 95 |
|
93 | | - gh_release_updateRelease "$GH_RELEASE" "$RELEASE_NAME" "$RELEASE_BODY" |
| 96 | + pmd_ci_gh_releases_updateRelease "$GH_RELEASE" "$RELEASE_NAME" "$RELEASE_BODY" |
94 | 97 |
|
95 | 98 | # 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" |
105 | 100 |
|
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 |
121 | 102 | } |
122 | 103 |
|
123 | 104 | build |
0 commit comments