Skip to content

Commit 049efab

Browse files
committed
feat: refine changelog formatting and archive structure in release workflow
1 parent 6d62638 commit 049efab

1 file changed

Lines changed: 11 additions & 24 deletions

File tree

.github/workflows/release.yml

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ permissions:
2929
contents: write
3030

3131
env:
32-
# Using .NET 8.0 (LTS) or 9.0. Ensure this matches your project target.
3332
DOTNET_VERSION: "8.0.x"
3433

3534
jobs:
@@ -56,22 +55,19 @@ jobs:
5655
id: config
5756
shell: bash
5857
run: |
59-
# 1. Determine Tag
6058
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
6159
TAG="${{ github.event.inputs.tag }}"
6260
else
6361
TAG="${GITHUB_REF#refs/tags/}"
6462
fi
6563
echo "tag=$TAG" >> $GITHUB_OUTPUT
6664
67-
# 2. Determine Title
6865
if [ -n "${{ github.event.inputs.title }}" ]; then
6966
echo "title=${{ github.event.inputs.title }}" >> $GITHUB_OUTPUT
7067
else
7168
echo "title=Release $TAG" >> $GITHUB_OUTPUT
7269
fi
7370
74-
# 3. Determine Pre-release status
7571
if [ "${{ github.event.inputs.pre_release }}" = "true" ]; then
7672
echo "is_pre_release=true" >> $GITHUB_OUTPUT
7773
elif [[ "$TAG" =~ -(alpha|beta|rc|pre|preview) ]]; then
@@ -80,10 +76,7 @@ jobs:
8076
echo "is_pre_release=false" >> $GITHUB_OUTPUT
8177
fi
8278
83-
# 4. Determine Draft status
8479
echo "is_draft=${{ github.event.inputs.draft }}" >> $GITHUB_OUTPUT
85-
86-
# 5. Get Commit SHA
8780
echo "commit_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
8881
8982
- name: Generate Changelog
@@ -93,34 +86,32 @@ jobs:
9386
CURRENT_TAG="${{ steps.config.outputs.tag }}"
9487
INPUT_PREV="${{ github.event.inputs.previous_tag }}"
9588
96-
# Try to find the previous tag automatically if not provided
9789
if [ -n "$INPUT_PREV" ]; then
9890
PREV_TAG="$INPUT_PREV"
9991
else
100-
# Get the tag before the current HEAD
10192
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
10293
fi
10394
10495
echo "Current: $CURRENT_TAG, Previous: $PREV_TAG"
10596
echo "previous_tag=$PREV_TAG" >> $GITHUB_OUTPUT
10697
107-
# Generate Commit List
108-
# Format: - Subject (@Author)
98+
# 统一格式:
99+
# Commits: - Subject (@**Author**)
100+
# Contributors: - **Author** (Count commits)
101+
109102
if [ -z "$PREV_TAG" ]; then
110103
echo "No previous tag found. Listing all commits."
111-
COMMITS=$(git log --pretty=format:"- %s (@%an)" --reverse)
112-
CONTRIBUTORS=$(git log --pretty=format:"%an" | sort | uniq -c | sort -nr | awk '{print "- " $2 " (" $1 " commits)"}')
104+
COMMITS=$(git log --pretty=format:"- %s (@**%an**)" --reverse)
105+
CONTRIBUTORS=$(git log --pretty=format:"%an" | sort | uniq -c | sort -nr | awk '{print "- **" $2 "** (" $1 " commits)"}')
113106
else
114107
echo "Generating changelog from $PREV_TAG to HEAD."
115108
COMMITS=$(git log ${PREV_TAG}..HEAD --pretty=format:"- %s (@**%an**)" --reverse)
116-
CONTRIBUTORS=$(git log ${PREV_TAG}..HEAD --pretty=format:"%an" | sort | uniq -c | sort -nr | awk '{print "- @" $2 " (" $1 " Commits)"}')
109+
CONTRIBUTORS=$(git log ${PREV_TAG}..HEAD --pretty=format:"%an" | sort | uniq -c | sort -nr | awk '{print "- **" $2 "** (" $1 " commits)"}')
117110
fi
118111
119-
# Handle empty results
120112
if [ -z "$COMMITS" ]; then COMMITS="No visible changes."; fi
121113
if [ -z "$CONTRIBUTORS" ]; then CONTRIBUTORS="No new contributors."; fi
122114
123-
# Output Multi-line strings using EOF
124115
{
125116
echo "changes<<EOF"
126117
echo "$COMMITS"
@@ -180,9 +171,6 @@ jobs:
180171
OUTPUT_DIR="./publish/${{ matrix.project.name }}"
181172
ARCHIVE_NAME="${{ matrix.project.output_name }}-${{ matrix.platform.rid }}.zip"
182173
183-
# Optimization: Removed PublishReadyToRun=true to speed up build significantly
184-
# Optimization: PublishTrimmed=false prevents analysis delays and runtime errors
185-
186174
EXTRA_ARGS="-p:PublishSingleFile=true -p:IncludeAllContentForSelfExtract=true"
187175
188176
if [[ "${{ matrix.platform.rid }}" == win-* ]]; then
@@ -200,16 +188,15 @@ jobs:
200188
-p:PublishReadyToRun=false \
201189
$EXTRA_ARGS
202190
203-
# Compress Artifacts
204191
mkdir -p ./artifacts
205-
206192
echo "Compressing to $ARCHIVE_NAME..."
207193
208194
if [[ "${{ matrix.platform.runner }}" == "windows-latest" ]]; then
209-
# Use 7z on Windows Git Bash for speed
210-
7z a -tzip "./artifacts/$ARCHIVE_NAME" "$OUTPUT_DIR/*"
195+
# Windows: Enter directory first to ensure clean zip structure
196+
cd "$OUTPUT_DIR"
197+
7z a -tzip "../../artifacts/$ARCHIVE_NAME" .
211198
else
212-
# Use zip on Linux/Mac
199+
# Linux/Mac
213200
cd "$OUTPUT_DIR"
214201
zip -r "../../artifacts/$ARCHIVE_NAME" .
215202
fi

0 commit comments

Comments
 (0)