Merge pull request #71 from MIA-Development-Team/dependabot/github_ac… #270
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: CI (Build) | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Setup Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: 21 | |
| cache: gradle | |
| - name: Make gradle wrapper executable | |
| run: chmod +x ./gradlew | |
| - name: Append short Git commit hash to version | |
| run: | | |
| SHORT_HASH=$(git rev-parse --short HEAD) | |
| CURRENT_VERSION=$(grep '^mod_version=' gradle.properties | cut -d= -f2) | |
| sed -i "s/^mod_version=.*/mod_version=${CURRENT_VERSION}+$SHORT_HASH/" gradle.properties | |
| - name: Build with Gradle | |
| run: ./gradlew build | |
| - name: Set JAR name | |
| id: binary-version | |
| run: | | |
| MOD_VERSION=$(grep '^mod_version=' gradle.properties | cut -d= -f2) | |
| MC_VERSION=$(grep '^minecraft_version=' gradle.properties | cut -d= -f2) | |
| JAR_NAME="MadeInAbyss-${MOD_VERSION}-mc${MC_VERSION}" | |
| echo "jar_name=$JAR_NAME" >> "$GITHUB_OUTPUT" | |
| - name: Rename output JAR | |
| run: | | |
| ORIG_JAR=$(ls build/libs/*.jar | head -n 1) | |
| NEW_NAME="build/libs/${{ steps.binary-version.outputs.jar_name }}.jar" | |
| mv "$ORIG_JAR" "$NEW_NAME" | |
| - name: Upload Mod JAR | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ steps.binary-version.outputs.jar_name }} | |
| path: build/libs/*.jar |