Fix #258 #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and upload mod | |
on: | |
push: | |
branches: | |
- '1.19' | |
release: | |
types: [ published ] | |
branches: | |
- '1.19' | |
jobs: | |
setup: | |
if: ${{ contains(github.event.head_commit.message, 'version bump for release') && github.event_name != 'release' }} | |
name: Generate file path | |
runs-on: ubuntu-latest | |
outputs: | |
mod_name: ${{steps.moddetails.outputs.mod_name}} | |
mod_version: ${{steps.moddetails.outputs.mod_version}} | |
java_version: ${{steps.moddetails.outputs.java_version}} | |
mc_patch_version: ${{steps.patchversion.outputs.mc_patch_version}} | |
mc_minor_version: ${{steps.minorversion.outputs.mc_minor_version}} | |
file_path: ${{steps.filepath.outputs.file_path}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get Details | |
id: moddetails | |
run: | | |
echo "mod_name=$(cat ./gradle.properties | sed -n 's/modid\=//p' | tr -d "'")" >> $GITHUB_OUTPUT | |
echo "mod_version=$(cat ./gradle.properties | sed -n 's/mod_version\=//p' | tr -d "'")" >> $GITHUB_OUTPUT | |
echo "mc_version=$(cat ./gradle.properties | sed -n 's/mc_version\=//p' | tr -d "'")" >> $GITHUB_OUTPUT | |
echo "java_version=$(cat ./build.gradle | grep -o -P '(?<=JavaLanguageVersion.of\().*(?=\))')" >> $GITHUB_OUTPUT | |
- name: MC Patch Version | |
id: patchversion | |
run: echo "mc_patch_version=$(echo ${{ steps.moddetails.outputs.mc_version }} | awk -F- '{ print $1 }')" >> $GITHUB_OUTPUT | |
- name: MC Minor Version | |
id: minorversion | |
run: echo "mc_minor_version=$(echo ${{ steps.patchversion.outputs.mc_patch_version }} | awk -F. '{ print $1"."$2 }')" >> $GITHUB_OUTPUT | |
- name: Get Details | |
id: filepath | |
run: echo "file_path=./build/libs/${{ steps.moddetails.outputs.mod_name }}-${{ steps.moddetails.outputs.mc_version }}-${{ steps.moddetails.outputs.mod_version }}.jar" >> $GITHUB_OUTPUT | |
build: | |
name: Build and cache | |
runs-on: ubuntu-latest | |
needs: [ setup ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '${{ needs.setup.outputs.java_version }}' | |
distribution: 'adopt' | |
cache: 'gradle' | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build | |
run: ./gradlew :build | |
- name: Cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
${{ needs.setup.outputs.file_path }} | |
CHANGELOG.md | |
key: ${{ github.sha }} | |
upload: | |
name: Upload to ModRepo | |
runs-on: ubuntu-latest | |
needs: [ setup,build ] | |
steps: | |
- name: Restore Cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
${{ needs.setup.outputs.file_path }} | |
CHANGELOG.md | |
key: ${{ github.sha }} | |
- name: Upload to CurseForge | |
if: ${{ vars.MODREPO == 'curseforge' || vars.MODREPO == 'both' }} | |
uses: Kir-Antipov/[email protected] | |
with: | |
curseforge-id: 550941 | |
curseforge-token: ${{ secrets.curseforge_api }} | |
files-primary: ${{ needs.setup.outputs.file_path }} | |
name: ${{ needs.setup.outputs.mod_name }}-${{ needs.setup.outputs.mc_patch_version }}-${{ needs.setup.outputs.mod_version }} | |
version: ${{ needs.setup.outputs.mc_patch_version }}-${{ needs.setup.outputs.mod_version }} | |
changelog-file: CHANGELOG.md | |
loaders: | | |
forge | |
game-versions: | | |
${{ needs.setup.outputs.mc_minor_version }} | |
${{ needs.setup.outputs.mc_patch_version }} | |
java: | | |
${{ needs.setup.outputs.java_version }} | |
version-type: | | |
beta | |
- name: Upload to Modrinth | |
if: ${{ vars.MODREPO == 'modrinth' || vars.MODREPO == 'both' }} | |
uses: Kir-Antipov/[email protected] | |
with: | |
modrinth-id: KFQYC1Uy | |
modrinth-token: ${{ secrets.modrinth_api }} | |
files-primary: ${{ needs.setup.outputs.file_path }} | |
name: ${{ needs.setup.outputs.mod_name }}-${{ needs.setup.outputs.mc_patch_version }}-${{ needs.setup.outputs.mod_version }} | |
version: ${{ needs.setup.outputs.mc_patch_version }}-${{ needs.setup.outputs.mod_version }} | |
changelog-file: CHANGELOG.md | |
loaders: | | |
forge | |
game-versions: | | |
${{ needs.setup.outputs.mc_minor_version }} | |
${{ needs.setup.outputs.mc_patch_version }} | |
java: | | |
${{ needs.setup.outputs.java_version }} |