diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f987873..bf96fde 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,22 +14,26 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: + distribution: temurin java-version: ${{ matrix.java }} - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1 - - uses: actions/cache@v2 + + - uses: actions/checkout@v4 + - uses: actions/cache@v4 with: path: | ~/.gradle/caches ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} restore-keys: ${{ runner.os }}-gradle- + + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v2 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle run: ./gradlew build env: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0de6a71..6a73f01 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,97 +5,58 @@ on: types: [published] jobs: - publish-github: + build: + name: publish runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 - name: Extract Version from Tag - uses: rishabhgupta/split-by@v1 id: split_tag - with: - string: ${{ github.event.release.tag_name }} - split-by: '/' + run: | + tag=${{ github.event.release.tag_name }} + parts=(${tag//\// }) + echo "mc_version=${parts[0]}" >> $GITHUB_OUTPUT + echo "mod_version=${parts[1]}" >> $GITHUB_OUTPUT - - name: Set up JDK - uses: actions/setup-java@v1 - with: - java-version: 17 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1 - - uses: actions/cache@v2 + - uses: actions/checkout@v4 + - uses: actions/cache@v4 with: path: | ~/.gradle/caches ~/.gradle/wrapper key: ubuntu-latest-gradle-${{ hashFiles('**/*.gradle*') }} restore-keys: ubuntu-latest-gradle- + + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v2 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle - run: ./gradlew -Psemver='${{ steps.split_tag.outputs._1 }}' build + run: ./gradlew -Psemver='${{ steps.split_tag.outputs.mod_version }}' build env: GPR_USER: ${{ secrets.GPR_USER }} GPR_KEY: ${{ secrets.GPR_KEY }} - name: Add Artifacts to Github Release - uses: alexellis/upload-assets@0.3.0 + uses: alexellis/upload-assets@0.4.1 env: GITHUB_TOKEN: ${{ github.token }} with: asset_paths: '["./build/libs/*.jar"]' - - name: Publish to Github Packages - run: gradle -Psemver='${{ steps.split_tag.outputs._1 }}' publish - env: - GPR_USER: ${{ secrets.GPR_USER }} - GPR_KEY: ${{ secrets.GPR_KEY }} - GITHUB_MAVEN_URL: 'https://maven.pkg.github.com/${{ github.repository }}' - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - publish-curse: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Extract Version from Tag - uses: rishabhgupta/split-by@v1 - id: split_tag + - name: Publish to Curseforge and Minotaur (Forge) + uses: Kir-Antipov/mc-publish@v3 with: - string: ${{ github.event.release.tag_name }} - split-by: '/' + name: ${{ github.event.repository.name }}-MC${{ steps.split_tag.outputs.mc_version }}-${{ steps.split_tag.outputs.mod_version }} + version: MC${{ steps.split_tag.outputs.mc_version }}-forge-${{ steps.split_tag.outputs.mod_version }} + java: Java 17 - - name: Set up JDK - uses: actions/setup-java@v1 - with: - java-version: 17 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1 - - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ubuntu-latest-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: ubuntu-latest-gradle- - - # Set Curseforge release type based on pre-release flag. - - name: Set release type to 'release' - run: | - echo "CURSEFORGE_RELEASE_TYPE=release" >> $GITHUB_ENV - if: github.event.release.prerelease == false - - name: Set release type to 'alpha' - run: | - echo "CURSEFORGE_RELEASE_TYPE=alpha" >> $GITHUB_ENV - if: github.event.release.prerelease == true + files: build/libs/*.jar - - name: Publish to Curseforge - run: ./gradlew -Psemver='${{ steps.split_tag.outputs._1 }}' curseforge - env: - GPR_USER: ${{ secrets.GPR_USER }} - GPR_KEY: ${{ secrets.GPR_KEY }} - CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} - CURSEFORGE_RELEASE_TYPE: ${{ env.CURSEFORGE_RELEASE_TYPE }} - CHANGELOG: ${{ github.event.release.body }} + curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }} diff --git a/build.gradle b/build.gradle index b91e435..02349e6 100644 --- a/build.gradle +++ b/build.gradle @@ -10,9 +10,6 @@ buildscript { plugins { id 'java' - id 'idea' - id 'maven-publish' - id 'com.matthewprenger.cursegradle' version '1.4.0' id 'com.github.johnrengelman.shadow' version '8.1.1' } @@ -66,49 +63,6 @@ dependencies { minecraft { mappings channel: 'official', version: minecraft_version - - runs { - client { - workingDirectory project.file('run') - - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'info' - - mods { - sedna { - source sourceSets.main - } - } - } - - server { - workingDirectory project.file('run') - - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'info' - - mods { - sedna { - source sourceSets.main - } - } - } - - data { - workingDirectory project.file('run') - - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'info' - - args '--mod', 'sedna', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') - - mods { - sedna { - source sourceSets.main - } - } - } - } } jar { @@ -146,45 +100,3 @@ reobf { artifacts { archives shadowJar } - -publishing { - publications { - mavenJava(MavenPublication) { - groupId = project.group - artifactId = project.name - version = semver - artifact shadowJar - } - } - repositories { - maven { - name = "GitHubPackages" - url = System.getenv("GITHUB_MAVEN_URL") ?: "" - credentials { - username = System.getenv("GITHUB_ACTOR") - password = System.getenv("GITHUB_TOKEN") - } - } - } -} - -curseforge { - apiKey = System.getenv('CURSEFORGE_API_KEY') ?: "" - project { - id = curse_project_id - releaseType = System.getenv('CURSEFORGE_RELEASE_TYPE') ?: "alpha" - changelogType = 'markdown' - changelog = System.getenv("CHANGELOG") ?: "Changelog not available." - addGameVersion 'Forge' - addGameVersion minecraft_version - addGameVersion 'Java 17' - } -} - -idea { - module { - for (final String exclude in ['out', 'logs', 'run', 'src/generated']) { - excludeDirs += file(exclude) - } - } -}