Skip to content

Commit

Permalink
Merge pull request #2960 from Multiverse/revamp-actions
Browse files Browse the repository at this point in the history
feat: Revamp github actions workflow
  • Loading branch information
dumptruckman authored Aug 22, 2023
2 parents 3f5a17e + b1c0e94 commit f592673
Show file tree
Hide file tree
Showing 11 changed files with 264 additions and 312 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/call.github_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: 'Call: GitHub Release'

on:
workflow_call:
inputs:
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/[email protected]
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 }}
92 changes: 92 additions & 0 deletions .github/workflows/call.platform_uploads.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: 'Call: Platform Uploads'

on:
workflow_call:
inputs:
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
secrets:
MODRINTH_TOKEN:
required: true
DBO_UPLOAD_API_TOKEN:
required: true

jobs:
platform_uploads:
runs-on: ubuntu-latest
steps:
- name: Get release info
id: release-info
uses: cardinalby/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ inputs.target_tag }}

- name: Download release artifact
id: release-artifact
uses: dsaltares/[email protected]
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
run: |
if [[ "${{ steps.release-info.outputs.prerelease }}" == "true" ]]; then
echo Setting RELEASE_TYPE to Beta
echo "RELEASE_TYPE=Beta" >> $GITHUB_ENV
else
echo Setting RELEASE_TYPE to Release
echo "RELEASE_TYPE=Release" >> $GITHUB_ENV
fi
- name: echo inputs
run: |
echo "upload_modrinth: ${{ inputs.upload_modrinth }}"
echo "upload_dbo: ${{ inputs.upload_dbo }}"
echo "RELEASE_TYPE: ${{ env.RELEASE_TYPE }}"
- name: Upload to Modrinth
if: inputs.upload_modrinth == 'true'
uses: benwoo1110/[email protected]
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: ${{ env.RELEASE_TYPE }}
loaders: bukkit, spigot, paper

- name: Upload to DBO
if: inputs.upload_dbo == 'true'
uses: benwoo1110/[email protected]
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: ${{ env.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
55 changes: 0 additions & 55 deletions .github/workflows/dbo_upload.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/dispatch.platform_uploads.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Dispatch: Platform Uploads'

on:
workflow_dispatch:
inputs:
target_tag:
description: 'Version to upload'
required: true
type: string
upload_modrinth:
description: 'Upload to modrinth.com'
required: true
type: boolean
upload_dbo:
description: 'Upload to dev.bukkit.org'
required: true
type: boolean

jobs:
dispatch_platform_uploads:
uses: ./.github/workflows/call.platform_uploads.yml
secrets: inherit
with:
target_tag: ${{ github.event.inputs.target_tag }}
upload_modrinth: ${{ github.event.inputs.upload_modrinth }}
upload_dbo: ${{ github.event.inputs.upload_dbo }}
37 changes: 37 additions & 0 deletions .github/workflows/dispatch.promote_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 'Dispatch: Promote Release'

on:
workflow_dispatch:
inputs:
target_tag:
description: 'Version to promote'
required: true

jobs:
check_version:
runs-on: ubuntu-latest
steps:
- name: Verify input version is prerelease
run: |
if [[ "${{ github.event.inputs.target_tag }}" != *"pre"* ]]; then
echo "Version must be a prerelease"
exit 1
fi
github_release:
needs: check_version
uses: ./.github/workflows/call.github_release.yml
secrets: inherit
with:
release_mode: promote
promote_from: ${{ github.event.inputs.target_tag }}

platform_uploads:
needs: github_release
if: needs.github_release.outputs.release_created == 'true'
uses: ./.github/workflows/call.platform_uploads.yml
secrets: inherit
with:
target_tag: ${{ needs.github_release.outputs.tag_name }}
upload_modrinth: 'true'
upload_dbo: 'true'
23 changes: 23 additions & 0 deletions .github/workflows/main.prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'Main: Prerelease'

on:
push:
branches: [main]

jobs:
github_release_on_push:
uses: ./.github/workflows/call.github_release.yml
secrets: inherit
with:
release_mode: prerelease
version_bump: prlabel

platform_uploads_on_push:
needs: github_release_on_push
if: needs.github_release_on_push.outputs.release_created == 'true'
uses: ./.github/workflows/call.platform_uploads.yml
secrets: inherit
with:
target_tag: ${{ needs.github_release_on_push.outputs.tag_name }}
upload_modrinth: 'true'
upload_dbo: 'false'
53 changes: 0 additions & 53 deletions .github/workflows/modrinth_upload.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Require PR Labels
name: 'PR: Require Label'

on:
pull_request:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run unit tests against all PRs
name: 'PR: Test'

on:
pull_request:
Expand Down
Loading

0 comments on commit f592673

Please sign in to comment.