diff --git a/.github/workflows/build-fabric-1.21.8.yml b/.github/workflows/build-fabric-1.21.8.yml new file mode 100644 index 000000000..fbcd5a71c --- /dev/null +++ b/.github/workflows/build-fabric-1.21.8.yml @@ -0,0 +1,98 @@ +name: Build Fabric jar (Minecraft 1.21.8) + +on: + workflow_dispatch: + inputs: + create_release: + description: 'Create GitHub Release and upload built jar(s)? (true/false)' + required: false + default: 'false' + release_tag: + description: 'Release tag to use if creating a release (e.g. v1.21.8-build-001)' + required: false + default: 'v1.21.8-build-${{ github.run_id }}' + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + outputs: + artifact-name: fabric-1.21.8-jars + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Java 17 (Temurin) + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + cache: 'gradle' + + - name: Show Java info + run: java -version && javac -version + + - name: Run Gradle build + # Adjust the Gradle task if your project builds a remapped jar with a different task (eg :fabric:remapJar) + run: ./gradlew clean build --no-daemon + env: + JAVA_HOME: ${{ runner.tool_cache }}/java + + - name: List candidate jars + run: | + echo "Looking for jars produced by the build:" + find . -type f -name "*.jar" -not -path "*/.gradle/*" -maxdepth 6 -print || true + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: fabric-1.21.8-jars + path: | + **/build/libs/*.jar + **/fabric/build/libs/*.jar + **/mod/build/libs/*.jar + + release: + needs: build + runs-on: ubuntu-latest + if: ${{ github.event.inputs.create_release == 'true' }} + steps: + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: fabric-1.21.8-jars + path: ./artifact + + - name: Create GitHub release + id: create_release + uses: actions/create-release@v1 + with: + tag_name: ${{ github.event.inputs.release_tag }} + release_name: ${{ github.event.inputs.release_tag }} + body: "Automated build for Fabric / Minecraft 1.21.8 (generated by workflow)." + draft: false + prerelease: false + + - name: Install GitHub CLI + run: | + sudo apt-get update + sudo apt-get install -y gh + - name: Upload jars to release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "Uploading jars found in ./artifact to release ${{ github.event.inputs.release_tag }} ..." + ls -la ./artifact || true + # Upload all jars present under ./artifact + set -e + JARS=$(find ./artifact -type f -name "*.jar" -print) + if [ -z "$JARS" ]; then + echo "No jars found to upload. Exiting." + exit 1 + fi + for jar in $JARS; do + echo "Uploading $jar" + gh release upload "${{ github.event.inputs.release_tag }}" "$jar" --clobber + done