# SPDX-FileCopyrightText: 2023 Linnea Gräf # # SPDX-License-Identifier: CC0-1.0 name: Build on: - push - pull_request permissions: pull-requests: write jobs: build: name: Build runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 name: Checkout repository with: fetch-tags: true fetch-depth: 0 filter: 'tree:0' - uses: ./.github/composite/gradle - name: Build with gradle run: | ./gradlew assemble --scan - name: Move build artifact around and print check sum run: | rm -f build/libs/*sources*.jar sha256sum build/libs/*.jar - name: Upload build artifact uses: actions/upload-artifact@v4 with: name: built-mod-jar path: build/libs/Firmament-*.jar test: name: Test needs: build runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 name: Checkout repository with: fetch-tags: true fetch-depth: 0 filter: 'tree:0' - uses: ./.github/composite/gradle - name: Build with gradle run: | ./gradlew test --scan upload: name: Upload runs-on: ubuntu-latest needs: build if: ${{ 'push' == github.event_name && ('master' == github.ref_name || startsWith(github.ref_name, 'mc-')) && '637563904' == github.repository_id }} steps: - name: Download generated artifact uses: actions/download-artifact@v5 with: name: built-mod-jar - name: Upload to discord run: | ls -lahR . curl "$WEBHOOK_URL" -X POST -H "Content-type: multipart/form-data" --form "files[0]=@$(echo *.jar)" env: WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} prepare-release: name: Prepare a release runs-on: ubuntu-22.04 needs: build permissions: contents: write if: ${{ 'push' == github.event_name && startsWith(github.ref, 'refs/tags/') }} steps: - uses: actions/checkout@v5 name: Checkout repository with: fetch-tags: true fetch-depth: 0 filter: 'tree:0' - name: Download generated artifact uses: actions/download-artifact@v5 with: name: built-mod-jar - name: Generate changelog run: ./docs/generate-changelog.sh > changelog.md - name: Upload release env: GH_TOKEN: ${{ github.token }} run: | gh release create --draft -t "Firmament ${GITHUB_REF#refs/tags/}" "${GITHUB_REF#refs/tags/}" -F "changelog.md" "*.jar" - name: Notify discord env: ACTOR: ${{ github.actor }} WEBHOOK: ${{ secrets.CONFIDENTIAL_WEBHOOK }} REPO: ${{ github.repository }} run: | curl -X POST "$WEBHOOK" --data "$(jq -n --arg r "$REPO" --arg v "${GITHUB_REF#refs/tags/}" --arg a "$WEBHOOK" '{"content": ("Created release preview, ready for publishing." + $v+"\n\nSee the draft at https://github.com/"+$r+"/releases/"), "username": $a, "avatar_url": ("https://github.com/" + $a + ".png")}')" -H 'content-type: application/json'