Build and release plugin to CurseForge and Modrinth #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and release plugin to CurseForge and Modrinth | |
| on: | |
| push: | |
| tags: | |
| - 'v*' # adjust to your tagging pattern | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| jar-path: ${{ steps.jar.outputs.jar-path }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Build with Maven | |
| run: mvn -B package --file pom.xml | |
| - name: Get JAR file path | |
| id: jar | |
| run: | | |
| JAR_NAME=$(ls target/*.jar | grep -v 'original' | head -n 1) | |
| echo "jar-path=$JAR_NAME" >> $GITHUB_STATE | |
| generate-changelog: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| outputs: | |
| changelog: ${{ steps.changelog.outputs.release-notes }} | |
| release_type: ${{ steps.release-type.outputs.release_type }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Generate Changelog from commits | |
| id: changelog | |
| uses: johnyherangi/create-release-notes@main | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| format: "- {{subject}}" | |
| - name: Determine release type | |
| id: release-type | |
| run: | | |
| TAG_NAME=${GITHUB_REF#refs/tags/} | |
| echo "Tag is: $TAG_NAME" | |
| if echo "$TAG_NAME" | grep -iq "release"; then | |
| echo "release_type=release" >> $GITHUB_STATE | |
| else | |
| echo "release_type=beta" >> $GITHUB_STATE | |
| fi | |
| publish: | |
| runs-on: ubuntu-latest | |
| needs: [build, generate-changelog] | |
| steps: | |
| - name: Upload to CurseForge | |
| uses: itsmeow/curseforge-upload@v3 | |
| with: | |
| token: ${{ secrets.CURSEFORGE_TOKEN }} | |
| project_id: ${{ env.CURSEFORGE_PROJECT_ID }} | |
| game_endpoint: minecraft | |
| file_path: ${{ needs.build.outputs.jar-path }} | |
| changelog: ${{ needs.generate-changelog.outputs.changelog }} | |
| changelog_type: markdown | |
| release_type: ${{ needs.generate-changelog.outputs.release_type }} | |
| - name: Upload to Modrinth | |
| uses: cloudnode-pro/modrinth-publish@v2.1.2 | |
| with: | |
| token: ${{ secrets.MODRINTH_TOKEN }} | |
| project_id: ${{ env.MODRINTH_PROJECT_ID }} | |
| file: ${{ needs.build.outputs.jar-path }} | |
| version_number: ${{ github.ref_name }} | |
| changelog: ${{ needs.generate-changelog.outputs.changelog }} | |
| version_type: ${{ needs.generate-changelog.outputs.release_type }} |