feat: Revamp github actions workflow

This commit is contained in:
Ben Woo 2023-08-22 21:35:10 +08:00
parent 3f5a17e39a
commit 61254bfccb
No known key found for this signature in database
GPG Key ID: FB2A3645536E12C8
11 changed files with 264 additions and 312 deletions

View File

@ -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
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
id: release
uses: benwoo1110/semantic-release-action@v1.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_mode: ${{ inputs.release_mode }}
version_bump: ${{ inputs.version_bump }}
promote_from: ${{ inputs.promote_from }}
- name: Build package # change to publish
if: steps.release.outputs.release_created == 'true'
uses: gradle/gradle-build-action@v2
with:
arguments: build -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 }}

View File

@ -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/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: 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/modrinth-upload-action@v1.0.0
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/dbo-upload-action@v1.0.1
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

View File

@ -1,55 +0,0 @@
name: Manually upload specific release to dev.bukkit.org
on:
workflow_dispatch:
inputs:
version:
description: 'Release to upload'
required: true
jobs:
manually_upload_dbo_release:
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: ${{ github.event.inputs.version }}
- 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
run: |
if [[ "${{ steps.release-info.outputs.prerelease }}" == "true" ]]; then
echo "RELEASE_TYPE=beta" >> $GITHUB_ENV
else
echo "RELEASE_TYPE=release" >> $GITHUB_ENV
fi
- name: Upload to dev.bukkit.org
uses: benwoo1110/dbo-upload-action@v0.1.0
with:
api_token: ${{ secrets.DBO_UPLOAD_API_TOKEN }}
project_id: 30765
changelog: ${{ steps.release-info.outputs.body }}
changelog_type: markdown
display_name: ${{ steps.release-artifact.outputs.version }}
game_versions: 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.18.1, 1.18.2, 1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.20, 1.20.1
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-artifact.outputs.version }}.jar

View File

@ -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 }}

View File

@ -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
.github/workflows/main.prerelease.yml vendored Normal file
View File

@ -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: patch # change to 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'

View File

@ -1,53 +0,0 @@
name: Manually upload specific release to modrinth.com
on:
workflow_dispatch:
inputs:
version:
description: 'Release to upload'
required: true
jobs:
manually_upload_modrinth_release:
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: ${{ github.event.inputs.version }}
- name: Modify version scheme
run: |
if [[ "${{ steps.release-info.outputs.tag_name }}" == *"pre"* ]]; then
echo "Replacing prerelease version scheme with SNAPSHOT"
echo "VERSION=$(echo ${{ steps.release-info.outputs.tag_name }} | sed -E 's/-pre.*/-SNAPSHOT/')" >> $GITHUB_ENV
else
echo "Using release version scheme"
echo "VERSION=${{ steps.release-info.outputs.tag_name }}" >> $GITHUB_ENV
fi
- name: Parse release type
run: |
if [[ "${{ steps.release-info.outputs.prerelease }}" == "true" ]]; then
echo "RELEASE_TYPE=beta" >> $GITHUB_ENV
else
echo "RELEASE_TYPE=release" >> $GITHUB_ENV
fi
- uses: actions/checkout@v3
with:
ref: ${{ steps.release-info.outputs.tag_name }}
- name: Upload to modrinth.com
uses: gradle/gradle-build-action@v2
with:
arguments: build modrinth
env:
GITHUB_VERSION: ${{ env.VERSION }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
CHANGELOG: ${{ steps.release-info.outputs.body }}
VERSION_NUMBER: ${{ steps.release-info.outputs.tag_name }}
VERSION_TYPE: ${{ env.RELEASE_TYPE }}

View File

@ -1,4 +1,4 @@
name: Require PR Labels name: 'PR: Require Label'
on: on:
pull_request: pull_request:

View File

@ -1,4 +1,4 @@
name: Run unit tests against all PRs name: 'PR: Test'
on: on:
pull_request: pull_request:

View File

@ -1,109 +0,0 @@
name: Manually promote prerelease to release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to promote'
required: true
jobs:
manually_promote_release:
runs-on: ubuntu-latest
steps:
- name: Verify input version is prerelease
run: |
if [[ "${{ github.event.inputs.version }}" != *"pre"* ]]; then
echo "Version must be a prerelease"
exit 1
fi
- name: Get release info
id: get-release
uses: cardinalby/git-get-release-action@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag: ${{ github.event.inputs.version }}
- uses: actions/checkout@v3
with:
ref: ${{ steps.get-release.outputs.tag_name }}
- 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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
id: release
uses: benwoo1110/semantic-release-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_mode: promote
promote_from: ${{ github.event.inputs.version }}
- name: Publish package
uses: gradle/gradle-build-action@v2
with:
arguments: publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_VERSION: ${{ steps.release.outputs.publish_version }}
- name: Upload release artifact
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 }}
- 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.outputs.tag_name }}
file: multiverse-core-${{ steps.release.outputs.tag_name }}.jar
- name: Upload to modrinth.com
uses: gradle/gradle-build-action@v2
with:
arguments: build modrinth
env:
GITHUB_VERSION: ${{ steps.release.outputs.publish_version }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
CHANGELOG: ${{ steps.release.outputs.body }}
VERSION_NUMBER: ${{ steps.release.outputs.tag_name }}
VERSION_TYPE: ${{ steps.release.outputs.release_type }}
- name: Upload to dev.bukkit.org
uses: benwoo1110/dbo-upload-action@v0.2.0
with:
api_token: ${{ secrets.DBO_UPLOAD_API_TOKEN }}
project_id: 30765
changelog: ${{ steps.release.outputs.body }}
changelog_type: markdown
display_name: ${{ steps.release.outputs.tag_name }}
game_versions: 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.18.1, 1.18.2, 1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.20, 1.20.1
release_type: ${{ steps.release.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.outputs.tag_name }}.jar

View File

@ -1,93 +0,0 @@
name: Create Release Version & Publish Package
on:
push:
branches: [main]
jobs:
release_on_push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
id: release
uses: benwoo1110/semantic-release-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
version_bump: prlabel
release_mode: prerelease
- name: Publish package
if: steps.release.outputs.release_created == 'true'
uses: gradle/gradle-build-action@v2
with:
arguments: publish
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 }}
- name: Download release artifact
if: steps.release.outputs.release_created == 'true'
uses: dsaltares/fetch-gh-release-asset@1.1.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: tags/${{ steps.release.outputs.tag_name }}
file: multiverse-core-${{ steps.release.outputs.tag_name }}.jar
- name: Upload to modrinth.com
if: steps.release.outputs.release_created == 'true'
uses: gradle/gradle-build-action@v2
with:
arguments: build modrinth -x checkstyleMain -x checkstyleTest
env:
GITHUB_VERSION: ${{ steps.release.outputs.publish_version }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
CHANGELOG: ${{ steps.release.outputs.body }}
VERSION_NUMBER: ${{ steps.release.outputs.tag_name }}
VERSION_TYPE: ${{ steps.release.outputs.release_type }}
- name: Upload to dev.bukkit.org
if: steps.release.outputs.release_created == 'true'
uses: benwoo1110/dbo-upload-action@v0.2.0
with:
api_token: ${{ secrets.DBO_UPLOAD_API_TOKEN }}
project_id: 30765
changelog: ${{ steps.release.outputs.body }}
changelog_type: markdown
display_name: ${{ steps.release.outputs.tag_name }}
game_versions: 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.18.1, 1.18.2, 1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.20, 1.20.1
release_type: ${{ steps.release.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.outputs.tag_name }}.jar