Skip to content

Introduce github actions pull request workflow #493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Pull request
on:
pull_request:
types: [ opened, reopened, synchronize ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '8', '11', '15' ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup java
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: 'adopt'
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release
on: [ workflow_dispatch ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup java
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify

publish:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Bintray
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
server-id: bintray
server-username: BINTRAY_USER
server-password: BINTRAY_PASSWORD
- name: Publish release
run: bash github-build.sh
env:
MAVEN_USERNAME: ${{ secrets.OSS_USER_TOKEN_KEY }}
MAVEN_PASSWORD: ${{ secrets.OSS_USER_TOKEN_PASS }}
38 changes: 38 additions & 0 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release Snapshot
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup java
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify

publish:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Bintray
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
server-id: bintray
server-username: BINTRAY_USER
server-password: BINTRAY_PASSWORD
- name: Publish release
run: mvn --batch-mode -Pbintray deploy
env:
MAVEN_USERNAME: ${{ secrets.OSS_USER_TOKEN_KEY }}
MAVEN_PASSWORD: ${{ secrets.OSS_USER_TOKEN_PASS }}
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

54 changes: 54 additions & 0 deletions github-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
set -ev

getVersion() {
grep -m1 -o '[^<>]*-SNAPSHOT' pom.xml
}

removeSnapshots() {
sed -i 's/-SNAPSHOT//' pom.xml
}

commitRelease() {
local APP_VERSION=$(getVersion)
git commit -a -m "Update version for release"
git tag -a "v${APP_VERSION}" -m "Tag release version"
}

bumpVersion() {
echo "Bump version number"
local APP_VERSION=$(getVersion | xargs)
local SEMANTIC_REGEX='^([0-9]+)\.([0-9]+)(\.([0-9]+))?$'
if [[ ${APP_VERSION} =~ ${SEMANTIC_REGEX} ]]; then
if [[ ${BASH_REMATCH[4]} ]]; then
nextVersion=$((BASH_REMATCH[4] + 1))
nextVersion="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${nextVersion}-SNAPSHOT"
else
nextVersion=$((BASH_REMATCH[2] + 1))
nextVersion="${BASH_REMATCH[1]}.${nextVersion}-SNAPSHOT"
fi

echo "Next version: ${nextVersion}"
sed -i "'0,/<version>.*<\/version>/s//<version>${nextVersion}<\/version>/'" pom.xml

else
echo "No semantic version and therefore cannot publish to maven repository: '${APP_VERSION}'"
fi
}

commitNextVersion() {
git commit -a -m "Update version for release"
}

git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"

echo "Deploying release to Bintray"
removeSnapshots

mvn release:clean release:prepare release:perform -B -e -Pbintray

commitRelease
bumpVersion
commitNextVersion
git push --follow-tags
40 changes: 0 additions & 40 deletions travis-build.sh

This file was deleted.