-
Notifications
You must be signed in to change notification settings - Fork 26
85 lines (71 loc) · 3.34 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# 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 ./neoforge/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.minecraft_version }}"
bodyFile: "CHANGELOG.md"
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "${{ steps.gradle_build.outputs.artifact_full_path_fabric }},${{ steps.gradle_build.outputs.artifact_full_path_neoforge }}"
tag: "mc${{ steps.gradle_build.outputs.minecraft_version }}-${{ steps.gradle_build.outputs.artifact_version }}"