Skip to content

Publish

Publish #36

Workflow file for this run

name: "Publish"
on:
workflow_dispatch:
inputs:
mod_loaders:
description: 'List of mod loaders to be published'
required: true
default: "['fabric', 'forge', 'neoforge']"
type: string
branches:
description: 'List of branches to be published'
required: true
default: "['1.19.2', '1.19.3', '1.19.4', '1.20.1', '1.20.2', '1.20.4', '1.20.6', '1.21']"
type: string
jobs:
publish:
runs-on: ubuntu-latest
name: Publish ${{ matrix.branch }} ${{ matrix.mod_loader }}
timeout-minutes: 60
strategy:
max-parallel: 3
fail-fast: false
matrix:
branch: ${{ fromJson(inputs.branches) }}
mod_loader: ${{ fromJson(inputs.mod_loaders) }}
include:
- mod_loader: "fabric"
supported_mod_loaders: [ "fabric", "quilt" ]
secondary_game_version: ""
curseforge_id: ${{ vars.CURSEFORGE_FABRIC_PROJECT_ID }}
modrinth_id: ${{ vars.MODRINTH_FABRIC_PROJECT_ID }}
- mod_loader: "forge"
supported_mod_loaders: [ "forge" ]
secondary_game_version: ""
curseforge_id: ${{ vars.CURSEFORGE_FORGE_PROJECT_ID }}
modrinth_id: ${{ vars.MODRINTH_FORGE_PROJECT_ID }}
- mod_loader: "neoforge"
supported_mod_loaders: [ "neoforge" ]
secondary_game_version: ""
curseforge_id: ${{ vars.CURSEFORGE_FORGE_PROJECT_ID }}
modrinth_id: ${{ vars.MODRINTH_FORGE_PROJECT_ID }}
steps:
- name: "Checkout repository"
uses: actions/[email protected]
with:
ref: ${{ matrix.branch }}
fetch-depth: 0
- name: "Check if the mod loader is supported"
id: check-mod-loader
run: |
if [ -d ${{ matrix.mod_loader }} ]; then
echo "Mod loader is supported"
echo "is_mod_loader_supported=true" >> $GITHUB_OUTPUT
else
echo "Mod loader is not supported"
echo "is_mod_loader_supported=false" >> $GITHUB_OUTPUT
fi
- name: "Parse gradle properties"
if: steps.check-mod-loader.outputs.is_mod_loader_supported == 'true'
id: gradle-properties
run: |
while IFS='=' read -r key value; do
key=$(echo $key | awk '{$1=$1;print}')
value=$(echo $value | awk '{$1=$1;print}')
case "$key" in
minecraft_version) echo "MINECRAFT_VERSION=$value" >> $GITHUB_OUTPUT ;;
mod_name) echo "MOD_NAME=$value" >> $GITHUB_OUTPUT ;;
mod_version) echo "MOD_VERSION=$value" >> $GITHUB_OUTPUT ;;
esac
done < gradle.properties
- name: "Parse changelog"
if: steps.check-mod-loader.outputs.is_mod_loader_supported == 'true'
id: parse-changelog
run: |
changelog=$(cat CHANGELOG.md)
tag=${{ steps.gradle-properties.outputs.MOD_VERSION }}
list=$(echo "$changelog" | sed -n "/^## $tag/,/^## [0-9]/p" | sed -e '1d;$d' -e '/^$/d')
echo "$list" > RELEASE_CHANGELOG.md
- name: "Create github release"
if: steps.check-mod-loader.outputs.is_mod_loader_supported == 'true'
continue-on-error: true
uses: ncipollo/release-action@v1
with:
skipIfReleaseExists: true
allowUpdates: true
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
tag: mc${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}-${{ steps.gradle-properties.outputs.MOD_VERSION }}
name: ${{ steps.gradle-properties.outputs.MOD_NAME }} ${{ steps.gradle-properties.outputs.MOD_VERSION }} for Minecraft ${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}
bodyFile: RELEASE_CHANGELOG.md
- name: "Set up JDK 17"
if: steps.check-mod-loader.outputs.is_mod_loader_supported == 'true' && steps.gradle-properties.outputs.MINECRAFT_VERSION != '1.20.6' && steps.gradle-properties.outputs.MINECRAFT_VERSION != '1.21'
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: "Set up JDK 21"
if: steps.check-mod-loader.outputs.is_mod_loader_supported == 'true' && steps.gradle-properties.outputs.MINECRAFT_VERSION == '1.20.6' || steps.gradle-properties.outputs.MINECRAFT_VERSION == '1.21'
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
- name: "Setup gradle and run build"
if: steps.check-mod-loader.outputs.is_mod_loader_supported == 'true'
uses: gradle/[email protected]
with:
cache-read-only: true
generate-job-summary: false
gradle-version: wrapper
arguments: ${{ matrix.mod_loader }}:build
- name: Publish ${{ matrix.mod_loader }}
if: steps.check-mod-loader.outputs.is_mod_loader_supported == 'true'
uses: Kir-Antipov/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
github-tag: mc${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}-${{ steps.gradle-properties.outputs.MOD_VERSION }}
github-commitish: ${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}
curseforge-id: ${{ matrix.curseforge_id }}
curseforge-token: ${{ secrets.CURSEFORGE_RELEASE_TOKEN }}
modrinth-id: ${{ matrix.modrinth_id }}
modrinth-featured: true
modrinth-token: ${{ secrets.MODRINTH_RELEASE_TOKEN }}
name: ${{ steps.gradle-properties.outputs.MOD_NAME }} ${{ steps.gradle-properties.outputs.MOD_VERSION }}
version: ${{ matrix.mod_loader }}-mc${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}-${{ steps.gradle-properties.outputs.MOD_VERSION }}
loaders: ${{ join(matrix.supported_mod_loaders, ' ') }}
game-versions: "${{ matrix.branch }}\n${{ matrix.secondary_game_version }}"
changelog-file: RELEASE_CHANGELOG.md
files: |
${{ matrix.mod_loader }}/build/libs/!(*-@(dev|dev-shadow|sources|javadoc)).jar
clear-cache:
needs: publish
runs-on: ubuntu-latest
name: "Clear cache"
timeout-minutes: 60
steps:
- uses: MyAlbum/purge-cache@v2
with:
accessed: true
created: true
max-age: 21600