From 095120f7a93ec3285a753d1f00a9bd411a7fda8a Mon Sep 17 00:00:00 2001 From: Daniel Naylor Date: Tue, 17 May 2022 22:18:02 +0100 Subject: [PATCH] Enable Ore deployments for v2 --- .github/workflows/deployToOre.yml | 69 +++++++++++++++++++++++++++++++ build.gradle.kts | 6 ++- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deployToOre.yml diff --git a/.github/workflows/deployToOre.yml b/.github/workflows/deployToOre.yml new file mode 100644 index 000000000..811ebecc3 --- /dev/null +++ b/.github/workflows/deployToOre.yml @@ -0,0 +1,69 @@ +name: Release to Ore and GH Releases + +on: + push: + tags: + - '[2-9]*' + workflow_dispatch: + +env: + NUCLEUS_CHANGELOG_NAME: "changelog" + +jobs: + buildAndPublish: + runs-on: ubuntu-latest + environment: ore + steps: + - uses: actions/checkout@v3 + - name: Set up Java + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + - name: Build + run: ./gradlew clean build + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: plugin + path: 'output/*-plugin.jar' + if-no-files-found: error + - name: Upload Description + uses: actions/upload-artifact@v3 + with: + name: changelog + path: 'output/changelog.md' + if-no-files-found: error + - name: Upload to Ore + uses: dualspiral/ore-upload-action@v2 + with: + plugin: plugin + description: changelog + apiKey: ${{ secrets.ORE_API_KEY }} + pluginId: "nucleus" + - name: Upload to Github Releases + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + prerelease: ${{ contains(github.ref, 'BETA') || contains(github.ref, 'ALPHA') || contains(github.ref, 'RC') || contains(github.ref, 'PR') }} + body_path: output/changelog.md + files: output/*.jar + - name: Get tag + id: tagval + uses: mad9000/actions-find-and-replace-string@2 + if: startsWith(github.ref, 'refs/tags/') + with: + source: ${{ github.ref }} + find: 'refs/tags/' + replace: '' + - name: Notify Discord + uses: sarisia/actions-status-discord@v1 + if: startsWith(github.ref, 'refs/tags/') + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + with: + nodetail: true + title: Nucleus ${{ steps.tagval.outputs.value }} has been released! + description: 'Download it from Ore by clicking here!' + url: https://ore.spongepowered.org/Nucleus/Nucleus/versions/${{ steps.tagval.outputs.value }} + color: 0x00ff40 \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 835e3c30f..4cee15062 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -165,7 +165,11 @@ val writeRelNotes by tasks.registering { val outputRelNotes by tasks.registering { dependsOn(relNotes) doLast { - Files.write(project.projectDir.toPath().resolve("output").resolve("${nucVersion}.md"), + val parentDirectory = project.projectDir.toPath().resolve("output") + Files.createDirectories(parentDirectory) + + val filename = System.getenv("NUCLEUS_CHANGELOG_NAME") ?: nucleusVersion + Files.write(project.projectDir.toPath().resolve("output").resolve("${filename}.md"), relNotes.get().relNotes!!.toByteArray(StandardCharsets.UTF_8)) } }