refactor: GitHub Actions build workflow #3
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 | |
| on: | |
| push: | |
| branches: [main, master, develop] # ignore noise from short-lived feature branches | |
| pull_request: | |
| workflow_dispatch: | |
| # Cancel any in-progress run on the same branch/PR when a new one is triggered. | |
| # This prevents redundant builds piling up while you're actively pushing. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true # opt into Node.js 24 ahead of June 2026 forced migration | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '21' | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Build | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew --no-daemon shadowJar | |
| - name: Collect JARs | |
| run: | | |
| mkdir -p jars | |
| find . -path "*/build/libs/*.jar" -type f \ | |
| ! -name "*-sources.jar" \ | |
| ! -name "*-javadoc.jar" \ | |
| ! -name "*-tests.jar" \ | |
| ! -name "*-plain.jar" \ | |
| -exec cp {} jars/ \; | |
| - name: Upload JARs | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: jars-${{ github.sha }} # include commit SHA so each run's artifact is uniquely identifiable | |
| path: jars/*.jar | |
| if-no-files-found: error | |
| retention-days: 14 |