55 lines
1.7 KiB
YAML
55 lines
1.7 KiB
YAML
name: Build Custom Server Mods
|
|
|
|
on:
|
|
push:
|
|
tags: ['v*']
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: docker
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup JDK 21
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: '21'
|
|
|
|
- name: Make scripts executable
|
|
run: chmod +x scripts/*.sh mods/*/manifest.sh
|
|
|
|
- name: Build all manifests
|
|
run: ./scripts/build-all.sh
|
|
|
|
- name: Create release
|
|
id: release
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
API: https://git.mithraic.cloud/api/v1/repos/ad3laid3/custom-server-mods/releases
|
|
run: |
|
|
set -e
|
|
TAG="${GITHUB_REF_NAME}"
|
|
AUTH="Authorization: token ${GITHUB_TOKEN}"
|
|
RELEASE_JSON=$(curl -sS -X POST "$API" \
|
|
-H "$AUTH" -H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"Custom Server Mods $TAG\",\"body\":\"Pre-built JARs for SciCraft pack.\"}")
|
|
RELEASE_ID=$(printf '%s' "$RELEASE_JSON" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
|
echo "release_id=$RELEASE_ID" >> "$GITHUB_ENV"
|
|
echo "API=$API" >> "$GITHUB_ENV"
|
|
|
|
- name: Upload jars as release assets
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
set -e
|
|
AUTH="Authorization: token ${GITHUB_TOKEN}"
|
|
for jar in out/*/*.jar; do
|
|
[ -f "$jar" ] || continue
|
|
echo "Uploading $jar"
|
|
curl -sS -X POST "$API/$RELEASE_ID/assets?name=$(basename "$jar")" \
|
|
-H "$AUTH" \
|
|
-F "attachment=@$jar"
|
|
done
|
|
echo "Uploaded all jars to release $RELEASE_ID"
|