diff --git a/.github/workflows/call.github_release.yml b/.github/workflows/call.github_release.yml index 9d123b66..334cb70e 100644 --- a/.github/workflows/call.github_release.yml +++ b/.github/workflows/call.github_release.yml @@ -25,54 +25,10 @@ on: jobs: github_release: - runs-on: ubuntu-latest - outputs: - release_created: ${{ steps.release.outputs.release_created }} - tag_name: ${{ steps.release.outputs.tag_name }} - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ inputs.promote_from }} - - - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - cache: gradle - - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1 - - - name: Build and test - uses: gradle/gradle-build-action@v2 - with: - arguments: clean build -x assemble -x shadowJar -x checkStyleMain -x checkStyleTest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create release - id: release - uses: benwoo1110/semantic-release-action@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - release_mode: ${{ inputs.release_mode }} - version_bump: ${{ inputs.version_bump }} - promote_from: ${{ inputs.promote_from }} - - - name: Publish package - if: steps.release.outputs.release_created == 'true' - uses: gradle/gradle-build-action@v2 - with: - arguments: publish -x checkStyleMain -x checkStyleTest -x test - env: - GITHUB_VERSION: ${{ steps.release.outputs.publish_version }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload release artifact - if: steps.release.outputs.release_created == 'true' - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: build/libs/multiverse-core-${{ steps.release.outputs.publish_version }}.jar - asset_name: multiverse-core-${{ steps.release.outputs.tag_name }}.jar - tag: ${{ steps.release.outputs.tag_name }} + uses: ./.github/workflows/generic.github_release.yml + secrets: inherit + with: + plugin_name: multiverse-core + release_mode: ${{ inputs.release_mode }} + version_bump: ${{ inputs.version_bump }} + promote_from: ${{ inputs.promote_from }} diff --git a/.github/workflows/call.platform_uploads.yml b/.github/workflows/call.platform_uploads.yml index 7ecbfabf..06b8e074 100644 --- a/.github/workflows/call.platform_uploads.yml +++ b/.github/workflows/call.platform_uploads.yml @@ -15,73 +15,38 @@ on: description: 'Upload to dev.bukkit.org' required: true type: string + upload_hangar: + description: 'Upload to hangar.papermc.io' + required: true + type: string secrets: MODRINTH_TOKEN: required: true DBO_UPLOAD_API_TOKEN: required: true + HANGAR_UPLOAD_TOKEN: + required: true jobs: platform_uploads: - runs-on: ubuntu-latest - steps: - - name: Get release info - id: release-info - uses: cardinalby/git-get-release-action@1.2.4 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag: ${{ inputs.target_tag }} + uses: ./.github/workflows/generic.platform_uploads.yml + secrets: inherit + with: + plugin_name: multiverse-core + modrinth_project_id: 3wmN97b8 + modrinth_dependencies: '[]' + dbo_project_id: 30765 + dbo_project_relations: > + [ + {"slug": "multiverse-portals", "type": "optionalDependency"}, + {"slug": "multiverse-netherportals", "type": "optionalDependency"}, + {"slug": "multiverse-signportals", "type": "optionalDependency"}, + {"slug": "multiverse-inventories", "type": "optionalDependency"} + ] + hangar_slug: Multiverse-Core + hangar_plugin_dependencies: '{}' - - name: Download release artifact - id: release-artifact - uses: dsaltares/fetch-gh-release-asset@1.1.1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - version: tags/${{ steps.release-info.outputs.tag_name }} - file: multiverse-core-${{ steps.release-info.outputs.tag_name }}.jar - - - name: Parse release type - id: parse-release-type - run: | - if [[ "${{ steps.release-info.outputs.prerelease }}" == "true" ]]; then - echo Setting release_type to Beta - echo "release_type=Beta" >> $GITHUB_OUTPUT - else - echo Setting release_type to Release - echo "release_type=Release" >> $GITHUB_OUTPUT - fi - - - name: Upload to Modrinth - if: ${{ !cancelled() && inputs.upload_modrinth == 'true' }} - uses: benwoo1110/modrinth-upload-action@v1 - with: - api_token: ${{ secrets.MODRINTH_TOKEN }} - project_id: 3wmN97b8 - version_number: ${{ steps.release-info.outputs.tag_name }} - files: '["${{ github.workspace }}/multiverse-core-${{ steps.release-info.outputs.tag_name }}.jar"]' - name: ${{ steps.release-info.outputs.tag_name }} - changelog: ${{ steps.release-artifact.outputs.body }} - game_versions: 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13 - version_type: ${{ steps.parse-release-type.outputs.release_type }} - loaders: bukkit, spigot, paper - - - name: Upload to DBO - if: ${{ !cancelled() && inputs.upload_dbo == 'true' }} - uses: benwoo1110/dbo-upload-action@v1 - with: - api_token: ${{ secrets.DBO_UPLOAD_API_TOKEN }} - project_id: 30765 - changelog: ${{ steps.release-artifact.outputs.body }} - changelog_type: markdown - display_name: ${{ steps.release-info.outputs.tag_name }} - game_versions: 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17, 1.16, 1.15, 1.14, 1.13 - release_type: ${{ steps.parse-release-type.outputs.release_type }} - project_relations: > - [ - {"slug": "multiverse-portals", "type": "optionalDependency"}, - {"slug": "multiverse-netherportals", "type": "optionalDependency"}, - {"slug": "multiverse-signportals", "type": "optionalDependency"}, - {"slug": "multiverse-inventories", "type": "optionalDependency"} - ] - file_path: ${{ github.workspace }}/multiverse-core-${{ steps.release-info.outputs.tag_name }}.jar + target_tag: ${{ inputs.target_tag }} + upload_modrinth: ${{ inputs.upload_modrinth }} + upload_dbo: ${{ inputs.upload_dbo }} + upload_hangar: ${{ inputs.upload_hangar }} diff --git a/.github/workflows/dispatch.platform_uploads.yml b/.github/workflows/dispatch.platform_uploads.yml index 9676755a..2eb99cb5 100644 --- a/.github/workflows/dispatch.platform_uploads.yml +++ b/.github/workflows/dispatch.platform_uploads.yml @@ -15,6 +15,10 @@ on: description: 'Upload to dev.bukkit.org' required: true type: boolean + upload_hangar: + description: 'Upload to hangar.papermc.io' + required: true + type: boolean jobs: dispatch_platform_uploads: @@ -24,3 +28,4 @@ jobs: target_tag: ${{ github.event.inputs.target_tag }} upload_modrinth: ${{ github.event.inputs.upload_modrinth }} upload_dbo: ${{ github.event.inputs.upload_dbo }} + upload_hangar: ${{ github.event.inputs.upload_hangar }} diff --git a/.github/workflows/dispatch.promote_release.yml b/.github/workflows/dispatch.promote_release.yml index a0a100f5..0a59ca46 100644 --- a/.github/workflows/dispatch.promote_release.yml +++ b/.github/workflows/dispatch.promote_release.yml @@ -35,3 +35,4 @@ jobs: target_tag: ${{ needs.github_release.outputs.tag_name }} upload_modrinth: 'true' upload_dbo: 'true' + upload_hangar: 'true' diff --git a/.github/workflows/generic.github_release.yml b/.github/workflows/generic.github_release.yml new file mode 100644 index 00000000..6210d1ed --- /dev/null +++ b/.github/workflows/generic.github_release.yml @@ -0,0 +1,91 @@ +name: 'Generic: GitHub Release' + +on: + workflow_call: + inputs: + # Plugin specific + plugin_name: + description: 'Plugin name' + required: true + type: string + + # Common params + release_mode: + description: 'Release mode' + required: true + type: string + version_bump: + description: 'Version bump' + required: false + type: string + promote_from: + description: 'Promote from' + required: false + type: string + outputs: + release_created: + description: 'Release created' + value: ${{ jobs.github_release.outputs.release_created }} + tag_name: + description: 'Tag name' + value: ${{ jobs.github_release.outputs.tag_name }} + +jobs: + github_release: + runs-on: ubuntu-latest + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + steps: + - name: Echo inputs + run: | + echo "release_mode: ${{ inputs.release_mode }}" + echo "version_bump: ${{ inputs.version_bump }}" + echo "promote_from: ${{ inputs.promote_from }}" + + - uses: actions/checkout@v3 + with: + ref: ${{ inputs.promote_from }} + + - uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + cache: gradle + + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + + - name: Build and test + uses: gradle/gradle-build-action@v2 + with: + arguments: clean build -x assemble -x shadowJar -x checkStyleMain -x checkStyleTest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create release + id: release + uses: benwoo1110/semantic-release-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + release_mode: ${{ inputs.release_mode }} + version_bump: ${{ inputs.version_bump }} + promote_from: ${{ inputs.promote_from }} + + - name: Publish package + if: steps.release.outputs.release_created == 'true' + uses: gradle/gradle-build-action@v2 + with: + arguments: publish -x checkStyleMain -x checkStyleTest -x test + env: + GITHUB_VERSION: ${{ steps.release.outputs.publish_version }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload release artifact + if: steps.release.outputs.release_created == 'true' + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: build/libs/${{ inputs.plugin_name }}-${{ steps.release.outputs.publish_version }}.jar + asset_name: ${{ inputs.plugin_name }}-${{ steps.release.outputs.tag_name }}.jar + tag: ${{ steps.release.outputs.tag_name }} diff --git a/.github/workflows/generic.platform_uploads.yml b/.github/workflows/generic.platform_uploads.yml new file mode 100644 index 00000000..2110c31d --- /dev/null +++ b/.github/workflows/generic.platform_uploads.yml @@ -0,0 +1,141 @@ +name: 'Generic: Platform Uploads' + +on: + workflow_call: + inputs: + # Plugin specific params + plugin_name: + description: 'Plugin name' + required: true + type: string + + modrinth_project_id: + description: 'modrinth.com project ID' + required: true + type: string + modrinth_dependencies: + description: 'modrinth.com project dependencies' + required: false + type: string + default: '[]' + + dbo_project_id: + description: 'dev.bukkit.org project ID' + required: true + type: string + dbo_project_relations: + description: 'dev.bukkit.org project relations' + required: false + type: string + default: '[]' + + hangar_slug: + description: 'hangar.papermc.io project slug' + required: true + type: string + hangar_plugin_dependencies: + description: 'hangar.papermc.io project dependencies' + required: false + type: string + default: '{}' + + # Common params + target_tag: + description: 'Version to upload' + required: true + type: string + + upload_modrinth: + description: 'Upload to modrinth.com' + required: true + type: string + upload_dbo: + description: 'Upload to dev.bukkit.org' + required: true + type: string + upload_hangar: + description: 'Upload to hangar.papermc.io' + required: true + type: string + + secrets: + MODRINTH_TOKEN: + required: true + DBO_UPLOAD_API_TOKEN: + required: true + HANGAR_UPLOAD_TOKEN: + required: true + +jobs: + platform_uploads: + runs-on: ubuntu-latest + steps: + - name: Get release info + id: release-info + uses: cardinalby/git-get-release-action@1.2.4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag: ${{ inputs.target_tag }} + + - name: Download release artifact + id: release-artifact + uses: dsaltares/fetch-gh-release-asset@1.1.1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: tags/${{ steps.release-info.outputs.tag_name }} + file: ${{ inputs.plugin_name }}-${{ steps.release-info.outputs.tag_name }}.jar + + - name: Parse release type + id: parse-release-type + run: | + if [[ "${{ steps.release-info.outputs.prerelease }}" == "true" ]]; then + echo Setting release_type to Beta + echo "release_type=Beta" >> $GITHUB_OUTPUT + else + echo Setting release_type to Release + echo "release_type=Release" >> $GITHUB_OUTPUT + fi + + - name: Upload to Modrinth + if: ${{ !cancelled() && inputs.upload_modrinth == 'true' }} + uses: benwoo1110/modrinth-upload-action@v1 + with: + api_token: ${{ secrets.MODRINTH_TOKEN }} + project_id: ${{ inputs.modrinth_project_id }} + version_number: ${{ steps.release-info.outputs.tag_name }} + files: '["${{ github.workspace }}/${{ inputs.plugin_name }}-${{ steps.release-info.outputs.tag_name }}.jar"]' + name: ${{ steps.release-info.outputs.tag_name }} + changelog: ${{ steps.release-artifact.outputs.body }} + game_versions: 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13 + version_type: ${{ steps.parse-release-type.outputs.release_type }} + loaders: bukkit, spigot, paper + dependencies: ${{ inputs.modrinth_dependencies }} + + - name: Upload to DBO + if: ${{ !cancelled() && inputs.upload_dbo == 'true' }} + uses: benwoo1110/dbo-upload-action@v1 + with: + api_token: ${{ secrets.DBO_UPLOAD_API_TOKEN }} + project_id: ${{ inputs.dbo_project_id }} + changelog: ${{ steps.release-artifact.outputs.body }} + changelog_type: markdown + display_name: ${{ steps.release-info.outputs.tag_name }} + game_versions: 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17, 1.16, 1.15, 1.14, 1.13 + release_type: ${{ steps.parse-release-type.outputs.release_type }} + project_relations: ${{ inputs.dbo_project_relations }} + file_path: ${{ github.workspace }}/${{ inputs.plugin_name }}-${{ steps.release-info.outputs.tag_name }}.jar + + - name: Upload to Hangar + if: ${{ !cancelled() && inputs.upload_hangar == 'true' }} + uses: benwoo1110/hangar-upload-action@v1 + with: + api_token: ${{ secrets.HANGAR_UPLOAD_TOKEN }} + author: Multiverse + slug: ${{ inputs.hangar_slug }} + version: ${{ steps.release-info.outputs.tag_name }} + channel: ${{ steps.parse-release-type.outputs.release_type }} + files: '[{"path": "${{ github.workspace }}/${{ inputs.plugin_name }}-${{ steps.release-info.outputs.tag_name }}.jar", "platforms": ["PAPER"]}]' + description: ${{ steps.release-artifact.outputs.body }} + platform_dependencies: '{"PAPER": ["1.13-1.20.1"]}' + plugin_dependencies: ${{ inputs.hangar_plugin_dependencies }} diff --git a/.github/workflows/main.prerelease.yml b/.github/workflows/main.prerelease.yml index 2f743fb8..76bc17e1 100644 --- a/.github/workflows/main.prerelease.yml +++ b/.github/workflows/main.prerelease.yml @@ -21,3 +21,4 @@ jobs: target_tag: ${{ needs.github_release_on_push.outputs.tag_name }} upload_modrinth: 'true' upload_dbo: 'false' + upload_hangar: 'true'