Parkour bot project (CI) #114
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Generate TypeScript Definitions | |
| on: | |
| push: | |
| branches: [ master ] | |
| pull_request: | |
| branches: [ master ] | |
| workflow_dispatch: # Allow manual triggering | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' # Updated to JDK 21 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Clone LiquidBounce NextGen | |
| run: | | |
| git clone https://github.com/commandblock2/LiquidBounce.git lbng | |
| cd lbng | |
| git checkout 9888c42aa793bdac38767839443de934e509e103 | |
| - name: Create Mods Directory | |
| run: mkdir -p lbng/run/mods | |
| - name: Download and Install Baritone | |
| uses: dawidd6/action-download-artifact@v11 | |
| with: | |
| github_token: ${{secrets.BARITONE_DOWNLOAD_TOKEN}} | |
| name: Artifacts | |
| repo: cabaletta/baritone | |
| workflow: gradle_build.yml | |
| branch: 1.21.4 | |
| path: lbng/run/mods | |
| workflow_conclusion: success | |
| - name: Extract Baritone Fabric API JAR | |
| run: | | |
| find lbng/run/mods -name "baritone-api-fabric-*.jar" -exec mv {} lbng/run/mods/ \; | |
| - name: Download Latest ts-generator | |
| run: | | |
| mkdir -p lbng/run/LiquidBounce/scripts | |
| LATEST_RELEASE_URL=$(curl -s https://api.github.com/repos/commandblock2/ts-generator/releases/latest | jq -r '.assets[] | select(.name | endswith(".zip")) | .browser_download_url') | |
| curl -L $LATEST_RELEASE_URL -o lbng/run/LiquidBounce/scripts/ts-generator.zip | |
| unzip lbng/run/LiquidBounce/scripts/ts-generator.zip -d lbng/run/LiquidBounce/scripts/ | |
| # Look specifically for the main jar file (excluding source jars) | |
| find lbng/run/LiquidBounce/scripts/ -name "*.jar" -not -name "*-sources.jar" -not -name "*-src.jar" -exec mv {} lbng/run/LiquidBounce/scripts/ts-generator.jar \; || echo "Main JAR file not found in the zip, check contents" | |
| - name: Copy ts-defgen.js to LiquidBounce scripts | |
| run: | | |
| cp LBNG-script/ts-defgen.js lbng/run/LiquidBounce/scripts/ | |
| - name: Install Xvfb | |
| run: sudo apt-get install -y xvfb | |
| - name: Run LiquidBounce with Gradle | |
| working-directory: ./lbng | |
| env: | |
| CI_BUILD: "true" # Set the CI_BUILD flag to auto-execute ts-defgen | |
| run: | | |
| chmod +x ./gradlew | |
| timeout 60m xvfb-run --auto-servernum --server-args="-screen 0 1280x720x24" ./gradlew runClient -Dfabric.headless=true || exit 0 | |
| - name: Copy Generated Definitions | |
| run: | | |
| mkdir -p generated-modules | |
| cp -r lbng/run/LiquidBounce/scripts/types-gen generated-modules/ | |
| - name: Find JVM Types Directory | |
| id: find_jvm_types | |
| run: | | |
| # Finds the first directory matching jvm-types* inside generated-modules/types-gen/ | |
| JVM_DIR=$(ls -d generated-modules/types-gen/jvm-types* | head -n 1) | |
| echo "jvm_dir=$JVM_DIR" >> $GITHUB_OUTPUT # Output the found path | |
| - name: Copy Augmentations | |
| run: | | |
| # Use the found directory path | |
| cp -r augmentations/* ${{ steps.find_jvm_types.outputs.jvm_dir }}/augmentations | |
| - name: Install Generated Definitions | |
| run: | | |
| # Use the found directory path for npm install | |
| npm install file:${{ steps.find_jvm_types.outputs.jvm_dir }} --no-save | |
| - name: Compile TypeScript | |
| run: | | |
| mkdir -p dist | |
| tsc || exit 0 | |
| - name: Upload TypeScript Definitions | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: 'jvm-types' | |
| path: ${{ steps.find_jvm_types.outputs.jvm_dir }} | |
| - name: Upload Compiled Scripts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: compiled-scripts | |
| path: dist |