name: Build and Release on: push: tags: - 'v*' jobs: build: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up JDK 21 uses: actions/setup-java@v4 with: java-version: '21' distribution: 'temurin' - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle run: ./gradlew build - name: Get version from tag id: get_version run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT - name: Find JAR file id: find_jar run: | JAR_FILE=$(find build/libs -name "*.jar" ! -name "*-sources.jar" ! -name "*-javadoc.jar" | head -1) echo "JAR_PATH=$JAR_FILE" >> $GITHUB_OUTPUT echo "JAR_NAME=$(basename $JAR_FILE)" >> $GITHUB_OUTPUT - name: Create Draft Release run: | VERSION="${{ steps.get_version.outputs.VERSION }}" RELEASE_BODY="## Release ${VERSION} ### What's New - Feature 1 - Feature 2 ### Bug Fixes - Fix 1 - Fix 2 ### Changes - Change 1 - Change 2 ### Breaking Changes - None ### Installation 1. Download the JAR file from the assets below 2. Place it in your server's \`plugins\` folder 3. Restart the server ### Requirements - Minecraft Server with PaperMC: 1.21.11 - Java: 21+" # Create draft release RESPONSE=$(curl -s -X POST \ -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ -H "Content-Type: application/json" \ "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases" \ -d "{ \"tag_name\": \"${VERSION}\", \"name\": \"Release ${VERSION}\", \"body\": $(echo "$RELEASE_BODY" | jq -Rs .), \"draft\": true, \"prerelease\": false }") RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id') echo "Created release with ID: $RELEASE_ID" echo "RELEASE_ID=$RELEASE_ID" >> $GITHUB_ENV - name: Upload JAR to Release run: | curl -s -X POST \ -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ -H "Content-Type: application/java-archive" \ "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/${{ env.RELEASE_ID }}/assets?name=${{ steps.find_jar.outputs.JAR_NAME }}" \ --data-binary @"${{ steps.find_jar.outputs.JAR_PATH }}" echo "Uploaded ${{ steps.find_jar.outputs.JAR_NAME }} to release"