|
| 1 | +name: "Build Java Binaries" |
| 2 | +description: "Build and test Java binaries using standard Makefile targets" |
| 3 | + |
| 4 | +inputs: |
| 5 | + javaVersion: |
| 6 | + description: "Java version" |
| 7 | + required: false |
| 8 | + default: "17" |
| 9 | + mainBuild: |
| 10 | + description: "Whether this is the main build (true) or a test build (false)" |
| 11 | + required: false |
| 12 | + default: "true" |
| 13 | + artifactName: |
| 14 | + description: "Name for the uploaded artifact" |
| 15 | + required: false |
| 16 | + default: "binaries.tar" |
| 17 | + runnerArch: |
| 18 | + description: "Runner architecture (amd64, arm64)" |
| 19 | + required: false |
| 20 | + default: "amd64" |
| 21 | + |
| 22 | +runs: |
| 23 | + using: "composite" |
| 24 | + steps: |
| 25 | + - name: Debug action_path |
| 26 | + shell: bash |
| 27 | + run: | |
| 28 | + echo "github.action_path = ${{ github.action_path }}" |
| 29 | + ls -la ${{ github.action_path }} |
| 30 | + ls -la .github/actions/build/ || echo "Path doesn't exist" |
| 31 | + ls -la github-actions/.github/actions/build/ || echo "Path doesn't exist" |
| 32 | + ls -la ${{ github.action_path }}/../../dependencies/ || echo "Path doesn't exist" |
| 33 | +
|
| 34 | + - name: Setup Java and Maven |
| 35 | + uses: ${{ github.action_path }}/../../dependencies/setup-java |
| 36 | + with: |
| 37 | + javaVersion: ${{ inputs.javaVersion }} |
| 38 | + |
| 39 | + - name: Restore Maven cache |
| 40 | + uses: actions/cache/restore@v5 |
| 41 | + with: |
| 42 | + path: ~/.m2/repository |
| 43 | + key: maven-${{ hashFiles('**/pom.xml') }} |
| 44 | + restore-keys: | |
| 45 | + maven- |
| 46 | +
|
| 47 | + - name: Install yq |
| 48 | + uses: ${{ github.action_path }}/../../dependencies/install-yq |
| 49 | + with: |
| 50 | + architecture: ${{ inputs.runnerArch }} |
| 51 | + |
| 52 | + - name: Install Shellcheck |
| 53 | + uses: ${{ github.action_path }}/../../dependencies/install-shellcheck |
| 54 | + with: |
| 55 | + architecture: ${{ inputs.runnerArch }} |
| 56 | + |
| 57 | + - name: Install Helm |
| 58 | + uses: ${{ github.action_path }}/../../dependencies/install-helm |
| 59 | + |
| 60 | + - name: Build binaries |
| 61 | + shell: bash |
| 62 | + run: make java_install |
| 63 | + env: |
| 64 | + MVN_ARGS: '-B -DskipTests' |
| 65 | + |
| 66 | + - name: Run SpotBugs |
| 67 | + shell: bash |
| 68 | + run: make spotbugs |
| 69 | + |
| 70 | + - name: Run tests and verification |
| 71 | + shell: bash |
| 72 | + run: make java_verify |
| 73 | + |
| 74 | + - name: Save Maven cache |
| 75 | + if: ${{ inputs.mainBuild == 'true' }} |
| 76 | + uses: actions/cache/save@v5 |
| 77 | + with: |
| 78 | + path: ~/.m2/repository |
| 79 | + key: maven-${{ hashFiles('**/pom.xml') }} |
| 80 | + |
| 81 | + - name: Create artifact tarball |
| 82 | + if: ${{ inputs.mainBuild == 'true' }} |
| 83 | + shell: bash |
| 84 | + run: | |
| 85 | + # Archive build artifacts preserving directory structure for multi-module projects |
| 86 | + # Includes: |
| 87 | + # - All target/ directories (contains JARs, POMs, and other build outputs) |
| 88 | + # Excludes: |
| 89 | + # - Test outputs that aren't needed for deployment |
| 90 | +
|
| 91 | + tar -cvpf ${{ inputs.artifactName }} \ |
| 92 | + --exclude='**/surefire-reports' \ |
| 93 | + --exclude='**/test-classes' \ |
| 94 | + $(find . -type d -name "target") |
| 95 | +
|
| 96 | + - name: Upload artifact |
| 97 | + if: ${{ inputs.mainBuild == 'true' }} |
| 98 | + uses: actions/upload-artifact@v5 |
| 99 | + with: |
| 100 | + name: ${{ inputs.artifactName }}.tar |
| 101 | + path: ${{ inputs.artifactName }} |
| 102 | + retention-days: 7 |
| 103 | + |
| 104 | + - name: Upload artifact with Java suffix |
| 105 | + uses: actions/upload-artifact@v5 |
| 106 | + with: |
| 107 | + name: ${{ inputs.artifactName }}-java-${{ inputs.javaVersion }}.tar |
| 108 | + path: ${{ inputs.artifactName }} |
| 109 | + retention-days: 7 |
0 commit comments