-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (58 loc) · 2.78 KB
/
Copy pathrelease-notes.yml
File metadata and controls
68 lines (58 loc) · 2.78 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
name: Update Release Notes
# release 브랜치에 새 커밋이 반영될 때마다 실행됩니다.
# 버전은 사람이 직접 입력하지 않고, Xcode 프로젝트의 MARKETING_VERSION 값을
# 그대로 읽어와 사용합니다. (즉, 버전은 평소처럼 프로젝트에서 직접 올리면 됩니다.)
on:
push:
branches:
- release
permissions:
contents: write
jobs:
update-release-notes:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract version from Xcode project
id: version
run: |
VERSION=$(grep -m1 'MARKETING_VERSION' WSSiOS.xcodeproj/project.pbxproj | sed -E 's/.*MARKETING_VERSION = ([0-9.]+);.*/\1/')
if [ -z "$VERSION" ]; then
echo "::error::project.pbxproj에서 MARKETING_VERSION을 찾을 수 없습니다."
exit 1
fi
echo "버전: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v.$VERSION" >> "$GITHUB_OUTPUT"
- name: Generate release notes from merged PRs
id: notes
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ steps.version.outputs.tag }}"
# generate-notes API는 tag_name이 이미 존재하는 태그면 target_commitish를 무시하고
# 그 태그가 가리키는(과거) 커밋 기준으로만 노트를 만든다. 버전을 올리지 않은 채
# release에 커밋이 더 쌓인 경우에도 최신 커밋까지 반영되도록, 존재하지 않는 임시
# 태그 이름으로 요청하고 이전 버전 태그를 previous_tag_name으로 직접 지정한다.
PREV_TAG=$(gh release list --limit 20 --json tagName,createdAt \
--jq "[.[] | select(.tagName != \"$TAG\")] | sort_by(.createdAt) | last | .tagName // empty")
ARGS=(-f tag_name="${TAG}-preview" -f target_commitish="release")
if [ -n "$PREV_TAG" ]; then
echo "이전 버전 태그: $PREV_TAG"
ARGS+=(-f previous_tag_name="$PREV_TAG")
fi
RESPONSE=$(gh api "repos/${{ github.repository }}/releases/generate-notes" "${ARGS[@]}")
echo "$RESPONSE" | jq -r .body > /tmp/release-notes.md
- name: Create or update GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ steps.version.outputs.tag }}"
if gh release view "$TAG" >/dev/null 2>&1; then
echo "기존 릴리즈($TAG)의 노트를 업데이트합니다."
gh release edit "$TAG" --title "$TAG" --notes-file /tmp/release-notes.md
else
echo "새 릴리즈($TAG)를 생성합니다."
gh release create "$TAG" --target release --title "$TAG" --notes-file /tmp/release-notes.md
fi