Repository navigation
140 lines (122 loc) · 5.28 KB
/
Copy pathrelease.yml
File metadata and controls
140 lines (122 loc) · 5.28 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g. 0.12.1)'
required: true
permissions:
contents: write
concurrency:
group: release
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && 'develop' || github.ref }}
fetch-depth: 0
- name: Resolve VERSION
env:
INPUT_VERSION: ${{ github.event.inputs.version }}
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${INPUT_VERSION}"
else
VERSION="${GITHUB_REF#refs/tags/v}"
fi
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
echo "Resolved VERSION=${VERSION} (trigger: ${{ github.event_name }})"
- name: Validate
run: |
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.]+)?$ ]]; then
echo "::error::Invalid version '$VERSION'. Expected MAJOR.MINOR.PATCH[-suffix]."
exit 1
fi
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
if git rev-parse -q --verify "refs/tags/v$VERSION" >/dev/null; then
echo "::error::Tag v$VERSION already exists."
exit 1
fi
fi
# 태그가 develop의 과거 커밋을 가리키면, 아래 amend + force-push가 그 뒤의 develop 커밋을 지워 버린다.
- name: Ensure the release commit is the tip of develop
run: |
git fetch origin develop
ORIG_SHA="$(git rev-parse HEAD)"
DEVELOP_SHA="$(git rev-parse origin/develop)"
if [ "$ORIG_SHA" != "$DEVELOP_SHA" ]; then
echo "::error::Release commit $ORIG_SHA is not the tip of develop ($DEVELOP_SHA). Tag the tip of develop."
exit 1
fi
echo "ORIG_SHA=${ORIG_SHA}" >> "$GITHUB_ENV"
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'oracle'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Update version in README.md
run: |
sed -i "s|implementation 'com.github.getCurrentThread:soopapi:[^']*'|implementation 'com.github.getCurrentThread:soopapi:v${VERSION}'|g" README.md
grep -qF -- "implementation 'com.github.getCurrentThread:soopapi:v${VERSION}'" README.md \
|| { echo "::error::README.md JitPack line not updated to v${VERSION}."; exit 1; }
- name: Update version in gradle.properties
run: |
sed -i "s|^version=.*|version=${VERSION}|" gradle.properties
grep -qx -- "version=${VERSION}" gradle.properties \
|| { echo "::error::gradle.properties version not updated to ${VERSION}."; exit 1; }
- name: Update version in llms.txt
run: |
sed -i "s|^- 버전: .*|- 버전: v${VERSION}|" llms.txt
grep -qx -- "- 버전: v${VERSION}" llms.txt \
|| { echo "::error::llms.txt version line not updated to v${VERSION}."; exit 1; }
- name: Update version in llms-full.txt
run: |
sed -i "s|^- 버전: .*|- 버전: v${VERSION}|" llms-full.txt
grep -qx -- "- 버전: v${VERSION}" llms-full.txt \
|| { echo "::error::llms-full.txt version line not updated to v${VERSION}."; exit 1; }
- name: Update install lines in llms docs
run: |
for f in llms.txt llms-full.txt; do
sed -i "s|implementation 'com.github.getCurrentThread:soopapi:[^']*'|implementation 'com.github.getCurrentThread:soopapi:v${VERSION}'|g" "$f"
grep -qF -- "implementation 'com.github.getCurrentThread:soopapi:v${VERSION}'" "$f" \
|| { echo "::error::$f install line not updated to v${VERSION}."; exit 1; }
done
# 태그를 달기 전에, 태그될 내용 그대로 빌드와 테스트를 통과하는지 확인한다.
- name: Build and test
run: ./gradlew :lib:build
- name: Amend bump, retag, and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add README.md gradle.properties llms.txt llms-full.txt
if git diff --cached --quiet; then
echo "No file changes to amend."
else
git commit --amend --no-edit
fi
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
git tag -a "v${VERSION}" -m "Release v${VERSION}" HEAD
else
git tag -af "v${VERSION}" -m "Release v${VERSION}" HEAD
fi
# develop이 위 검사 이후에 움직였으면 push가 거부된다.
git push --force-with-lease=refs/heads/develop:"${ORIG_SHA}" origin HEAD:develop
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
git push origin "v${VERSION}"
else
git push --force origin "v${VERSION}"
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.VERSION }}
name: v${{ env.VERSION }}
generate_release_notes: true