Skip to content

Publish Project

Publish Project #70

Workflow file for this run

# Publishes the project to GitHub Releases, CurseForge, and Modrinth
name: Publish Project
on:
workflow_dispatch:
inputs:
version:
description: 'Mod version'
required: true
release_type:
description: 'Release type'
type: choice
default: 'beta'
options:
- 'release'
- 'beta'
- 'alpha'
env:
# link to the changelog with a format code for the version
CHANGELOG_LOCATION: "Changelog is available [here](https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }})"
# Version of the mod
FULL_VERSION: "${{ github.event.inputs.version }}-${{ github.event.inputs.release_type }}"
# type of release
NAME: "GTExpertCore"
# Curseforge and Modrinth project IDs
CURSEFORGE_PROJECT_ID: "851103"
MODRINTH_PROJECT_ID: "ipueNiWG"
concurrency:
group: publish-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Check if tag already exists
run: |
if git rev-parse --verify --quiet "v${{ github.event.inputs.version }}"; then
echo "Version ${{ github.event.inputs.version }} already exists, aborting workflow."
exit 1
fi
- name: Set version
run: sed -i "s/modVersion.*=.*/modVersion = ${{ env.FULL_VERSION }}/g" gradle.properties
- name: Commit and push gradle.properties
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Bump version to v${{ env.FULL_VERSION }}"
commit_options: '--no-verify'
file_pattern: gradle.properties
tagging_message: "v${{ env.FULL_VERSION }}"
- name: Setup Build
uses: ./.github/actions/build_setup
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build Project
run: ./gradlew --info build
- name: Publish to GitHub
uses: softprops/action-gh-release@v1
with:
files: "build/libs/*.jar"
name: "${{ env.NAME }}-v${{ env.FULL_VERSION }}"
tag_name: "v${{ env.FULL_VERSION }}"
generate_release_notes: true
fail_on_unmatched_files: true
- name: Publish to Curseforge
env:
CURSEFORGE_API_KEY: "${{ secrets.CURSEFORGE_API_KEY }}"
CURSEFORGE_PROJECT_ID: "${{ env.CURSEFORGE_PROJECT_ID }}"
CHANGELOG_LOCATION: "${{ env.CHANGELOG_LOCATION }}"
RELEASE_TYPE: "${{ github.event.inputs.release_type }}"
run: ./gradlew --info curseforge
- name: Publish to Modrinth
env:
MODRINTH_API_KEY: "${{ secrets.MODRINTH_API_KEY }}"
MODRINTH_PROJECT_ID: "${{ env.MODRINTH_PROJECT_ID }}"
CHANGELOG_LOCATION: "${{ env.CHANGELOG_LOCATION }}"
RELEASE_TYPE: "${{ github.event.inputs.release_type }}"
run: ./gradlew --info modrinth