|
| 1 | +name: Release on tag |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' |
| 7 | + |
| 8 | +env: |
| 9 | + JAVA_VERSION: 17 |
| 10 | + MODRINTH_ID: 'T9FDHbY5' |
| 11 | + CURSEFORGE_ID: '484738' |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Check out source code |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Validate Gradle wrapper |
| 21 | + uses: gradle/wrapper-validation-action@v1 |
| 22 | + |
| 23 | + - name: Setup JDK |
| 24 | + uses: actions/setup-java@v4 |
| 25 | + with: |
| 26 | + distribution: 'temurin' |
| 27 | + java-version: '${{env.JAVA_VERSION}}' |
| 28 | + |
| 29 | + - name: Setup Gradle |
| 30 | + uses: gradle/gradle-build-action@v2 |
| 31 | + |
| 32 | + - name: Build with Gradle |
| 33 | + run: gradle build |
| 34 | + |
| 35 | + - name: Get version numbers from tag |
| 36 | + id: version |
| 37 | + run: | |
| 38 | + # Extract mod and minecraft version from tag |
| 39 | + mod_version=${GITHUB_REF_NAME//@(*v|+*)} |
| 40 | + minecraft_version=${GITHUB_REF_NAME#*+} |
| 41 | + echo "mod=$mod_version" >> $GITHUB_OUTPUT |
| 42 | + echo "minecraft=$minecraft_version" >> $GITHUB_OUTPUT |
| 43 | + echo "full=$mod_version+$minecraft_version" >> $GITHUB_OUTPUT |
| 44 | + echo Mod version: $mod_version |
| 45 | + echo Minecraft version: $minecraft_version |
| 46 | +
|
| 47 | + - name: Install parse-changelog |
| 48 | + uses: taiki-e/install-action@v2 |
| 49 | + with: |
| 50 | + tool: parse-changelog |
| 51 | + |
| 52 | + - name: Parse changelog |
| 53 | + id: changelog |
| 54 | + run: | |
| 55 | + # Extract the changelog entry for this release |
| 56 | + mkdir -p output |
| 57 | + changelog=output/changelog.md |
| 58 | + parse-changelog CHANGELOG.md ${{ steps.version.outputs.full }} > $changelog |
| 59 | + if [[ ! -s $changelog ]]; then |
| 60 | + # No changelog for specific version (mod+minecraft), try just mod version |
| 61 | + parse-changelog CHANGELOG.md ${{ steps.version.outputs.mod }} > $changelog |
| 62 | + fi |
| 63 | + echo Extracted changelog for this release: |
| 64 | + cat $changelog |
| 65 | + echo "file=$changelog" >> $GITHUB_OUTPUT |
| 66 | +
|
| 67 | + - name: Publish release |
| 68 | + id: publish |
| 69 | + uses: Kir-Antipov/[email protected] |
| 70 | + with: |
| 71 | + modrinth-id: ${{ env.MODRINTH_ID }} |
| 72 | + curseforge-id: ${{ env.CURSEFORGE_ID }} |
| 73 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} |
| 75 | + curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} |
| 76 | + name: Status Effect Timer ${{ steps.version.outputs.full }} |
| 77 | + version: ${{ steps.version.outputs.full }} |
| 78 | + version-type: release |
| 79 | + changelog-file: ${{ steps.changelog.outputs.file }} |
| 80 | + |
| 81 | + - name: Show results |
| 82 | + run: | |
| 83 | + # Show results from mc-publish |
| 84 | + echo Successfully published Status Effect Timer ${{ steps.version.outputs.full }} |
| 85 | + echo Modrinth release ${{ steps.publish.outputs.modrinth-version }}: ${{ steps.publish.outputs.modrinth-url }} |
| 86 | + echo CurseForge release ${{ steps.publish.outputs.curseforge-version }}: ${{ steps.publish.outputs.curseforge-url }} |
| 87 | + echo GitHub release ${{ steps.publish.outputs.github-tag }}: ${{ steps.publish.outputs.github-url }} |
0 commit comments