|
| 1 | +--- |
| 2 | +name: Flex Build |
| 3 | + |
| 4 | +"on": |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + mc: |
| 8 | + description: Minecraft version |
| 9 | + type: string |
| 10 | + lex: |
| 11 | + description: LexForge version |
| 12 | + type: string |
| 13 | + neo: |
| 14 | + description: NeoForge version |
| 15 | + type: string |
| 16 | + java: |
| 17 | + description: Java version |
| 18 | + required: true |
| 19 | + type: string |
| 20 | + upload: |
| 21 | + description: Upload the build artifacts |
| 22 | + default: true |
| 23 | + type: boolean |
| 24 | + publish: |
| 25 | + description: Run Gradle publish |
| 26 | + default: false |
| 27 | + type: boolean |
| 28 | + |
| 29 | +jobs: |
| 30 | + build: # TODO: add build attestation and generate then combine gradle dependency graphs for SBOM |
| 31 | + name: Build ${{ inputs.mc }} |
| 32 | + runs-on: blacksmith-2vcpu-ubuntu-2204 |
| 33 | + steps: |
| 34 | + - name: Checkout |
| 35 | + uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + fetch-depth: 1 |
| 38 | + |
| 39 | + - name: Cache build |
| 40 | + id: cache |
| 41 | + uses: useblacksmith/cache@v5 |
| 42 | + with: |
| 43 | + path: build |
| 44 | + key: build-${{ hashFiles(format('{0}/[a-z]**', inputs.mc), 'api/**') }} |
| 45 | + |
| 46 | + - if: steps.cache.outputs.cache-hit != 'true' |
| 47 | + name: Setup Java |
| 48 | + uses: useblacksmith/setup-java@v5 |
| 49 | + with: |
| 50 | + distribution: temurin |
| 51 | + java-version: ${{ inputs.java }} |
| 52 | + |
| 53 | + - if: steps.cache.outputs.cache-hit != 'true' |
| 54 | + name: Setup Gradle |
| 55 | + uses: useblacksmith/setup-gradle/setup-gradle@v5 |
| 56 | + with: |
| 57 | + workflow-job-context: '{}' # FIXME: avoid this cache duplication workaround |
| 58 | + |
| 59 | + - if: | |
| 60 | + steps.cache.outputs.cache-hit != 'true' |
| 61 | + && !inputs.release |
| 62 | + name: Gradle build |
| 63 | + run: > |
| 64 | + ./gradlew build --stacktrace |
| 65 | + -Pminecraft_version=${{ inputs.mc }} |
| 66 | + -Plexforge_version=${{ inputs.lex }} |
| 67 | + -Pneoforge_version=${{ inputs.neo }} |
| 68 | +
|
| 69 | + - if: inputs.release |
| 70 | + name: Gradle publish |
| 71 | + env: |
| 72 | + IS_MAVEN_PUB: true |
| 73 | + DEPLOY_TO_GITHUB_PACKAGES_URL: https://maven.pkg.github.com/${{ github.repository }} |
| 74 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + run: ./gradlew publish |
| 76 | + |
| 77 | + - if: inputs.upload |
| 78 | + name: Upload artifacts |
| 79 | + uses: actions/upload-artifact@v4 |
| 80 | + with: |
| 81 | + name: jars-${{ inputs.mc }} |
| 82 | + path: build/libs/*.jar |
0 commit comments