Skip to content

Commit d6f68d5

Browse files
authored
Merge pull request #493 from graphql-java-kickstart/github-actions
Introduce github actions pull request workflow
2 parents b6cfd64 + 7158dd7 commit d6f68d5

File tree

6 files changed

+153
-47
lines changed

6 files changed

+153
-47
lines changed

.github/workflows/pull-request.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Pull request
2+
on:
3+
pull_request:
4+
types: [ opened, reopened, synchronize ]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
java: [ '8', '11', '15' ]
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
- name: Setup java
15+
uses: actions/setup-java@v2
16+
with:
17+
java-version: ${{ matrix.java }}
18+
distribution: 'adopt'
19+
- name: Cache Maven packages
20+
uses: actions/cache@v2
21+
with:
22+
path: ~/.m2
23+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
24+
restore-keys: ${{ runner.os }}-m2
25+
- name: Build with Maven
26+
run: mvn --batch-mode --update-snapshots verify

.github/workflows/release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Release
2+
on: [ workflow_dispatch ]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: Checkout
8+
uses: actions/checkout@v2
9+
- name: Setup java
10+
uses: actions/setup-java@v2
11+
with:
12+
java-version: '8'
13+
distribution: 'adopt'
14+
- name: Build with Maven
15+
run: mvn --batch-mode --update-snapshots verify
16+
17+
publish:
18+
runs-on: ubuntu-latest
19+
needs: build
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v2
23+
- name: Setup Bintray
24+
uses: actions/setup-java@v2
25+
with:
26+
java-version: '8'
27+
distribution: 'adopt'
28+
server-id: bintray
29+
server-username: BINTRAY_USER
30+
server-password: BINTRAY_PASSWORD
31+
- name: Publish release
32+
run: bash github-build.sh
33+
env:
34+
MAVEN_USERNAME: ${{ secrets.OSS_USER_TOKEN_KEY }}
35+
MAVEN_PASSWORD: ${{ secrets.OSS_USER_TOKEN_PASS }}

.github/workflows/snapshot.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Release Snapshot
2+
on:
3+
push:
4+
branches:
5+
- master
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
- name: Setup java
13+
uses: actions/setup-java@v2
14+
with:
15+
java-version: '8'
16+
distribution: 'adopt'
17+
- name: Build with Maven
18+
run: mvn --batch-mode --update-snapshots verify
19+
20+
publish:
21+
runs-on: ubuntu-latest
22+
needs: build
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v2
26+
- name: Setup Bintray
27+
uses: actions/setup-java@v2
28+
with:
29+
java-version: '8'
30+
distribution: 'adopt'
31+
server-id: bintray
32+
server-username: BINTRAY_USER
33+
server-password: BINTRAY_PASSWORD
34+
- name: Publish release
35+
run: mvn --batch-mode -Pbintray deploy
36+
env:
37+
MAVEN_USERNAME: ${{ secrets.OSS_USER_TOKEN_KEY }}
38+
MAVEN_PASSWORD: ${{ secrets.OSS_USER_TOKEN_PASS }}

.travis.yml

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

github-build.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
set -ev
3+
4+
getVersion() {
5+
grep -m1 -o '[^<>]*-SNAPSHOT' pom.xml
6+
}
7+
8+
removeSnapshots() {
9+
sed -i 's/-SNAPSHOT//' pom.xml
10+
}
11+
12+
commitRelease() {
13+
local APP_VERSION=$(getVersion)
14+
git commit -a -m "Update version for release"
15+
git tag -a "v${APP_VERSION}" -m "Tag release version"
16+
}
17+
18+
bumpVersion() {
19+
echo "Bump version number"
20+
local APP_VERSION=$(getVersion | xargs)
21+
local SEMANTIC_REGEX='^([0-9]+)\.([0-9]+)(\.([0-9]+))?$'
22+
if [[ ${APP_VERSION} =~ ${SEMANTIC_REGEX} ]]; then
23+
if [[ ${BASH_REMATCH[4]} ]]; then
24+
nextVersion=$((BASH_REMATCH[4] + 1))
25+
nextVersion="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${nextVersion}-SNAPSHOT"
26+
else
27+
nextVersion=$((BASH_REMATCH[2] + 1))
28+
nextVersion="${BASH_REMATCH[1]}.${nextVersion}-SNAPSHOT"
29+
fi
30+
31+
echo "Next version: ${nextVersion}"
32+
sed -i "'0,/<version>.*<\/version>/s//<version>${nextVersion}<\/version>/'" pom.xml
33+
34+
else
35+
echo "No semantic version and therefore cannot publish to maven repository: '${APP_VERSION}'"
36+
fi
37+
}
38+
39+
commitNextVersion() {
40+
git commit -a -m "Update version for release"
41+
}
42+
43+
git config --global user.email "actions@github.com"
44+
git config --global user.name "GitHub Actions"
45+
46+
echo "Deploying release to Bintray"
47+
removeSnapshots
48+
49+
mvn release:clean release:prepare release:perform -B -e -Pbintray
50+
51+
commitRelease
52+
bumpVersion
53+
commitNextVersion
54+
git push --follow-tags

travis-build.sh

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

0 commit comments

Comments
 (0)