1- name : Build and Release
1+ name : Publish Release
22
33on :
44 push :
5- tags :
6- - ' v*'
7- workflow_dispatch :
8- inputs :
9- version :
10- description : ' Version to release (e.g., v0.6.9)'
11- required : true
12- type : string
5+ branches :
6+ - 2101-neo
7+ paths-ignore :
8+ - ' *.md'
139
1410permissions :
1511 contents : write
1612
1713jobs :
1814 build-and-release :
15+ if : contains(github.event.head_commit.message, '[release]')
1916 runs-on : ubuntu-latest
20-
17+
2118 steps :
22- - name : Checkout code
23- uses : actions/checkout@v4
24-
25- - name : Set up JDK 21
26- uses : actions/setup-java@v4
27- with :
28- java-version : ' 21'
29- distribution : ' temurin'
30-
31- - name : Grant execute permission for gradlew
32- run : chmod +x gradlew
33-
34- - name : Setup Gradle
35- uses : gradle/gradle-build-action@v3
36-
37- - name : Build with Gradle
38- run : ./gradlew build
39-
40- - name : Get version from gradle.properties
41- id : get_version
42- run : |
43- VERSION=$(grep 'mod_version=' gradle.properties | cut -d'=' -f2)
44- echo "version=$VERSION" >> $GITHUB_OUTPUT
45- echo "tag_version=v$VERSION" >> $GITHUB_OUTPUT
46-
47- - name : Find JAR file
48- id : find_jar
49- run : |
50- JAR_FILE=$(find build/libs -name "*.jar" -not -name "*-sources.jar" -not -name "*-javadoc.jar" | head -1)
51- echo "jar_file=$JAR_FILE" >> $GITHUB_OUTPUT
52- echo "jar_name=$(basename $JAR_FILE)" >> $GITHUB_OUTPUT
53-
54- - name : Create Release
55- id : create_release
56- uses : actions/create-release@v1
57- env :
58- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
59- with :
60- tag_name : ${{ github.event.inputs.version || steps.get_version.outputs.tag_version }}
61- release_name : Release ${{ github.event.inputs.version || steps.get_version.outputs.tag_version }}
62- body : |
63- ## Changes
64- - 自动构建发布
65-
66- ## 安装说明
67- 1. 下载 JAR 文件
68- 2. 将其放入 Minecraft mods 文件夹
69- 3. 启动游戏
70-
71- **支持的版本:** Minecraft 1.21.1 + NeoForge 21.1.169+
72- draft : false
73- prerelease : false
74-
75- - name : Upload Release Asset
76- uses : actions/upload-release-asset@v1
77- env :
78- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
79- with :
80- upload_url : ${{ steps.create_release.outputs.upload_url }}
81- asset_path : ${{ steps.find_jar.outputs.jar_file }}
82- asset_name : ${{ steps.find_jar.outputs.jar_name }}
83- asset_content_type : application/java-archive
19+ - name : Checkout code
20+ uses : actions/checkout@v4
21+
22+ - name : Set up JDK 21
23+ uses : actions/setup-java@v4
24+ with :
25+ java-version : ' 21'
26+ distribution : ' temurin'
27+ cache : ' gradle'
28+
29+ - name : Grant execute permission for gradlew
30+ run : chmod +x gradlew
31+
32+ - name : Build with Gradle
33+ run : ./gradlew build
34+
35+ - name : Read version from gradle.properties
36+ id : get_version
37+ run : |
38+ VERSION=$(grep "mod_version=" gradle.properties | cut -d'=' -f2)
39+ echo "VERSION=$VERSION" >> $GITHUB_ENV
40+
41+ - name : Create Release
42+ uses : softprops/action-gh-release@v2
43+ with :
44+ tag_name : v${{ env.VERSION }}
45+ name : Release v${{ env.VERSION }}
46+ body : ${{ github.event.head_commit.message }}
47+ draft : false
48+ prerelease : false
49+ files : build/libs/*.jar
50+ env :
51+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments