Update build.yml #5
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
| name: Build | |
| env: | |
| PLUGIN_NAME: NoBullying | |
| PLUGIN_FILE: nobullying | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| release: | |
| types: [created] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Build with Maven | |
| run: mvn -B package --file pom.xml | |
| - name: Debug directory contents | |
| run: ls -la target/ | |
| - name: Copy JAR to root | |
| run: | | |
| mkdir artifacts | |
| cp target/${{ env.PLUGIN_FILE }}-*.jar ./artifacts/${{ env.PLUGIN_FILE }}.jar || exit 1 | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.PLUGIN_FILE }} | |
| path: artifacts/${{ env.PLUGIN_FILE }}.jar | |
| compression-level: 0 | |
| retention-days: 5 | |
| if-no-files-found: error | |
| - name: Send Discord Notification | |
| if: success() | |
| uses: sarisia/actions-status-discord@v1 | |
| with: | |
| webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
| title: "New Build Available!" | |
| description: "A new build of ${{ env.PLUGIN_NAME }} has been created\nCommit: ${{ github.sha }}" | |
| color: 0x00ff00 | |
| username: "🏺Artifact Build's" | |
| avatar_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" | |
| release: | |
| needs: build | |
| if: github.event_name == 'release' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ env.PLUGIN_FILE }} | |
| path: ./ | |
| - name: Prepare Release Asset | |
| run: | | |
| ls -la | |
| mv ${{ env.PLUGIN_FILE }}.jar NoBullying-${{ github.ref_name }}.jar | |
| - name: Upload release artifacts | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: NoBullying-${{ github.ref_name }}.jar | |
| fail_on_unmatched_files: true | |
| - name: Send Release Discord Notification | |
| if: success() | |
| uses: sarisia/actions-status-discord@v1 | |
| with: | |
| webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
| title: "🎉 New Release Published!" | |
| description: "A new release of ${{ env.PLUGIN_NAME }} is available\nDownload: https://github.com/${{ github.repository }}/releases/latest" | |
| color: 0x00ff00 | |
| username: "🏺Artifact Build's" | |
| avatar_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" |