mirror of
https://github.com/zontreck/AutoMoneyPlugin
synced 2025-06-19 02:13:55 +00:00
112 lines
3.2 KiB
YAML
112 lines
3.2 KiB
YAML
name: Test and Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
schedule:
|
|
# PaperMC doesn't change version numbers for latest releases meaning the build may break
|
|
# unexpectedly. Build every so often so that we know if a breaking change has been published
|
|
- cron: '0 0 * * 6'
|
|
|
|
concurrency:
|
|
group: ${{ format('{0}-{1}', github.workflow, github.ref) }}
|
|
cancel-in-progress: false
|
|
|
|
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/
|
|
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- test
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Common Setup
|
|
uses: ./.github/actions/common-setup
|
|
with:
|
|
java-version: 21
|
|
|
|
- name: Publish with Gradle
|
|
run: ./gradlew -Pver="0.0.0-RC-1" release
|
|
|
|
- name: Upload build results
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: Release Build
|
|
path: ${{ github.workspace }}/build/libs/
|
|
|
|
notify:
|
|
name: Send job complete notification
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- test
|
|
- release
|
|
if: always() && vars.DISCORD_WEBHOOK_ID
|
|
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.2.0
|
|
with:
|
|
webhook_id: ${{ vars.DISCORD_WEBHOOK_ID }}
|
|
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
|
|
color: "#00FF00"
|
|
username: "${{ env.PROJECT_NAME }} Release Bot"
|
|
message: >
|
|
An ${{ env.PROJECT_NAME }} snapshot was deployed by ${{ github.actor }}:
|
|
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
|
|
- name: Notify on failure
|
|
if: failure()
|
|
uses: appleboy/discord-action@v1.2.0
|
|
with:
|
|
webhook_id: ${{ vars.DISCORD_WEBHOOK_ID }}
|
|
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
|
|
color: "#FF0000"
|
|
username: "${{ env.PROJECT_NAME }} Release Bot"
|
|
message: >
|
|
An ${{ env.PROJECT_NAME }} snapshot deployment ran by ${{ github.actor }} failed:
|
|
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
|