diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..5d0a8d6 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,28 @@ +name: Setup Environment +description: Setup JDK and Gradle + +inputs: + update-cache: + description: If cache should be updated + required: false + default: 'false' + +runs: + using: composite + steps: + - name: Setup JDK + uses: actions/setup-java@v5 + with: + java-version: 17 + distribution: temurin + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + with: + cache-write-only: ${{ inputs.update-cache }} + cache-read-only: ${{ github.ref != 'refs/heads/1.20.1' }} + add-job-summary: on-failure + + - name: Grant Execute Permission for gradlew + shell: bash + run: chmod +x gradlew \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..6b96f30 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,52 @@ +name: Build + +on: + push: + branches: [ "1.20.1" ] + paths: + - 'src/**' + - 'gradle/**' + - '**/*.gradle.kts' + - '**/gradle.properties' + - '.github/workflows/**' + - '.github/actions/**' + pull_request: + branches: [ "1.20.1" ] + +concurrency: + group: build-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + env: + CI: true + steps: + - name: Checkout Repository + uses: actions/checkout@v6 + + - name: Setup Environment + uses: ./.github/actions/setup + + - name: Build with Gradle + run: ./gradlew build --no-daemon + + - name: Get Mod Information + id: info + run: | + MOD_VERSION=$(grep -oP 'mod_version=\K.*' gradle.properties) + MC_VERSION=$(grep -oP 'minecraft_version=\K.*' gradle.properties) + echo "mod_version=$MOD_VERSION" >> $GITHUB_OUTPUT + echo "mc_version=$MC_VERSION" >> $GITHUB_OUTPUT + echo "sha_short=$(echo '${{ github.sha }}' | cut -c 1-7)" >> $GITHUB_OUTPUT + + - name: Upload Artifacts + uses: actions/upload-artifact@v6 + with: + name: hoarding-${{ steps.info.outputs.mc_version }}-${{ steps.info.outputs.mod_version }}+${{ steps.info.outputs.sha_short }} + path: build/libs/*.jar + if-no-files-found: error + retention-days: 7