Skip to content

Commit b5e4603

Browse files
committed
(feat.) 添加了自动构建脚本
1 parent 546f262 commit b5e4603

3 files changed

Lines changed: 109 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Lirael Action CI
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
paths:
8+
- ".github/workflows/**/**.yml"
9+
- "lirael-api/**/*"
10+
- "lirael-server/**/*"
11+
- "scripts/**/*"
12+
- "gradle.properties"
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
environment: default
18+
19+
steps:
20+
- name: Checkout Git Repository
21+
uses: actions/checkout@v6
22+
23+
- name: Setup Gradle
24+
uses: gradle/actions/setup-gradle@v5
25+
26+
- name: Set up JDK
27+
uses: actions/setup-java@v5
28+
with:
29+
distribution: 'zulu'
30+
java-version: '21'
31+
32+
- name: Config Git
33+
run: |
34+
git config --global user.email "no-reply@github.com"
35+
git config --global user.name "Github Actions"
36+
37+
- name: Grant execute permission for gradlew
38+
run: |
39+
chmod +x gradlew
40+
41+
- name: Apply Patches
42+
run: |
43+
./gradlew applyAllPatches
44+
45+
- name: CreateJar
46+
run: |
47+
./gradlew createMojmapPaperclipJar
48+
49+
- name : SetENV
50+
run: |
51+
sh scripts/SetENV.sh
52+
53+
- name: Get build info
54+
id: build-info
55+
run: |
56+
BUILD_DATE=$(date -u +'%Y-%m-%d %H:%M:%S UTC')
57+
echo "build_date=$BUILD_DATE" >> $GITHUB_ENV
58+
59+
- name: Create Release
60+
if: github.event_name != 'pull_request'
61+
uses: ncipollo/release-action@v1
62+
with:
63+
tag: ${{ env.tag }}
64+
name: ${{ env.project_id_b }} ${{ env.mcversion }} - ${{ env.commit_id }}
65+
body: |
66+
### 📦 Version: `${{ env.mcversion }}` | Commit: [${{ env.commit_id }}](https://github.com/${{ github.repository }}/commit/${{ env.commit_id }})
67+
[![download](https://img.shields.io/github/downloads/CoderFrish/${{ env.project_id }}/${{ env.tag }}/total?color=red&style=flat-square)](https://github.com/CoderFrish/${{ env.project_id }}/releases/download/${{ env.tag }}/${{ env.jar }})
68+
69+
> This release is automatically built by GitHub Actions.
70+
71+
#### 📜 Latest Commit Message:
72+
${{ env.commit_msg }}
73+
74+
#### 📊 Build Information:
75+
- **Build Status**: ✅ Success
76+
- **Build Date**: ${{ env.build_date }}
77+
artifacts: ${{ env.jar_dir }}
78+
generateReleaseNotes: true
79+
prerelease: ${{ env.pre }}
80+
makeLatest: ${{ env.make_latest }}
81+
token: ${{ secrets.GITHUB_TOKEN }}

gradle.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ group=dev.coderfrish.lirael
44
version=1.21.11-R0.1-SNAPSHOT
55
mcVersion=1.21.11
66
apiVersion=1.21.11
7-
preVersion=true
87

98
## Gradle Settings ##
109
org.gradle.configuration-cache=true

scripts/SetENV.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
prop() {
2+
grep "^[[:space:]]*${1}" gradle.properties | cut -d'=' -f2 | sed 's/^[[:space:]]*//; s/\r//'
3+
}
4+
5+
project_id="lirael"
6+
project_id_b="Lirael"
7+
8+
commitid=$(git log --pretty='%h' -1)
9+
mcversion=$(prop mcVersion)
10+
grdversion=$(prop version)
11+
preVersion=$(prop preVersion)
12+
release_tag="$mcversion-$commitid"
13+
jarName="$project_id-$mcversion"
14+
jarName_dir="lirael-server/build/libs/$jarName.jar"
15+
make_latest=$([ $preVersion = "true" ] && echo "false" || echo "true")
16+
17+
mv lirael-server/build/libs/$project_id-paperclip-$grdversion-mojmap.jar $jarName_dir
18+
19+
echo "project_id=$project_id" >> $GITHUB_ENV
20+
echo "project_id_b=$project_id_b" >> $GITHUB_ENV
21+
echo "commit_id=$commitid" >> $GITHUB_ENV
22+
echo "commit_msg=$(git log --pretty='> [%h] %s' -1)" >> $GITHUB_ENV
23+
echo "mcversion=$mcversion" >> $GITHUB_ENV
24+
echo "pre=$preVersion" >> $GITHUB_ENV
25+
echo "tag=$release_tag" >> $GITHUB_ENV
26+
echo "jar=$jarName" >> $GITHUB_ENV
27+
echo "jar_dir=$jarName_dir" >> $GITHUB_ENV
28+
echo "make_latest=$make_latest" >> $GITHUB_ENV

0 commit comments

Comments
 (0)