60 lines
1.4 KiB
YAML
60 lines
1.4 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches-ignore:
|
|
- artifacts
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Java 21
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: temurin
|
|
java-version: "21"
|
|
|
|
- name: Make Gradle wrapper executable
|
|
run: chmod +x ./gradlew
|
|
|
|
- name: Build
|
|
run: ./gradlew build --no-daemon
|
|
|
|
- name: Publish jar to artifacts branch
|
|
if: github.event_name != 'pull_request'
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
mkdir -p /tmp/worldhandler-artifacts
|
|
cp build/libs/*.jar /tmp/worldhandler-artifacts/
|
|
|
|
git config user.name "Gitea Actions"
|
|
git config user.email "actions@gitea.local"
|
|
|
|
git fetch origin artifacts || true
|
|
git switch --force-create artifacts
|
|
git rm -rf .
|
|
|
|
cp /tmp/worldhandler-artifacts/*.jar .
|
|
cat > README.md <<'EOF'
|
|
# WorldHandler build artifacts
|
|
|
|
This branch is maintained by the Gitea runner.
|
|
Download the jar file from this branch.
|
|
EOF
|
|
|
|
git add README.md *.jar
|
|
git commit --allow-empty -m "Publish WorldHandler jar from ${GITHUB_SHA}"
|
|
git push --force origin artifacts
|