forked from BalloonUpdate/Mcpatch2JavaClient
-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (88 loc) · 3.09 KB
/
manual-release.yml
File metadata and controls
105 lines (88 loc) · 3.09 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Manual Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., 1.0.0)'
required: true
type: string
prerelease:
description: 'Is this a pre-release?'
required: false
default: false
type: boolean
draft:
description: 'Create as draft?'
required: false
default: false
type: boolean
jobs:
build-and-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'zulu'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build with Gradle
run: ./gradlew shadowJar --no-daemon
- name: Get commit SHA
id: commit
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Create Git tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ inputs.version }}" -m "Release v${{ inputs.version }}"
git push origin "v${{ inputs.version }}"
- name: Generate changelog
id: changelog
run: |
# 获取上一个 tag
PREV_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
# 如果没有上一个 tag,获取所有提交
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges -20)
else
# 获取两个 tag 之间的提交
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges $PREV_TAG..HEAD)
fi
# 保存到文件(多行内容)
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ inputs.version }}
name: Mcpatch v${{ inputs.version }}
body: |
## Mcpatch v${{ inputs.version }}
**构建信息:**
- 版本: ${{ inputs.version }}
- 提交: ${{ steps.commit.outputs.sha }}
- 构建时间: ${{ github.event.head_commit.timestamp }}
**更新内容:**
${{ steps.changelog.outputs.changelog }}
---
**使用方法:**
下载 `Mcpatch-${{ inputs.version }}.jar` 文件,按照项目说明进行部署。
files: build/libs/*.jar
draft: ${{ inputs.draft }}
prerelease: ${{ inputs.prerelease }}
generate_release_notes: false
- name: Upload release artifact
uses: actions/upload-artifact@v4
with:
name: Mcpatch-v${{ inputs.version }}
path: build/libs/*.jar
retention-days: 30