-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,69 @@ | ||
name: 'Build & Test' | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
workflow_dispatch: | ||
inputs: | ||
commit: | ||
description: If the commit you want to test isn't the head of a branch, provide its SHA here | ||
required: false | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '8' | ||
distribution: 'temurin' | ||
- name: Build | ||
run: ./gradlew shadowJar | ||
test: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '8' | ||
distribution: 'temurin' | ||
- name: Test | ||
run: ./gradlew test | ||
- name: Create badges dir if necessary | ||
run: mkdir -p .github/badges | ||
- name: Generate JaCoCo Badge | ||
uses: cicirello/jacoco-badge-generator@v2 | ||
with: | ||
jacoco-csv-file: build/reports/jacoco/test/jacocoTestReport.csv | ||
coverage-badge-filename: jacoco.svg | ||
- name: Log coverage percentage | ||
run: | | ||
echo "coverage = ${{ steps.jacoco.outputs.coverage }}" | ||
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}" | ||
- name: Extract branch name | ||
shell: bash | ||
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | ||
id: extract_branch | ||
- name: Check if there are any changes | ||
id: verify_diff | ||
run: | | ||
git diff --quiet .github/badges/jacoco.svg || echo "changed=true" >> $GITHUB_OUTPUT | ||
- name: Commit badge | ||
if: steps.verify_diff.outputs.changed == 'true' | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add .github/badges/jacoco.svg | ||
git commit -m "Add/Update Jacoco badge" | ||
- name: Push badge commit | ||
if: steps.verify_diff.outputs.changed == 'true' | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: ${{ steps.extract_branch.outputs.branch }} |
This file contains 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,42 @@ | ||
name: 'Publish to GitHub Releases' | ||
|
||
on: | ||
push: | ||
tags: | ||
- '**' | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '8' | ||
distribution: 'temurin' | ||
- name: Test | ||
run: ./gradlew test | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: test | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '8' | ||
distribution: 'temurin' | ||
- name: Build | ||
run: ./gradlew shadowJar | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
build/libs/java-discord-oauth2-api-*.jar | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains 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,39 @@ | ||
name: 'Publish to MavenCentral' | ||
|
||
on: | ||
push: | ||
tags: | ||
- '**' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '8' | ||
distribution: 'temurin' | ||
- name: Test | ||
run: ./gradlew test | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: test | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '8' | ||
distribution: 'temurin' | ||
- name: Publish, Close, and Release to MavenCentral | ||
env: | ||
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRHUSERNAME }} | ||
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRHPASSWORD }} | ||
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.PGP_SECRET }} | ||
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} | ||
run: ./gradlew publishCloseAndRelease |