Skip to content

v1.0.2

v1.0.2 #1

name: Release to Discord
on:
release:
types: [published]
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: Build
run: ./gradlew build
- 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 }}"