Gradle Build mc/1.21 #6
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: | |
create_github_release: | |
description: 'Create Github Release' | |
type: boolean | |
default: true | |
env: | |
JAVA_VERSION: 21 | |
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 | |
./gradlew properties -q > ./gradlew_props | |
MCVERSION=$(cat ./gradlew_props | awk '/^minecraft_version:/ {print $2}') | |
echo "minecraft_version=${MCVERSION}" | |
echo "minecraft_version=${MCVERSION}" >> $GITHUB_OUTPUT | |
ARTIFACTVERSION=$(cat ./gradlew_props | awk '/^version:/ {print $2}') | |
echo "artifact_version=${ARTIFACTVERSION}" | |
echo "artifact_version=${ARTIFACTVERSION}" >> $GITHUB_OUTPUT | |
ARTIFACT_PATH_FABRIC=$(realpath ./fabric/build/libs/torchmaster-fabric-${MCVERSION}-${ARTIFACTVERSION}.jar) | |
echo "artifact_full_path_fabric=${ARTIFACT_PATH_FABRIC}" | |
echo "artifact_full_path_fabric=${ARTIFACT_PATH_FABRIC}" >> $GITHUB_OUTPUT | |
ARTIFACT_PATH_NEOFORGE=$(realpath ./fabric/build/libs/torchmaster-neoforge-${MCVERSION}-${ARTIFACTVERSION}.jar) | |
echo "artifact_full_path_neoforge=${ARTIFACT_PATH_NEOFORGE}" | |
echo "artifact_full_path_neoforge=${ARTIFACT_PATH_NEOFORGE}" >> $GITHUB_OUTPUT | |
if [[ "$ARTIFACTVERSION" == *-alpha ]] | |
then | |
RELEASE_TYPE=alpha | |
elif [[ "$ARTIFACTVERSION" == *-beta ]] | |
then | |
RELEASE_TYPE=beta | |
else | |
RELEASE_TYPE=release | |
fi | |
echo "release_type=$RELEASE_TYPE" | |
echo "release_type=$RELEASE_TYPE" >> $GITHUB_OUTPUT | |
JSON=$(jq -n '$ARGS.named' \ | |
--arg minecraft_version "$MCVERSION" \ | |
--arg fabric_artifact_name $(basename "$ARTIFACT_PATH_FABRIC") \ | |
--arg neoforge_artifact_name $(basename "$ARTIFACT_PATH_NEOFORGE") \ | |
--arg artifact_version "$ARTIFACTVERSION" \ | |
--arg release_type "$RELEASE_TYPE" | |
) | |
echo $JSON | |
echo $JSON > release-info.json | |
- 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: | |
name: "Torchmaster ${{ steps.gradle_build.outputs.artifact_version }} MC${{ steps.gradle_build.outputs.artifact_full_path_fabric }}" | |
bodyFile: "CHANGELOG.md" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
artifacts: "${{ steps.gradle_build.outputs.artifact_full_path_fabric }},${{ steps.gradle_build.outputs.artifact_full_path_neoforge }},release-info.json" | |
tag: "mc${{ steps.gradle_build.outputs.minecraft_version }}-${{ steps.gradle_build.outputs.artifact_version }}" |