Skip to content

Commit 8d96e4e

Browse files
committed
[ci] Use Github Actions
1 parent af8862a commit 8d96e4e

File tree

17 files changed

+158
-203
lines changed

17 files changed

+158
-203
lines changed

.ci/build.sh

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/usr/bin/env bash
2+
3+
source $(dirname $0)/inc/github-releases-api.bash || exit 1
4+
5+
# Exit this script immediately if a command/function exits with a non-zero status.
6+
set -e
7+
8+
function build() {
9+
fetch_ci_scripts
10+
11+
log_group_start "Install OpenJDK"
12+
pmd_ci_openjdk_install_adoptopenjdk 8
13+
pmd_ci_openjdk_setdefault 8
14+
log_group_end
15+
16+
log_group_start "Install xvfb"
17+
#see https://github.com/GabrielBB/xvfb-action
18+
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
27+
28+
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
35+
echo
36+
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
41+
exit 0
42+
fi
43+
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
49+
pmd_ci_maven_setup_settings
50+
log_group_end
51+
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})"
55+
56+
# Uploading the update site to Bintray
57+
xvfb-run --auto-servernum ./mvnw verify -DskipTests -Psnapshot-properties -Prelease-composite
58+
59+
# Cleanup old snapshots
60+
(
61+
cd net.sourceforge.pmd.eclipse.p2updatesite
62+
./cleanup-bintray-snapshots.sh
63+
)
64+
log_group_end
65+
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})"
69+
70+
# create a draft github release
71+
gh_releases_createDraftRelease "${PMD_CI_TAG}" "$(git rev-list -n 1 ${PMD_CI_TAG})"
72+
GH_RELEASE="$RESULT"
73+
74+
# Deploy the update site to bintray
75+
xvfb-run --auto-servernum ./mvnw clean verify -Prelease-composite
76+
77+
# Deploy to github releases
78+
gh_release_uploadAsset "$GH_RELEASE" "net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-${version}.zip"
79+
80+
# extract the release notes
81+
RELEASE_NAME="PMD For Eclipse ${version} ($(date -u +%d-%B-%Y))"
82+
BEGIN_LINE=$(grep -n "^## " ReleaseNotes.md|head -1|cut -d ":" -f 1)
83+
END_LINE=$(grep -n "^## " ReleaseNotes.md|head -2|tail -1|cut -d ":" -f 1)
84+
END_LINE=$((END_LINE - 1))
85+
86+
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/
88+
89+
$(cat ReleaseNotes.md|head -$END_LINE|tail -$((END_LINE - BEGIN_LINE)))
90+
"
91+
92+
gh_release_updateRelease "$GH_RELEASE" "$RELEASE_NAME" "$RELEASE_BODY"
93+
94+
# Publish release
95+
gh_release_publishRelease "$GH_RELEASE"
96+
97+
log_group_end
98+
99+
else
100+
log_error "Invalid combination: version=${version} branch=${PMD_CI_BRANCH} tag=${PMD_CI_TAG}"
101+
exit 1
102+
fi
103+
}
104+
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
119+
done
120+
}
121+
122+
build

.ci/files/id_rsa.gpg

2.5 KB
Binary file not shown.

.ci/files/id_rsa.pub

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC8yHVLHYDsKui8tYg/sFvkDqcs97pEZz0BzK9HtBF4O+/It1drRYRdUAFfjoImfprpKSxkJCTglHixGRp24eNaZ6woWVJ4/bmiMkEqEZAjr1NZ3qw7zIruMJMSkCV+YTtmL4cYcZlvMRPzzOZOnFbV05oi79oy41MUFHYjolK9QxMFNsVNN5iyzFxM3HqSFozz+ylKbFBtDk6ZHZQNRL/Xl2V9DJ69fVzjG4OZfcWNGmmKHHARmsnJyUOMeeKpLjDOe1M6ZdI8HkXWac8yCr9JTETNZZwemZAcS/RKoKCDqfIUOzkZfIPmyaznfVetTGsMi7yQrJhAyjznuNGF4+3lfgTcmRF8wz5FCeUkdYTmy2wNSFi5HiLPfC5OgRtjKzC6yb8rbRjDx6XQ2ph15PKOaXwzk49TaMc0xJvoiGDMZaTU0iTm3Y1/QUtfLvo3/jGMbtUdV3soWpuBAV2JUI4aB5xdLX9iNmcrVzoUe3y9DWuuTX46eoCvpUNXv/DXKhQw1D7xd7J67db5qUck/Akiqi0JR+e0SoBJvZFtYwVNLGC2bIJ/s8SR8X5Zp+1+ypf3WYjIylxQTkO1r4NfI0Cd9qXg7nmUrHAU7Z6xtJmUK8ZWzSST4wul8WkRJURtODLxt5firtlKhyZ93t9Mjuk6mATIPxr/b3x20T+IH463kw== ssh key for pmd. used for travis accessing sourceforge and github.

.ci/files/private-env.gpg

356 Bytes
Binary file not shown.

.github/workflows/build.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
tags:
9+
- '**'
10+
pull_request:
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
continue-on-error: false
16+
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
17+
steps:
18+
- uses: actions/checkout@v2
19+
- uses: actions/cache@v2
20+
with:
21+
path: |
22+
~/.m2/repository
23+
~/.cache
24+
key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
25+
restore-keys: |
26+
${{ runner.os }}-
27+
- name: Build
28+
run: .ci/build.sh
29+
shell: bash
30+
env:
31+
MAVEN_OPTS: -Dmaven.wagon.httpconnectionManager.ttlSeconds=180 -Dmaven.wagon.http.retryHandler.count=3
32+
PMD_CI_SECRET_PASSPHRASE: ${{ secrets.PMD_CI_SECRET_PASSPHRASE }}

.travis.yml

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

.travis/build.sh

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

.travis/configure-maven.sh

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

0 commit comments

Comments
 (0)