|
| 1 | +name: Dev Build |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - '*.*' |
| 6 | +jobs: |
| 7 | + build: |
| 8 | + concurrency: |
| 9 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 10 | + cancel-in-progress: true |
| 11 | + name: Build Lambda |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: write |
| 15 | + env: |
| 16 | + SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5' |
| 17 | + steps: |
| 18 | + - name: Checkout Repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Get short commit hash |
| 22 | + id: vars |
| 23 | + run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
| 24 | + |
| 25 | + - name: Set-Up JDK |
| 26 | + uses: actions/setup-java@v4 |
| 27 | + with: |
| 28 | + distribution: 'oracle' |
| 29 | + java-version: '21' |
| 30 | + architecture: x64 |
| 31 | + cache: 'gradle' |
| 32 | + |
| 33 | + - name: Read Gradle Properties |
| 34 | + uses: BrycensRanch/read-properties-action@v1.0.4 |
| 35 | + id: all |
| 36 | + with: |
| 37 | + file: gradle.properties |
| 38 | + all: true |
| 39 | + |
| 40 | + - name: Publish dev build to Maven |
| 41 | + id: upload-maven |
| 42 | + run: | |
| 43 | + ./gradlew publish \ |
| 44 | + -PmavenType=dev \ |
| 45 | + -PbuildNumber=${{ github.run_number }} \ |
| 46 | + -PmavenUsername=${{ secrets.MAVEN_USER }} \ |
| 47 | + -PmavenPassword=${{ secrets.MAVEN_TOKEN }} |
| 48 | +
|
| 49 | + - name: Rename JAR (fallback) |
| 50 | + run: | |
| 51 | + mv build/libs/lambda-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}.jar \ |
| 52 | + build/libs/lambda-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}-dev.${{ github.run_number }}.jar |
| 53 | +
|
| 54 | + - name: Upload JAR artifact |
| 55 | + uses: actions/upload-artifact@v4 |
| 56 | + id: upload-git |
| 57 | + with: |
| 58 | + name: dev-build |
| 59 | + path: | |
| 60 | + build/libs/lambda-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}-dev.${{ github.run_number }}.jar |
| 61 | +
|
| 62 | + - name: Get latest version info |
| 63 | + if: steps.upload-maven.conclusion == 'success' || steps.upload-git.conclusion == 'success' |
| 64 | + run: | |
| 65 | + COMMIT_MESSAGE=$(git log --pretty=format:'- \`%h\` %s' -1 --reverse) |
| 66 | + echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV |
| 67 | + echo "DEV_VERSION=${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}-dev.${{ github.run_number }}" >> $GITHUB_ENV |
| 68 | +
|
| 69 | + - name: Send Discord build message |
| 70 | + if: steps.upload-maven.conclusion == 'success' || steps.upload-git.conclusion == 'success' |
| 71 | + run: | |
| 72 | + curl "${{ secrets.WEBHOOK }}" -sS -H "Content-Type:application/json" -X POST -d "{\"content\":null,\"embeds\":[{\"title\":\"Build ${{ github.run_number }}\",\"description\":\"**Branch:** ${{ github.ref_name }}\\n**Changes:**\\n${{ env.COMMIT_MESSAGE }}\",\"url\":\"${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}\",\"color\":1487872,\"fields\":[{\"name\":\"Artifacts:\",\"value\":\"- [${{ env.DEV_VERSION }}.jar](https://maven.lambda-client.org/dev/com/lambda/lambda/${{ env.DEV_VERSION }}/lambda-${{ env.DEV_VERSION }}.jar)\"}],\"footer\":{\"text\":\"$GITHUB_REPOSITORY\"},\"thumbnail\":{\"url\":\"https://raw.githubusercontent.com/lambda-client/assets/refs/heads/main/lambda%20logo%20banner%20transparent.png\"}}],\"username\":\"Github Actions\",\"avatar_url\":\"https://raw.githubusercontent.com/lambda-client/assets/refs/heads/main/lambda.png\"}" |
0 commit comments