Skip to content

Commit f592673

Browse files
authored
Merge pull request #2960 from Multiverse/revamp-actions
feat: Revamp github actions workflow
2 parents 3f5a17e + b1c0e94 commit f592673

11 files changed

+264
-312
lines changed
+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: 'Call: GitHub Release'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
release_mode:
7+
description: 'Release mode'
8+
required: true
9+
type: string
10+
version_bump:
11+
description: 'Version bump'
12+
required: false
13+
type: string
14+
promote_from:
15+
description: 'Promote from'
16+
required: false
17+
type: string
18+
outputs:
19+
release_created:
20+
description: 'Release created'
21+
value: ${{ jobs.github_release.outputs.release_created }}
22+
tag_name:
23+
description: 'Tag name'
24+
value: ${{ jobs.github_release.outputs.tag_name }}
25+
26+
jobs:
27+
github_release:
28+
runs-on: ubuntu-latest
29+
outputs:
30+
release_created: ${{ steps.release.outputs.release_created }}
31+
tag_name: ${{ steps.release.outputs.tag_name }}
32+
steps:
33+
- name: Echo inputs
34+
run: |
35+
echo "release_mode: ${{ inputs.release_mode }}"
36+
echo "version_bump: ${{ inputs.version_bump }}"
37+
echo "promote_from: ${{ inputs.promote_from }}"
38+
39+
- uses: actions/checkout@v3
40+
with:
41+
ref: ${{ inputs.promote_from }}
42+
43+
- uses: actions/setup-java@v3
44+
with:
45+
java-version: '11'
46+
distribution: 'adopt'
47+
cache: gradle
48+
49+
- name: Validate Gradle wrapper
50+
uses: gradle/wrapper-validation-action@v1
51+
52+
- name: Build and test
53+
uses: gradle/gradle-build-action@v2
54+
with:
55+
arguments: clean build -x assemble -x shadowJar -x checkStyleMain -x checkStyleTest
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
59+
- name: Create release
60+
id: release
61+
uses: benwoo1110/[email protected]
62+
with:
63+
github_token: ${{ secrets.GITHUB_TOKEN }}
64+
release_mode: ${{ inputs.release_mode }}
65+
version_bump: ${{ inputs.version_bump }}
66+
promote_from: ${{ inputs.promote_from }}
67+
68+
- name: Publish package
69+
if: steps.release.outputs.release_created == 'true'
70+
uses: gradle/gradle-build-action@v2
71+
with:
72+
arguments: publish -x checkStyleMain -x checkStyleTest -x test
73+
env:
74+
GITHUB_VERSION: ${{ steps.release.outputs.publish_version }}
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
77+
- name: Upload release artifact
78+
if: steps.release.outputs.release_created == 'true'
79+
uses: svenstaro/upload-release-action@v2
80+
with:
81+
repo_token: ${{ secrets.GITHUB_TOKEN }}
82+
file: build/libs/multiverse-core-${{ steps.release.outputs.publish_version }}.jar
83+
asset_name: multiverse-core-${{ steps.release.outputs.tag_name }}.jar
84+
tag: ${{ steps.release.outputs.tag_name }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: 'Call: Platform Uploads'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
target_tag:
7+
description: 'Version to upload'
8+
required: true
9+
type: string
10+
upload_modrinth:
11+
description: 'Upload to modrinth.com'
12+
required: true
13+
type: string
14+
upload_dbo:
15+
description: 'Upload to dev.bukkit.org'
16+
required: true
17+
type: string
18+
secrets:
19+
MODRINTH_TOKEN:
20+
required: true
21+
DBO_UPLOAD_API_TOKEN:
22+
required: true
23+
24+
jobs:
25+
platform_uploads:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Get release info
29+
id: release-info
30+
uses: cardinalby/[email protected]
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
with:
34+
tag: ${{ inputs.target_tag }}
35+
36+
- name: Download release artifact
37+
id: release-artifact
38+
uses: dsaltares/[email protected]
39+
with:
40+
token: ${{ secrets.GITHUB_TOKEN }}
41+
version: tags/${{ steps.release-info.outputs.tag_name }}
42+
file: multiverse-core-${{ steps.release-info.outputs.tag_name }}.jar
43+
44+
- name: Parse release type
45+
run: |
46+
if [[ "${{ steps.release-info.outputs.prerelease }}" == "true" ]]; then
47+
echo Setting RELEASE_TYPE to Beta
48+
echo "RELEASE_TYPE=Beta" >> $GITHUB_ENV
49+
else
50+
echo Setting RELEASE_TYPE to Release
51+
echo "RELEASE_TYPE=Release" >> $GITHUB_ENV
52+
fi
53+
54+
- name: echo inputs
55+
run: |
56+
echo "upload_modrinth: ${{ inputs.upload_modrinth }}"
57+
echo "upload_dbo: ${{ inputs.upload_dbo }}"
58+
echo "RELEASE_TYPE: ${{ env.RELEASE_TYPE }}"
59+
60+
- name: Upload to Modrinth
61+
if: inputs.upload_modrinth == 'true'
62+
uses: benwoo1110/[email protected]
63+
with:
64+
api_token: ${{ secrets.MODRINTH_TOKEN }}
65+
project_id: 3wmN97b8
66+
version_number: ${{ steps.release-info.outputs.tag_name }}
67+
files: '["${{ github.workspace }}/multiverse-core-${{ steps.release-info.outputs.tag_name }}.jar"]'
68+
name: ${{ steps.release-info.outputs.tag_name }}
69+
changelog: ${{ steps.release-artifact.outputs.body }}
70+
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
71+
version_type: ${{ env.RELEASE_TYPE }}
72+
loaders: bukkit, spigot, paper
73+
74+
- name: Upload to DBO
75+
if: inputs.upload_dbo == 'true'
76+
uses: benwoo1110/[email protected]
77+
with:
78+
api_token: ${{ secrets.DBO_UPLOAD_API_TOKEN }}
79+
project_id: 30765
80+
changelog: ${{ steps.release-artifact.outputs.body }}
81+
changelog_type: markdown
82+
display_name: ${{ steps.release-info.outputs.tag_name }}
83+
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
84+
release_type: ${{ env.RELEASE_TYPE }}
85+
project_relations: >
86+
[
87+
{"slug": "multiverse-portals", "type": "optionalDependency"},
88+
{"slug": "multiverse-netherportals", "type": "optionalDependency"},
89+
{"slug": "multiverse-signportals", "type": "optionalDependency"},
90+
{"slug": "multiverse-inventories", "type": "optionalDependency"}
91+
]
92+
file_path: ${{ github.workspace }}/multiverse-core-${{ steps.release-info.outputs.tag_name }}.jar

.github/workflows/dbo_upload.yml

-55
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: 'Dispatch: Platform Uploads'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
target_tag:
7+
description: 'Version to upload'
8+
required: true
9+
type: string
10+
upload_modrinth:
11+
description: 'Upload to modrinth.com'
12+
required: true
13+
type: boolean
14+
upload_dbo:
15+
description: 'Upload to dev.bukkit.org'
16+
required: true
17+
type: boolean
18+
19+
jobs:
20+
dispatch_platform_uploads:
21+
uses: ./.github/workflows/call.platform_uploads.yml
22+
secrets: inherit
23+
with:
24+
target_tag: ${{ github.event.inputs.target_tag }}
25+
upload_modrinth: ${{ github.event.inputs.upload_modrinth }}
26+
upload_dbo: ${{ github.event.inputs.upload_dbo }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: 'Dispatch: Promote Release'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
target_tag:
7+
description: 'Version to promote'
8+
required: true
9+
10+
jobs:
11+
check_version:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Verify input version is prerelease
15+
run: |
16+
if [[ "${{ github.event.inputs.target_tag }}" != *"pre"* ]]; then
17+
echo "Version must be a prerelease"
18+
exit 1
19+
fi
20+
21+
github_release:
22+
needs: check_version
23+
uses: ./.github/workflows/call.github_release.yml
24+
secrets: inherit
25+
with:
26+
release_mode: promote
27+
promote_from: ${{ github.event.inputs.target_tag }}
28+
29+
platform_uploads:
30+
needs: github_release
31+
if: needs.github_release.outputs.release_created == 'true'
32+
uses: ./.github/workflows/call.platform_uploads.yml
33+
secrets: inherit
34+
with:
35+
target_tag: ${{ needs.github_release.outputs.tag_name }}
36+
upload_modrinth: 'true'
37+
upload_dbo: 'true'

.github/workflows/main.prerelease.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: 'Main: Prerelease'
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
github_release_on_push:
9+
uses: ./.github/workflows/call.github_release.yml
10+
secrets: inherit
11+
with:
12+
release_mode: prerelease
13+
version_bump: prlabel
14+
15+
platform_uploads_on_push:
16+
needs: github_release_on_push
17+
if: needs.github_release_on_push.outputs.release_created == 'true'
18+
uses: ./.github/workflows/call.platform_uploads.yml
19+
secrets: inherit
20+
with:
21+
target_tag: ${{ needs.github_release_on_push.outputs.tag_name }}
22+
upload_modrinth: 'true'
23+
upload_dbo: 'false'

.github/workflows/modrinth_upload.yml

-53
This file was deleted.

.github/workflows/require_label.yml renamed to .github/workflows/pr.require_label.yml

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

33
on:
44
pull_request:

.github/workflows/test.yml renamed to .github/workflows/pr.test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run unit tests against all PRs
1+
name: 'PR: Test'
22

33
on:
44
pull_request:

0 commit comments

Comments
 (0)