Skip to content

Updated upload workflow to provide summaries #46

Updated upload workflow to provide summaries

Updated upload workflow to provide summaries #46

Workflow file for this run

# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Build and Uploading
on:
push:
branches:
- main
jobs:
check-commit:
runs-on: ubuntu-latest
steps:
- name: "Checking out"
uses: actions/checkout@v3
- name: "List files"
run: ls -R
- name: "Match commit message"
id: match
uses: kaisugi/[email protected]
with:
text: ${{ github.event.head_commit.message }}
regex: '[bB]ump.*?(\d+(\.\d+)*)'
- name: "Exit if no match"
if: ${{ steps.match.outputs.group1 == '' }}
run: |
echo 'Not a new version.' > $GITHUB_STEP_SUMMARY
exit 1
- name: "Extract changelog"
id: extract-changelog
uses: sean0x42/markdown-extract@v2
with:
file: CHANGELOG.md
pattern: ${{ steps.match.outputs.group1 }}
- name: "Summary"
run: |
echo '# Version' >> $GITHUB_STEP_SUMMARY
echo '## Changelog' >> $GITHUB_STEP_SUMMARY
echo '${{ steps.extract-changelog.outputs.markdown }}' >> $GITHUB_STEP_SUMMARY
outputs:
new_ver: ${{ steps.match.outputs.group1 }}
changelog: ${{ steps.extract-changelog.outputs.markdown }}
build:
needs:
- check-commit
runs-on: ubuntu-latest
if: ${{ needs.check-commit.outputs.new_ver != '' }}
steps:
- name: "Display version"
run: echo 'Compiling for version ${{ needs.check-commit.outputs.new_ver }}'
- name: "Checking out"
uses: actions/checkout@v3
- name: "Set up java"
uses: actions/setup-java@v3
with:
distribution: 'corretto' # See 'Supported distributions' for available options
java-version: '17'
cache: maven
- name: "Build the jar"
run: mvn --batch-mode --update-snapshots verify
- name: "Upload artifact"
uses: actions/upload-artifact@v3
with:
name: ${{ needs.check-commit.outputs.new_ver }}
path: |
**/*.jar
!**/original-*.jar
release:
needs:
- check-commit
- build
runs-on: ubuntu-latest
if: ${{ needs.check-commit.outputs.new_ver != '' }}
steps:
- uses: mukunku/[email protected]
id: check_exists
with:
tag: v${{ needs.check-commit.outputs.new_ver }}
- name: "Exit if release exists"
run: exit 1
if: steps.check_exists.outputs.exists == 'true'
- name: "Downloading built jar"
uses: actions/download-artifact@v3
with:
name: ${{ needs.check-commit.outputs.new_ver }}
- name: "Display structure of downloaded files"
run: ls -R
- name: "Create Release"
id: create_release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
tag_name: v${{ needs.check-commit.outputs.new_ver }}
name: Release v${{ needs.check-commit.outputs.new_ver }}
body: ${{ needs.check-commit.outputs.changelog }}
draft: false
prerelease: false
files: './target/*.jar'
fail_on_unmatched_files: true
- name: "Summary"
run: |
echo '## GitHub Release' >> $GITHUB_STEP_SUMMARY
echo 'Release can be found at ${{ steps.create_release.outputs.url }}'
upload-curseforge:
needs:
- check-commit
- build
runs-on: ubuntu-latest
if: ${{ needs.check-commit.outputs.new_ver != '' }}
steps:
- name: "Downloading built jar"
uses: actions/download-artifact@v3
with:
name: ${{ needs.check-commit.outputs.new_ver }}
- name: "Display structure of downloaded files"
run: ls -R
- id: find_jar
run: JAR_LOC="$(find * -name '*.jar')" && echo "jar_loc=$JAR_LOC" >> $GITHUB_OUTPUT
- name: "Upload to CurseForge"
uses: itsmeow/[email protected]
with:
token: ${{ secrets.CURSEFORGE_TOKEN }}
project_id: 933999
game_endpoint: "minecraft"
file_path: ${{ steps.find_jar.outputs.jar_loc }}
changelog: ${{ needs.check-commit.outputs.changelog }}
game_versions: 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,1.20.2
upload-modrinth:
needs:
- check-commit
- build
runs-on: ubuntu-latest
if: ${{ needs.check-commit.outputs.new_ver != '' }}
steps:
- name: "Downloading built jar"
uses: actions/download-artifact@v3
with:
name: ${{ needs.check-commit.outputs.new_ver }}
- name: "Display structure of downloaded files"
run: ls -R
- id: find_jar
run: JAR_LOC="$(find * -name '*.jar')" && echo "jar_loc=$JAR_LOC" >> $GITHUB_OUTPUT
- name: "Upload to Modrinth"
uses: RubixDev/modrinth-upload@v1
id: upload
with:
token: ${{ secrets.MODRINTH_TOKEN }}
file_path: ${{ steps.find_jar.outputs.jar_loc }}
name: Release v${{ needs.check-commit.outputs.new_ver }}
version: ${{ needs.check-commit.outputs.new_ver }}
changelog: ${{ needs.check-commit.outputs.changelog }}
game_versions: 1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,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,1.20.2
release_type: release
loaders: bukkit,spigot,paper
featured: true
project_id: XOp04Yi2
- name: "Summary"
run: |
echo '## Modrinth Release' >> $GITHUB_STEP_SUMMARY
echo 'Release can be found at https://modrinth.com/plugin/${{ steps.upload.with.project_id }}/version/${{ steps.upload.outputs.id }}' >> $GITHUB_STEP_SUMMARY