diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1717a75..18307a5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,8 @@ -name: Build JAR +name: Build and publish on: - workflow_dispatch: push: + tags: + - '1.18/*' branches: [ '1.18' ] paths: - 'build.gradle' @@ -11,6 +12,7 @@ on: paths: - 'src/**' - 'build.gradle' + jobs: build: runs-on: ubuntu-20.04 @@ -34,5 +36,27 @@ jobs: - name: Upload Build Artifact uses: actions/upload-artifact@v2 with: - name: Generated JAR + name: build-artifacts + path: build/libs/ + + publish: + runs-on: ubuntu-20.04 + if: ${{ success() && github.ref_type == 'tag' }} + needs: [ build ] + steps: + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifacts path: build/libs/ + + - name: Publish build artifacts + uses: Kir-Antipov/mc-publish@v2.1 + with: + modrinth-id: VZWuyRVr + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + + curseforge-id: 441114 + curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} + + github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index f9100d5..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Publish - -on: - workflow_dispatch: - push: - tags: - - '*' - -jobs: - publish: - runs-on: ubuntu-20.04 - steps: - - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Validate Gradle Wrapper - uses: gradle/wrapper-validation-action@v1 - - - name: Setup JDK 17 - uses: actions/setup-java@v2 - with: - distribution: 'temurin' - java-version: '17' - cache: 'gradle' - - - name: Build - run: ./gradlew build - - - name: Publish to Modrinth - run: ./gradlew publishModrinth - env: - MODRINTH: ${{ secrets.MODRINTH_TOKEN }} - - - name: Publish to Curseforge - run: ./gradlew curseforge - env: - CURSEFORGE: ${{ secrets.CURSEFORGE_TOKEN }} - - - name: Publish to Infernal Studios Maven - run: ./gradlew publish - env: - MAVEN_USER: ${{ secrets.MAVEN_USER }} - MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }} - - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} - - - name: Create GitHub Release - uses: ncipollo/release-action@v1 - with: - artifacts: "./build/libs/*" - token: ${{ secrets.GITHUB_TOKEN }} - name: Release ${{ steps.get_version.outputs.VERSION }} diff --git a/build.gradle b/build.gradle index 730e5f7..d0717b4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,23 +1,19 @@ buildscript { repositories { maven { url = 'https://files.minecraftforge.net/maven' } - maven { url = 'https://plugins.gradle.org/m2/' } jcenter() mavenCentral() } dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1+', changing: true - classpath group: 'gradle.plugin.com.modrinth.minotaur', name: 'Minotaur', version: '1.2.1' - classpath group: 'gradle.plugin.com.matthewprenger', name: 'CurseGradle', version: '1.4.0' + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1+', changing: true } } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' -apply plugin: 'com.matthewprenger.cursegradle' // This initializes the config. Please try to modify the variables in the config file, if needed, add more if you see a reason to. ext.config = parseConfig(file('build.properties')) @@ -99,81 +95,6 @@ task sourcesJar(type: Jar) { tasks.build.dependsOn sourcesJar -publishing { - publications { - mavenJava(MavenPublication) { - groupId = config.GROUP - artifactId = config.ARTIFACT - artifact jar - artifact sourcesJar - version "${config.VERSION}-${config.MINECRAFT_VERSION}" - - pom { - name = 'Infernal Expansion' - url = 'https://infernalstudios.org/secondchanceforge' - licenses { - license { - name = 'Apache License 2.0' - url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - scm { - connection = 'scm:git:git://github.com/infernalexp/Second-Chance-Forge.git' - url = 'https://github.com/infernalexp/Second-Chance-Forge' - } - } - } - } - repositories { - maven { - url 'https://maven.infernalstudios.org/releases' - - credentials { - username = System.getenv('MAVEN_USER') - password = System.getenv('MAVEN_TOKEN') - } - - authentication { - basic(BasicAuthentication) - } - } - } -} - -// Modrinth publishing -import com.modrinth.minotaur.TaskModrinthUpload - -task publishModrinth (type: TaskModrinthUpload) { - onlyIf { - System.getenv('MODRINTH') - } - - token = System.getenv('MODRINTH') - projectId = config.MODRINTH_ID - versionNumber = project.version - uploadFile = jar - addFile(sourcesJar) - addGameVersion(config.MINECRAFT_VERSION) - addLoader('forge') -} - -// Curseforge publishing -curseforge { - apiKey = System.getenv('CURSEFORGE') ?: 'If you\'re seeing this, you haven\'t set your "CURSEFORGE" environment variable' - - project { - id = config.CURSEFORGE_ID - changelog = 'No changelog specified.' - releaseType = 'release' - addGameVersion config.MINECRAFT_VERSION - mainArtifact (jar) { - displayName = "Second Chance (Forge) Release ${project.version}" - } - addArtifact sourcesJar - } -} - - // Config parse function def parseConfig(File config) { config.withReader {