Skip to content

[build] Master/PR/Release workflows #181

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 5 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 11 additions & 9 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Test
name: Main Build
on:
push:
branches:
- master
pull_request:
branches:
- master
- master
paths-ignore:
- 'docs/**'
- '.circleci/**'
- '.github/**'
jobs:
build:
runs-on: 'ubuntu-latest'
Expand All @@ -18,7 +19,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: joschi/setup-[email protected]
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java_version }}
- uses: actions/[email protected]
Expand All @@ -27,7 +28,8 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: ./mvnw -V -B -ntp -ff install '-DskipTests=true' '-Dmaven.javadoc.skip=true'
- name: Run tests
run: ./mvnw -V -B -ntp -ff verify
run: ./mvnw -V -B -ntp -ff clean verify
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're running from scratch every time the workflow is being executed, the clean phase can be skipped.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar enough with the project to comment on this. However, it's usually best practice to ensure outputs are cleaned through the build tool before running a build in case there are any stale build outputs inadvertently committed to source.

- name: Release Snapshot
if: matrix.java_version == '11'
run: ./mvnw -V -B -ntp -ff deploy
35 changes: 35 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Pull Request Checks
on:
- pull_request

jobs:
cleanup:
name: Cleanup any previous jobs
runs-on: ubuntu-latest
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"
steps:
- uses: rokroskar/[email protected]
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java_version: ['8', '11', '15']
env:
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java_version }}
- uses: actions/[email protected]
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Run tests
run: ./mvnw -V -B -ntp -ff clean verify
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're running from scratch every time the workflow is being executed, the clean phase can be skipped.

43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Triggered Release
on: [workflow_dispatch]

env:
OSS_USERNAME: ${{ secrets.OSS_USERNAME }}
OSS_PASSWORD: ${{ secrets.OSS_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

jobs:
release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
# Value of the distributionManagement/repository/id field of the pom.xml
server-id: sonatype-nexus-staging
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
server-username: OSS_USERNAME
server-password: OSS_PASSWORD
gpg-passphrase: GPG_PASSPHRASE
- uses: actions/[email protected]
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Setup Git
run: |
git config --global committer.email "[email protected]"
git config --global committer.name "GitHub Release"
git config --global author.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global author.name "${GITHUB_ACTOR}"
- name: Release
run: ./mvnw -B clean release:prepare release:perform -Prelease -Dgpg.passphrase=${{secrets.GPG_PASSPHRASE}} -Drepository.url=https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git
- name: 'if failure -> rollback'
if: ${{ failure() }}
run: |
./mvnw -B release:rollback -Prelease -Dgpg.passphrase=${{secrets.GPG_PASSPHRASE}}
echo "You may need to manually delete the GitHub tag, if it was created."