|
| 1 | +name: Build Lambda |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | + name: Build Lambda |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + permissions: |
| 17 | + contents: write |
| 18 | + |
| 19 | + env: |
| 20 | + SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5' |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout Repository |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Get short commit hash |
| 27 | + id: vars |
| 28 | + run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
| 29 | + |
| 30 | + - name: Set-Up JDK |
| 31 | + uses: actions/setup-java@v4 |
| 32 | + with: |
| 33 | + distribution: 'oracle' |
| 34 | + java-version: '21' |
| 35 | + architecture: x64 |
| 36 | + cache: 'gradle' |
| 37 | + |
| 38 | + - name: Read Gradle Properties |
| 39 | + uses: BrycensRanch/read-properties-action@v1.0.4 |
| 40 | + id: all |
| 41 | + with: |
| 42 | + file: gradle.properties |
| 43 | + all: true |
| 44 | + |
| 45 | + - name: Publish snapshot to maven |
| 46 | + # if: github.event_name == 'push' |
| 47 | + id: upload-maven |
| 48 | + run: ./gradlew publish -PmavenType=snapshots -PmavenUsername=${{ secrets.MAVEN_USER }} -PmavenPassword=${{ secrets.MAVEN_TOKEN }} |
| 49 | + |
| 50 | + # - name: Generate Summary |
| 51 | + # if: steps.upload.conclusion == 'success' && github.event_name == 'push' |
| 52 | + # run: | |
| 53 | + # cat << EOF >> $GITHUB_STEP_SUMMARY |
| 54 | + # ### [Lambda ${{ steps.all.outputs.modVersion }} ${{ steps.all.outputs.minecraftVersion }} (${{ env.COMMIT_HASH }})](https://maven.lambda-client.org/snapshots/com/lambda/lambda/${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}-${{ env.COMMIT_HASH }}/lambda-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}-${{ env.COMMIT_HASH }}.jar) |
| 55 | + # EOF |
| 56 | + |
| 57 | + - name: Rename jar |
| 58 | + # if: steps.upload.conclusion == 'failure' || github.event_name == 'pull_request' |
| 59 | + run: mv build/libs/lambda-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}.jar build/libs/lambda-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}-${{ env.COMMIT_HASH }}.jar |
| 60 | + |
| 61 | + - name: Upload |
| 62 | + # if: steps.upload.conclusion == 'failure' || github.event_name == 'pull_request' |
| 63 | + uses: actions/upload-artifact@v4 |
| 64 | + id: upload-git |
| 65 | + with: |
| 66 | + name: lambda-nightly |
| 67 | + path: | |
| 68 | + build/libs/lambda-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}-${{ env.COMMIT_HASH }}.jar |
| 69 | +
|
| 70 | + - name: Send Discord build message |
| 71 | + if: steps.upload-maven.conclusion == 'success' || steps.upload-git.conclusion == 'success' |
| 72 | + run: | |
| 73 | + COMMIT_MESSAGE=$(git log --pretty=format:'- \`%h\` %s' -1 --reverse) |
| 74 | + LATEST_VERSION=$(curl -s "https://maven.lambda-client.org/snapshots/com/lambda/lambda/maven-metadata.xml" | grep -oP '(?<=<latest>).*?(?=</latest>)') |
| 75 | + LATEST_MAVEN_METADATA=$(curl -s "https://maven.lambda-client.org/snapshots/com/lambda/lambda/${LATEST_VERSION}/maven-metadata.xml") |
| 76 | + |
| 77 | + TIMESTAMP=$(echo "$LATEST_MAVEN_METADATA" | grep -oP '(?<=<timestamp>).*?(?=</timestamp>)') |
| 78 | + BUILD_NUMBER=$(echo "$LATEST_MAVEN_METADATA" | grep -oP '(?<=<buildNumber>).*?(?=</buildNumber>)') |
| 79 | + |
| 80 | + LATEST_SNAPSHOT="lambda-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}-${TIMESTAMP}-${BUILD_NUMBER}" |
| 81 | + |
| 82 | + 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.LATEST_SNAPSHOT }}.jar](https://maven.lambda-client.org/#/snapshots/com/lambda/lambda/${{ env.LATEST_VERSION }}/${{ env.LATEST_SNAPSHOT }}\"}],\"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\"}" |
| 83 | + |
0 commit comments