Gradle Build mc/1.20.1 #110
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
# This workflow will build a Java project with Gradle | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle | |
name: Gradle Build | |
run-name: Gradle Build ${{ github.ref_name }} | |
on: | |
workflow_dispatch: | |
inputs: | |
deploy_curseforge: | |
description: 'Deploy to Curseforge' | |
type: boolean | |
default: false | |
deploy_modrinth: | |
description: 'Deploy to Modrinth' | |
type: boolean | |
default: false | |
create_github_release: | |
description: 'Create Github Release' | |
type: boolean | |
default: false | |
env: | |
JAVA_VERSION: 17 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 1.${{ env.JAVA_VERSION }} | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
id: gradle_build | |
run: | | |
./gradlew build versionTxt | |
echo "artifactversion=`basename \`cat ./build/libs/version.txt\``" | |
echo "artifactversion=`basename \`cat ./build/libs/version.txt\``" >> $GITHUB_OUTPUT | |
echo "artifactname=`basename \`cat ./build/libs/artifact.txt\``" | |
echo "artifactname=`basename \`cat ./build/libs/artifact.txt\``" >> $GITHUB_OUTPUT | |
echo "artifactfullname=`realpath ./build/libs/\`cat ./build/libs/artifact.txt\``" | |
echo "artifactfullname=`realpath ./build/libs/\`cat ./build/libs/artifact.txt\``" >> $GITHUB_OUTPUT | |
echo "mcversion=`basename ${{ github.ref }}`" | |
echo "mcversion=`basename ${{ github.ref }}`" >> $GITHUB_OUTPUT | |
if [[ `cat ./build/libs/version.txt` == *-alpha ]] | |
then | |
echo "releasetype=alpha" | |
echo "releasetype=alpha" >> $GITHUB_OUTPUT | |
elif [[ `cat ./build/libs/version.txt` == *-beta ]] | |
then | |
echo "releasetype=beta" | |
echo "releasetype=beta" >> $GITHUB_OUTPUT | |
else | |
echo "releasetype=release" | |
echo "releasetype=release" >> $GITHUB_OUTPUT | |
fi | |
- name: Create Github Release | |
id: create_github_release | |
if: ${{ !cancelled() && steps.gradle_build.outcome == 'success' && github.event.inputs.create_github_release == 'true' }} | |
uses: ncipollo/release-action@v1 | |
with: | |
bodyFile: "changelog.md" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
artifacts: "${{ steps.gradle_build.outputs.artifactfullname }}" | |
tag: "mc${{ steps.gradle_build.outputs.mcversion }}-${{ steps.gradle_build.outputs.artifactversion }}" | |
- name: Publish to Modrinth | |
id: publish_modrinth | |
if: ${{ !cancelled() && steps.gradle_build.outcome == 'success' && github.event.inputs.deploy_modrinth == 'true' }} | |
uses: Kir-Antipov/[email protected] | |
with: | |
modrinth-id: "Tl8ESrhX" | |
modrinth-token: ${{ secrets.MODRINTH_TOKEN }} | |
files: ${{ steps.gradle_build.outputs.artifactfullname }} | |
name: torchmaster-${{ steps.gradle_build.outputs.artifactversion }} | |
version: ${{ steps.gradle_build.outputs.artifactversion }} | |
version-type: ${{ steps.gradle_build.outputs.releasetype }} | |
changelog-file: changelog.md | |
loaders: forge | |
game-versions: ${{ steps.gradle_build.outputs.mcversion }} | |
java: ${{ env.JAVA_VERSION }} | |
- name: Publish to Curseforge | |
id: publish_curseforge | |
if: ${{ !cancelled() && steps.gradle_build.outcome == 'success' && github.event.inputs.deploy_curseforge == 'true' }} | |
uses: Kir-Antipov/[email protected] | |
with: | |
curseforge-id: "254268" | |
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} | |
files: ${{ steps.gradle_build.outputs.artifactfullname }} | |
name: torchmaster-${{ steps.gradle_build.outputs.artifactversion }} | |
version: ${{ steps.gradle_build.outputs.artifactversion }} | |
version-type: ${{ steps.gradle_build.outputs.releasetype }} | |
changelog-file: changelog.md | |
loaders: forge | |
game-versions: ${{ steps.gradle_build.outputs.mcversion }} | |
java: ${{ env.JAVA_VERSION }} |