diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml new file mode 100644 index 000000000..c6e51a3cf --- /dev/null +++ b/.github/workflows/gradle-build.yml @@ -0,0 +1,32 @@ +# This workflow will build a Java project with Gradle +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle +# +# This worflow will also upload an artifact to Nexus, Hangar, Modrinth, and GitHub releases. + +name: Java CI with Gradle +on: [ push ] + +jobs: + build: + runs-on: ubuntu-latest + if: "!contains(github.event.commits[0].message, '[ci-skip]')" + steps: + - uses: actions/checkout@v3.0.0 + - uses: gradle/wrapper-validation-action@v1 + - name: Set up JDK 17 + uses: actions/setup-java@v3.0.0 + with: + distribution: temurin + java-version: 17 + cache: gradle + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Test with Gradle + run: ./gradlew test + - name: Build with Gradle + run: ./gradlew build + - name: Upload artifacts + uses: "actions/upload-artifact@v2.2.3" + with: + name: "IridiumSkyblock" + path: "build/libs/IridiumSkyblock-*.jar" \ No newline at end of file diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml deleted file mode 100644 index e0af74584..000000000 --- a/.github/workflows/gradle.yml +++ /dev/null @@ -1,55 +0,0 @@ -# This workflow will build a Java project with Gradle -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - -name: Java CI with Gradle -on: [ push, pull_request ] - -jobs: - build: - runs-on: ubuntu-latest - if: "!contains(github.event.commits[0].message, '[ci-skip]')" - steps: - - uses: actions/checkout@v3.0.0 - - uses: gradle/wrapper-validation-action@v1 - - name: Set up JDK 17 - uses: actions/setup-java@v3.0.0 - with: - distribution: temurin - java-version: 17 - cache: gradle - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Test with Gradle - run: ./gradlew test - - name: Build with Gradle - run: ./gradlew build - - name: Upload artifacts - uses: "actions/upload-artifact@v2.2.3" - with: - name: "IridiumSkyblock" - path: "build/libs/IridiumSkyblock-*.jar" - upload: - needs: build - runs-on: ubuntu-latest - if: "contains(github.event.commits[0].message, 'Version Increment')" - steps: - - uses: actions/checkout@v2 - - uses: thecodemonkey/action-get-gradle-version@master - id: version - with: - file: "build.gradle.kts" - - uses: actions/download-artifact@v3.0.2 - with: - name: "IridiumSkyblock" - path: "./" - - name: Publish to Nexus - uses: sonatype-nexus-community/nexus-repo-github-action@master - with: - serverUrl: "https://nexus.iridiumdevelopment.net/" - username: "${{ secrets.NEXUS_USERNAME }}" - password: "${{ secrets.NEXUS_PASSWORD }}" - format: "maven2" - repository: "maven-releases" - coordinates: "groupId=com.iridium artifactId=IridiumSkyblock version=${{steps.version.outputs.version}} generate-pom=on" - assets: "extension=jar" - filename: "IridiumSkyblock-*.jar" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..c7ca12d6f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,137 @@ +name: Publish Artifacts +on: + release: + types: [ published ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3.0.0 + - uses: gradle/wrapper-validation-action@v1 + - name: Set up JDK 17 + uses: actions/setup-java@v3.0.0 + with: + distribution: temurin + java-version: 17 + cache: gradle + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Test with Gradle + run: ./gradlew test + - name: Build with Gradle + run: ./gradlew build + - name: Upload artifacts + uses: "actions/upload-artifact@v2.2.3" + with: + name: "IridiumSkyblock" + path: "build/libs/IridiumSkyblock-*.jar" + - name: Upload release asset + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: build/libs/IridiumSkyblock-*.jar + asset_name: IridiumSkyblock.jar + asset_content_type: application/java-archive + token: ${{ secrets.GITHUB_TOKEN }} + + publish-nexus: + needs: build + runs-on: ubuntu-latest + steps: + - name: Downloading artifact + uses: actions/checkout@v2 + - uses: thecodemonkey/action-get-gradle-version@master + id: version + with: + file: "build.gradle.kts" + - uses: actions/download-artifact@v3.0.2 + with: + name: "IridiumSkyblock" + path: "./" + + - name: Publishing to Nexus + uses: sonatype-nexus-community/nexus-repo-github-action@master + with: + serverUrl: "https://nexus.iridiumdevelopment.net/" + username: "${{ secrets.NEXUS_USERNAME }}" + password: "${{ secrets.NEXUS_PASSWORD }}" + format: "maven2" + repository: "maven-releases" + coordinates: "groupId=com.iridium artifactId=IridiumSkyblock version=${{steps.version.outputs.version}} generate-pom=on" + assets: "extension=jar" + filename: "IridiumSkyblock-*.jar" + + publish-hangar: + needs: build + runs-on: ubuntu-latest + steps: + - name: Downloading artifact + uses: actions/checkout@v2 + - uses: thecodemonkey/action-get-gradle-version@master + id: version + with: + file: "build.gradle.kts" + - uses: actions/download-artifact@v3.0.2 + with: + name: "IridiumSkyblock" + path: "./" + + - if: github.event.release.prerelease == true + name: Publishing to Hangar (Beta) + uses: benwoo1110/hangar-upload-action@v1.0.1 + with: + api-token: ${{ secrets.HANGAR_API_TOKEN }} + slug: IridiumSkyblock + channel: beta + version: ${{steps.version.outputs.version}} + files: "IridiumSkyblock-*.jar" + + - if: github.event.release.prerelease == false + name: Publishing to Hangar (Release) + uses: benwoo1110/hangar-upload-action@v1.0.1 + with: + api-token: ${{ secrets.HANGAR_API_TOKEN }} + slug: IridiumSkyblock + channel: release + version: ${{steps.version.outputs.version}} + files: "IridiumSkyblock-*.jar" + + publish-modrinth: + needs: build + runs-on: ubuntu-latest + steps: + - name: Downloading artifact + uses: actions/checkout@v2 + - uses: thecodemonkey/action-get-gradle-version@master + id: version + with: + file: "build.gradle.kts" + - uses: actions/download-artifact@v3.0.2 + with: + name: "IridiumSkyblock" + path: "./" + + - if: github.event.release.prerelease == true + name: Publish to Modrinth (Beta) + uses: Kir-Antipov/mc-publish@v3.3 + with: + files: "IridiumSkyblock-*.jar" + version: ${{steps.version.outputs.version}} + version-type: beta + modrinth-id: uVMG0MzO + modrinth-featured: true + modrinth-unfeature-mode: any + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + + - if: github.event.release.prerelease == false + name: Publish to Modrinth (Release) + uses: Kir-Antipov/mc-publish@v3.3 + with: + files: "IridiumSkyblock-*.jar" + version: ${{steps.version.outputs.version}} + version-type: release + modrinth-id: uVMG0MzO + modrinth-featured: true + modrinth-unfeature-mode: any + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} \ No newline at end of file