-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ci): Refactor CI and fix notifications (#186)
- Loading branch information
Showing
4 changed files
with
170 additions
and
99 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
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,46 @@ | ||
name: Test | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- 'main' | ||
merge_group: | ||
types: | ||
- checks_requested | ||
|
||
concurrency: | ||
group: ${{ format('{0}-{1}', github.workflow, github.ref) }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test: | ||
name: Run unit tests | ||
strategy: | ||
matrix: | ||
os: [ ubuntu-latest, windows-latest ] | ||
java: [ 21 ] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Common Setup | ||
uses: ./.github/actions/common-setup | ||
with: | ||
java-version: ${{ matrix.java }} | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build --info | ||
|
||
- name: Upload build results | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.os }} Java ${{ matrix.java }} build results | ||
path: ${{ github.workspace }}/build/libs/ | ||
|
||
- name: Upload test results | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.os }} Java ${{ matrix.java }} test results | ||
path: ${{ github.workspace }}/build/reports/ |
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
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,85 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' # For v1.0, v0.1.0, etc | ||
|
||
concurrency: | ||
group: ${{ format('{0}-{1}', github.workflow, github.ref) }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Common Setup | ||
uses: ./.github/actions/common-setup | ||
|
||
- name: Publish with Gradle | ||
run: ./gradlew -Pver=${{ github.ref_name }} release | ||
|
||
- name: Upload build results | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: Release Build | ||
path: ${{ github.workspace }}/build/libs/ | ||
|
||
- name: Create Release | ||
uses: softprops/action-gh-release@v2 | ||
id: release | ||
with: | ||
files: ${{ github.workspace }}/build/libs/* | ||
generate_release_notes: true | ||
name: ${{ format('Release {0}', github.ref_name) }} | ||
prerelease: ${{ contains(github.ref_name, '-rc-') }} | ||
fail_on_unmatched_files: true | ||
draft: true | ||
outputs: | ||
url: ${{ steps.release.outputs.url }} | ||
|
||
notify: | ||
name: Send job complete notification | ||
runs-on: ubuntu-latest | ||
needs: | ||
- release | ||
# Run if on main or tag | ||
if: always() | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Common Setup | ||
uses: ./.github/actions/common-setup | ||
with: | ||
java-version: 21 | ||
|
||
- name: Retrieve Project Name | ||
run: echo "PROJECT_NAME=$(${{github.workspace}}/gradlew -q printProjectName)" >> $GITHUB_ENV | ||
|
||
- name: Notify on success | ||
if: success() | ||
uses: appleboy/discord-action@v1.0.0 | ||
with: | ||
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }} | ||
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }} | ||
color: "#00FF00" | ||
username: "${{ env.PROJECT_NAME }} Release Bot" | ||
message: > | ||
An ${{ env.PROJECT_NAME }} release draft was deployed by ${{ github.actor }}: | ||
${{ needs.release.outputs.url }} | ||
- name: Notify on failure | ||
if: failure() | ||
uses: appleboy/discord-action@v1.0.0 | ||
with: | ||
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }} | ||
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }} | ||
color: "#FF0000" | ||
username: "${{ env.PROJECT_NAME }} Release Bot" | ||
message: > | ||
An ${{ env.PROJECT_NAME }} release draft ran by ${{ github.actor }} failed: | ||
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |