Skip to content

Commit

Permalink
ci: Add modloader specific publish workflows
Browse files Browse the repository at this point in the history
For Modrinth and CurseForge.
  • Loading branch information
Steveplays28 committed May 26, 2024
1 parent 4e87e24 commit e3a9986
Show file tree
Hide file tree
Showing 4 changed files with 340 additions and 0 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/publish-curseforge-fabric.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Publish (CurseForge; Fabric)

on:
workflow_dispatch:

jobs:
build_and_publish:
name: Build and publish
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

steps:
- uses: actions/checkout@v3

- name: Get mod version from Gradle
uses: madhead/read-java-properties@latest
id: mod_version
with:
file: gradle.properties
property: mod_version
default: 0.0.1

- name: Get supported Minecraft version from Gradle
uses: madhead/read-java-properties@latest
id: supported_minecraft_version_name
with:
file: gradle.properties
property: supported_minecraft_version_name
default: 0.0.1

- name: Print version string
run: echo version string ${{ steps.mod_version.outputs.value }}+mc${{ steps.supported_minecraft_version_name.outputs.value }}

- name: Set release tag name environment variable
run: echo release_tag_name=v${{ steps.mod_version.outputs.value }}+mc${{ steps.supported_minecraft_version_name.outputs.value }} >> $GITHUB_ENV

- name: Get existing release
uses: cardinalby/git-get-release-action@v1
id: get_existing_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ env.release_tag_name }}
doNotFailIfNotFound: true

- name: Check if an existing release with the same version exists
if: steps.get_existing_release.outputs.tag_name == env.release_tag_name
run: exit 1

- name: Setup JDK (Temurin 17)
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: gradle

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Change Gradle wrapper permissions
run: chmod +x ./gradlew

- name: Execute Gradle build
run: ./gradlew build

# https://github.com/marketplace/actions/mc-publish
- name: Publish mod (Fabric)
uses: Kir-Antipov/mc-publish@v3.3
with:
# CurseForge
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}

name: ${{ steps.mod_version.outputs.value }} (${{ steps.supported_minecraft_version_name.outputs.value }})
github-tag: ${{ env.release_tag_name }}
files: |
fabric/build/libs/!(*-@(sources|dev-shadow|javadoc|transformProduction*).jar)
fabric/build/libs/*-@(sources|javadoc).jar
version-type: release
modrinth-featured: false
changelog-file: CHANGELOG_LATEST.md
85 changes: 85 additions & 0 deletions .github/workflows/publish-curseforge-neoforge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Publish (CurseForge; NeoForge)

on:
workflow_dispatch:

jobs:
build_and_publish:
name: Build and publish
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

steps:
- uses: actions/checkout@v3

- name: Get mod version from Gradle
uses: madhead/read-java-properties@latest
id: mod_version
with:
file: gradle.properties
property: mod_version
default: 0.0.1

- name: Get supported Minecraft version from Gradle
uses: madhead/read-java-properties@latest
id: supported_minecraft_version_name
with:
file: gradle.properties
property: supported_minecraft_version_name
default: 0.0.1

- name: Print version string
run: echo version string ${{ steps.mod_version.outputs.value }}+mc${{ steps.supported_minecraft_version_name.outputs.value }}

- name: Set release tag name environment variable
run: echo release_tag_name=v${{ steps.mod_version.outputs.value }}+mc${{ steps.supported_minecraft_version_name.outputs.value }} >> $GITHUB_ENV

- name: Get existing release
uses: cardinalby/git-get-release-action@v1
id: get_existing_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ env.release_tag_name }}
doNotFailIfNotFound: true

- name: Check if an existing release with the same version exists
if: steps.get_existing_release.outputs.tag_name == env.release_tag_name
run: exit 1

- name: Setup JDK (Temurin 17)
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: gradle

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Change Gradle wrapper permissions
run: chmod +x ./gradlew

- name: Execute Gradle build
run: ./gradlew build

# https://github.com/marketplace/actions/mc-publish
- name: Publish mod (NeoForge)
uses: Kir-Antipov/mc-publish@v3.3
with:
# CurseForge
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}

name: ${{ steps.mod_version.outputs.value }} (${{ steps.supported_minecraft_version_name.outputs.value }})
github-tag: ${{ env.release_tag_name }}
files: |
neoforge/build/libs/!(*-@(sources|dev-shadow|javadoc|transformProduction*).jar)
neoforge/build/libs/*-@(sources|javadoc).jar
version-type: release
modrinth-featured: false
changelog-file: CHANGELOG_LATEST.md
85 changes: 85 additions & 0 deletions .github/workflows/publish-modrinth-fabric.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Publish (Modrinth; Fabric)

on:
workflow_dispatch:

jobs:
build_and_publish:
name: Build and publish
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

steps:
- uses: actions/checkout@v3

- name: Get mod version from Gradle
uses: madhead/read-java-properties@latest
id: mod_version
with:
file: gradle.properties
property: mod_version
default: 0.0.1

- name: Get supported Minecraft version from Gradle
uses: madhead/read-java-properties@latest
id: supported_minecraft_version_name
with:
file: gradle.properties
property: supported_minecraft_version_name
default: 0.0.1

- name: Print version string
run: echo version string ${{ steps.mod_version.outputs.value }}+mc${{ steps.supported_minecraft_version_name.outputs.value }}

- name: Set release tag name environment variable
run: echo release_tag_name=v${{ steps.mod_version.outputs.value }}+mc${{ steps.supported_minecraft_version_name.outputs.value }} >> $GITHUB_ENV

- name: Get existing release
uses: cardinalby/git-get-release-action@v1
id: get_existing_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: v${{ steps.mod_version.outputs.value }}+mc${{ steps.supported_minecraft_version_name.outputs.value }}
doNotFailIfNotFound: true

- name: Check if an existing release with the same version exists
if: steps.get_existing_release.outputs.tag_name == env.release_tag_name
run: exit 1

- name: Setup JDK (Temurin 17)
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: gradle

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Change Gradle wrapper permissions
run: chmod +x ./gradlew

- name: Execute Gradle build
run: ./gradlew build

# https://github.com/marketplace/actions/mc-publish
- name: Publish mod (Fabric)
uses: Kir-Antipov/mc-publish@v3.3
with:
# Modrinth
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}

name: ${{ steps.mod_version.outputs.value }} (${{ steps.supported_minecraft_version_name.outputs.value }})
github-tag: ${{ env.release_tag_name }}
files: |
fabric/build/libs/!(*-@(sources|dev-shadow|javadoc|transformProduction*).jar)
fabric/build/libs/*-@(sources|javadoc).jar
version-type: release
modrinth-featured: false
changelog-file: CHANGELOG_LATEST.md
85 changes: 85 additions & 0 deletions .github/workflows/publish-modrinth-neoforge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Publish (Modrinth; NeoForge)

on:
workflow_dispatch:

jobs:
build_and_publish:
name: Build and publish
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

steps:
- uses: actions/checkout@v3

- name: Get mod version from Gradle
uses: madhead/read-java-properties@latest
id: mod_version
with:
file: gradle.properties
property: mod_version
default: 0.0.1

- name: Get supported Minecraft version from Gradle
uses: madhead/read-java-properties@latest
id: supported_minecraft_version_name
with:
file: gradle.properties
property: supported_minecraft_version_name
default: 0.0.1

- name: Print version string
run: echo version string ${{ steps.mod_version.outputs.value }}+mc${{ steps.supported_minecraft_version_name.outputs.value }}

- name: Set release tag name environment variable
run: echo release_tag_name=v${{ steps.mod_version.outputs.value }}+mc${{ steps.supported_minecraft_version_name.outputs.value }} >> $GITHUB_ENV

- name: Get existing release
uses: cardinalby/git-get-release-action@v1
id: get_existing_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: v${{ steps.mod_version.outputs.value }}+mc${{ steps.supported_minecraft_version_name.outputs.value }}
doNotFailIfNotFound: true

- name: Check if an existing release with the same version exists
if: steps.get_existing_release.outputs.tag_name == env.release_tag_name
run: exit 1

- name: Setup JDK (Temurin 17)
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: gradle

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Change Gradle wrapper permissions
run: chmod +x ./gradlew

- name: Execute Gradle build
run: ./gradlew build

# https://github.com/marketplace/actions/mc-publish
- name: Publish mod (NeoForge)
uses: Kir-Antipov/mc-publish@v3.3
with:
# Modrinth
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}

name: ${{ steps.mod_version.outputs.value }} (${{ steps.supported_minecraft_version_name.outputs.value }})
github-tag: ${{ env.release_tag_name }}
files: |
neoforge/build/libs/!(*-@(sources|dev-shadow|javadoc|transformProduction*).jar)
neoforge/build/libs/*-@(sources|javadoc).jar
version-type: release
modrinth-featured: false
changelog-file: CHANGELOG_LATEST.md

0 comments on commit e3a9986

Please sign in to comment.