-
Notifications
You must be signed in to change notification settings - Fork 165
[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
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
efab1f8
[build] Master/PR/Release workflows
jimschubert 2cd5ac0
Update GitHub workflow badge in README.md
joschi 565f3b4
Skip Maven `clean` phase
joschi 89c61df
Only run release workflow on `master` branch
joschi c40bc2a
Merge branch 'master' into ci-release-management
joschi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
|
@@ -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] | ||
|
@@ -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 | ||
- name: Release Snapshot | ||
if: matrix.java_version == '11' | ||
run: ./mvnw -V -B -ntp -ff deploy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
jimschubert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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." |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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.