-
Notifications
You must be signed in to change notification settings - Fork 21
125 lines (108 loc) · 4.38 KB
/
Copy pathrelease.yml
File metadata and controls
125 lines (108 loc) · 4.38 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
pull-requests: read
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate version tag format
run: |
if ! [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid version tag format (${{ github.ref_name }}). Expected vX.Y.Z"
exit 1
fi
- name: Verify versions match tag
env:
TAG_NAME: ${{ github.ref_name }}
run: |
TAG_VERSION="${TAG_NAME#v}"
# Check package.json
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)"
exit 1
fi
# Check gemini-extension.json
EXTENSION_VERSION=$(node -p "require('./gemini-extension.json').version")
if [ "$TAG_VERSION" != "$EXTENSION_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) does not match gemini-extension.json version ($EXTENSION_VERSION)"
exit 1
fi
# Check .gemini-plugin/plugin.json
PLUGIN_VERSION=$(node -p "require('./.gemini-plugin/plugin.json').version")
if [ "$TAG_VERSION" != "$PLUGIN_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) does not match .gemini-plugin/plugin.json version ($PLUGIN_VERSION)"
exit 1
fi
echo "All versions match tag $TAG_NAME"
- name: Get last tag and date
id: get_last_tag
run: |
# Get the tag before the current one
TAG_LIST=$(git tag --list 'v[0-9]*' --sort=-v:refname)
LAST_TAG=$(echo "$TAG_LIST" | sed -n '2p')
if [ -z "$LAST_TAG" ]; then
LAST_TAG="v0.0.0"
TAG_DATE="1970-01-01T00:00:00Z"
else
TAG_DATE=$(git log -1 --format=%aI "$LAST_TAG" || date -Iseconds)
fi
echo "last_tag=$LAST_TAG" >> $GITHUB_OUTPUT
echo "last_tag_date=$TAG_DATE" >> $GITHUB_OUTPUT
- name: Generate Changelog from merged PRs
id: changelog
uses: actions/github-script@v6
with:
script: |
const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: "closed",
base: "main",
per_page: 100
});
const since = new Date("${{ steps.get_last_tag.outputs.last_tag_date }}");
const mergedPRs = prs.filter(pr => pr.merged_at && new Date(pr.merged_at) > since);
let changelog = "## What's Changed in ${{ github.ref_name }}\n\n";
if (mergedPRs.length === 0) {
changelog += "_No pull requests merged since last release._";
} else {
const formatted = [];
for (const pr of mergedPRs) {
let body = pr.body?.trim();
if (!body) {
// PR body가 없으면 커밋 목록으로 대체
try {
const { data: commits } = await github.rest.pulls.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
per_page: 20
});
body = commits.map(c => `- ${c.commit.message.split('\n')[0]}`).join('\n');
} catch {
body = '_No description provided._';
}
}
formatted.push(`### ${pr.title} (#${pr.number}) by @${pr.user.login}\n\n${body}`);
}
changelog += formatted.join("\n\n---\n\n");
}
const fs = require('fs');
fs.writeFileSync('RELEASE_NOTES.md', changelog);
- name: Create GitHub Release
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body_path: RELEASE_NOTES.md