update GitHub Actions workflow for improved build process and add gra… #2
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 and Release | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up Java 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| cache: 'gradle' | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Build with Gradle and create ShadowJar | |
| run: ./gradlew :plugin-runner:shadowJar --no-daemon | |
| - name: Verify build artifact | |
| run: | | |
| if [ -f plugin-runner/build/libs/nukkit-addon-bridge.jar ]; then | |
| echo "✓ Build artifact generated successfully" | |
| ls -lh plugin-runner/build/libs/nukkit-addon-bridge.jar | |
| else | |
| echo "✗ Build artifact not found" | |
| exit 1 | |
| fi | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nukkit-addon-bridge | |
| path: plugin-runner/build/libs/nukkit-addon-bridge.jar | |
| if-no-files-found: error | |
| - name: Upload to Release (on tag push only) | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: plugin-runner/build/libs/nukkit-addon-bridge.jar | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |