Release to Discord #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release to Discord | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| jobs: | |
| build-and-post: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: "21" | |
| cache: gradle | |
| - name: Grant execute permission for Gradle | |
| run: chmod +x ./gradlew | |
| - name: Download Baritone API dependency | |
| run: | | |
| set -euo pipefail | |
| mkdir -p libs | |
| curl --fail -L -o libs/baritone-api-fabric-1.15.0.jar \ | |
| https://github.com/cabaletta/baritone/releases/download/v1.15.0/baritone-api-fabric-1.15.0.jar | |
| ls -l libs/baritone-api-fabric-1.15.0.jar | |
| - name: Build | |
| env: | |
| BARITONE_API_JAR: libs/baritone-api-fabric-1.15.0.jar | |
| run: | | |
| if [ ! -f libs/baritone-api-fabric-1.15.0.jar ]; then | |
| echo "Baritone API jar missing; listing libs:" | |
| ls -l libs || true | |
| exit 1 | |
| fi | |
| ./gradlew build -PbaritoneApiPath=libs/baritone-api-fabric-1.15.0.jar | |
| - name: Post to Discord (message + all jar attachments) | |
| shell: bash | |
| run: | | |
| TAG="${{ github.event.release.tag_name }}" | |
| URL="${{ github.event.release.html_url }}" | |
| NAME="${{ github.event.repository.name }}" | |
| # Collect all "main" jars (ignore common extra jars) | |
| mapfile -t JARS < <(ls -1 build/libs/*.jar 2>/dev/null \ | |
| | grep -Ev '(-sources|-javadoc|-dev|-shadow|-all)\.jar$' || true) | |
| if [ "${#JARS[@]}" -eq 0 ]; then | |
| echo "No suitable jars found in build/libs/" | |
| ls -la build/libs || true | |
| exit 1 | |
| fi | |
| # Build curl args for multiple attachments: file1, file2, file3... | |
| CURL_FILES=() | |
| i=1 | |
| for jar in "${JARS[@]}"; do | |
| echo "Attaching: $jar" | |
| CURL_FILES+=(-F "file${i}=@\"${jar}\"") | |
| i=$((i+1)) | |
| done | |
| curl \ | |
| -F "payload_json={\"content\":\"@here\\n**${NAME} ${TAG}**\\nGitHub Release: ${URL}\\n\\n**Downloads:** (files attached)\"}" \ | |
| "${CURL_FILES[@]}" \ | |
| "${{ secrets.DISCORD_WEBHOOK_URL }}" |