1- name : Publish to Modrinth
1+ name : Release
22on :
3- push :
4- tags :
5- - v*
3+ release :
4+ types : [ prereleased, released ]
65
76jobs :
8- build :
9- strategy :
10- matrix :
11- java : [
12- 16
13- ]
14- os : [ ubuntu-latest ]
15- runs-on : ${{ matrix.os }}
7+
8+ # Prepare and publish the plugin to the Marketplace repository
9+ release :
10+ name : Publish Plugin
11+ runs-on : ubuntu-latest
1612 steps :
17- - name : checkout repository
18- uses : actions/checkout@v2
19- - name : validate gradle wrapper
20- uses : gradle/wrapper-validation-action@v1
21- - name : setup jdk ${{ matrix.java }}
22- uses : actions/setup-java@v1
13+
14+ # Check out current repository
15+ - name : Fetch Sources
16+ uses : actions/checkout@v2.4.0
17+ with :
18+ ref : ${{ github.event.release.tag_name }}
19+
20+ # Setup Java 11 environment for the next steps
21+ - name : Setup Java
22+ uses : actions/setup-java@v2
2323 with :
24- java-version : ${{ matrix.java }}
25- - name : make gradle wrapper executable
26- run : chmod +x ./gradlew
27- - name : build
28- run : ./gradlew build
29- - name : Publish artifacts to Modrinth
24+ distribution : zulu
25+ java-version : 17
26+ cache : gradle
27+
28+ # Set environment variables
29+ - name : Export Properties
30+ id : properties
31+ shell : bash
32+ run : |
33+ CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d'
34+ ${{ github.event.release.body }}
35+ EOM
36+ )"
37+
38+ CHANGELOG="${CHANGELOG//'%'/'%25'}"
39+ CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
40+ CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
41+ echo "::set-output name=changelog::$CHANGELOG"
42+ # Update Unreleased section with the current release note
43+ - name : Patch Changelog
44+ if : ${{ steps.properties.outputs.changelog != '' }}
45+ env :
46+ CHANGELOG : ${{ steps.properties.outputs.changelog }}
47+ run : |
48+ ./gradlew patchChangelog --release-note="$CHANGELOG"
49+ # Publish the mod to Modrinth
50+ - name : Publish Plugin
51+ env :
52+ MODRINTH : ${{ secrets.MODRINTH }}
3053 run : ./gradlew publishModrinth
54+
55+ # Upload artifact as a release asset
56+ - name : Upload Release Asset
57+ env :
58+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
59+ run : gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
60+
61+ # Create pull request
62+ - name : Create Pull Request
63+ if : ${{ steps.properties.outputs.changelog != '' }}
64+ env :
65+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
66+ run : |
67+ VERSION="${{ github.event.release.tag_name }}"
68+ BRANCH="changelog-update-$VERSION"
69+ git config user.email "action@github.com"
70+ git config user.name "GitHub Action"
71+ git checkout -b $BRANCH
72+ git commit -am "Changelog update - $VERSION"
73+ git push --set-upstream origin $BRANCH
74+ gh pr create \
75+ --title "Changelog update - \`$VERSION\`" \
76+ --body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
77+ --base main \
78+ --head $BRANCH
0 commit comments