Skip to content

Commit cffece6

Browse files
Merge pull request #111 from Palbahngmiyine/ci/pipeline-setup
ci: GitHub OIDC 기반 CI/CD 파이프라인 및 beta 릴리스 워크플로우 추가
2 parents 446613f + a27275e commit cffece6

9 files changed

Lines changed: 581 additions & 7 deletions

.github/workflows/build-docs.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,21 @@ concurrency:
1616

1717
jobs:
1818
build-docs:
19+
if: ${{ !github.event.release.prerelease }}
1920
runs-on: ubuntu-latest
2021
steps:
2122
- name: Checkout
22-
uses: actions/checkout@v4
23+
uses: actions/checkout@v6
2324
- name: Setup pnpm
24-
uses: pnpm/action-setup@v4
25-
with:
26-
version: 10.15.1
25+
uses: pnpm/action-setup@v5
2726
- name: Setup Node.js
28-
uses: actions/setup-node@v4
27+
uses: actions/setup-node@v6
2928
with:
3029
node-version: 18
3130
cache: pnpm
3231
cache-dependency-path: pnpm-lock.yaml
3332
- name: Setup Pages
34-
uses: actions/configure-pages@v5
33+
uses: actions/configure-pages@v6
3534
- name: Install dependencies
3635
run: pnpm install --frozen-lockfile
3736
- name: Build docs
@@ -42,6 +41,7 @@ jobs:
4241
path: docs
4342

4443
deploy:
44+
if: ${{ !github.event.release.prerelease }}
4545
environment:
4646
name: github-pages
4747
url: ${{ steps.deployment.outputs.page_url }}
@@ -50,4 +50,4 @@ jobs:
5050
steps:
5151
- name: Deploy to GitHub Pages
5252
id: deployment
53-
uses: actions/deploy-pages@v4
53+
uses: actions/deploy-pages@v5

.github/workflows/ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master, beta]
6+
pull_request:
7+
branches: [master, beta]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: ci-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
env:
18+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
19+
20+
jobs:
21+
ci:
22+
name: CI (Node ${{ matrix.node-version }})
23+
runs-on: ubuntu-latest
24+
strategy:
25+
matrix:
26+
node-version: [18, 20, 22]
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v6
30+
31+
- name: Setup pnpm
32+
uses: pnpm/action-setup@v5
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v6
36+
with:
37+
node-version: ${{ matrix.node-version }}
38+
cache: pnpm
39+
cache-dependency-path: pnpm-lock.yaml
40+
41+
- name: Install dependencies
42+
run: pnpm install --frozen-lockfile
43+
44+
- name: Lint
45+
run: pnpm lint:ci
46+
47+
- name: Test (unit only)
48+
run: pnpm test:ci
49+
50+
- name: Build
51+
run: pnpm tsup
Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
name: Beta Release
2+
3+
on:
4+
workflow_run:
5+
workflows: ["CI"]
6+
branches: [beta]
7+
types: [completed]
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
issues: write
13+
actions: write
14+
statuses: write
15+
id-token: write
16+
17+
concurrency:
18+
group: release-please-beta
19+
cancel-in-progress: false
20+
21+
env:
22+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
23+
24+
jobs:
25+
release-please:
26+
name: Release Please (Beta)
27+
if: >-
28+
github.event.workflow_run.conclusion == 'success' &&
29+
github.event.workflow_run.event == 'push'
30+
runs-on: ubuntu-latest
31+
outputs:
32+
release_created: ${{ steps.release.outputs.release_created }}
33+
tag_name: ${{ steps.release.outputs.tag_name }}
34+
pr_head_sha: ${{ steps.pr-sha.outputs.sha }}
35+
steps:
36+
- name: Release Please
37+
id: release
38+
uses: googleapis/release-please-action@v4
39+
with:
40+
token: ${{ secrets.GITHUB_TOKEN }}
41+
target-branch: beta
42+
config-file: release-please-config-beta.json
43+
manifest-file: .release-please-manifest-beta.json
44+
45+
- name: Update release title with date
46+
if: ${{ steps.release.outputs.release_created }}
47+
env:
48+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
TAG: ${{ steps.release.outputs.tag_name }}
50+
REPO: ${{ github.repository }}
51+
run: |
52+
DATE=$(date -u +"%Y/%m/%d")
53+
gh release edit "$TAG" --repo "$REPO" --title "$TAG ($DATE)"
54+
55+
- name: Get PR head SHA
56+
id: pr-sha
57+
if: ${{ !steps.release.outputs.release_created }}
58+
env:
59+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
REPO: ${{ github.repository }}
61+
run: |
62+
SHA=$(gh pr list --repo "$REPO" --head release-please--branches--beta --state open --json headRefOid --jq '.[0].headRefOid // empty')
63+
echo "sha=${SHA:-}" >> "$GITHUB_OUTPUT"
64+
65+
test-release-pr:
66+
name: Test (Beta Release PR)
67+
needs: release-please
68+
if: ${{ !needs.release-please.outputs.release_created && needs.release-please.outputs.pr_head_sha != '' }}
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Set pending status
72+
env:
73+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
75+
REPO: ${{ github.repository }}
76+
run: |
77+
gh api "repos/$REPO/statuses/$SHA" \
78+
-f state=pending -f context="Test (Beta)" -f description="Running tests..." \
79+
|| echo "::warning::Failed to set pending status on $SHA"
80+
81+
- name: Checkout
82+
uses: actions/checkout@v6
83+
with:
84+
ref: ${{ needs.release-please.outputs.pr_head_sha }}
85+
86+
- name: Setup pnpm
87+
uses: pnpm/action-setup@v5
88+
89+
- name: Setup Node.js
90+
uses: actions/setup-node@v6
91+
with:
92+
node-version: 18
93+
cache: pnpm
94+
cache-dependency-path: pnpm-lock.yaml
95+
96+
- name: Install dependencies
97+
run: pnpm install --frozen-lockfile
98+
99+
- name: Test (unit only)
100+
run: pnpm test:ci
101+
102+
- name: Build
103+
run: pnpm tsup
104+
105+
- name: Report success
106+
if: success()
107+
continue-on-error: true
108+
env:
109+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110+
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
111+
REPO: ${{ github.repository }}
112+
run: |
113+
gh api "repos/$REPO/statuses/$SHA" \
114+
-f state=success -f context="Test (Beta)" -f description="Tests passed" \
115+
|| echo "::warning::Failed to report success status on $SHA"
116+
117+
- name: Report failure
118+
if: failure()
119+
continue-on-error: true
120+
env:
121+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122+
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
123+
REPO: ${{ github.repository }}
124+
run: |
125+
gh api "repos/$REPO/statuses/$SHA" \
126+
-f state=failure -f context="Test (Beta)" -f description="Tests failed" \
127+
|| echo "::warning::Failed to report failure status on $SHA"
128+
129+
lint-release-pr:
130+
name: Lint (Beta Release PR)
131+
needs: release-please
132+
if: ${{ !needs.release-please.outputs.release_created && needs.release-please.outputs.pr_head_sha != '' }}
133+
runs-on: ubuntu-latest
134+
steps:
135+
- name: Set pending status
136+
env:
137+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138+
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
139+
REPO: ${{ github.repository }}
140+
run: |
141+
gh api "repos/$REPO/statuses/$SHA" \
142+
-f state=pending -f context="Lint (Beta)" -f description="Running lint..." \
143+
|| echo "::warning::Failed to set pending status on $SHA"
144+
145+
- name: Checkout
146+
uses: actions/checkout@v6
147+
with:
148+
ref: ${{ needs.release-please.outputs.pr_head_sha }}
149+
150+
- name: Setup pnpm
151+
uses: pnpm/action-setup@v5
152+
153+
- name: Setup Node.js
154+
uses: actions/setup-node@v6
155+
with:
156+
node-version: 18
157+
cache: pnpm
158+
cache-dependency-path: pnpm-lock.yaml
159+
160+
- name: Install dependencies
161+
run: pnpm install --frozen-lockfile
162+
163+
- name: Lint
164+
run: pnpm lint:ci
165+
166+
- name: Report success
167+
if: success()
168+
continue-on-error: true
169+
env:
170+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
171+
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
172+
REPO: ${{ github.repository }}
173+
run: |
174+
gh api "repos/$REPO/statuses/$SHA" \
175+
-f state=success -f context="Lint (Beta)" -f description="Lint passed" \
176+
|| echo "::warning::Failed to report success status on $SHA"
177+
178+
- name: Report failure
179+
if: failure()
180+
continue-on-error: true
181+
env:
182+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
183+
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
184+
REPO: ${{ github.repository }}
185+
run: |
186+
gh api "repos/$REPO/statuses/$SHA" \
187+
-f state=failure -f context="Lint (Beta)" -f description="Lint failed" \
188+
|| echo "::warning::Failed to report failure status on $SHA"
189+
190+
publish:
191+
name: Publish to npm (Beta)
192+
needs: release-please
193+
if: ${{ needs.release-please.outputs.release_created == 'true' }}
194+
runs-on: ubuntu-latest
195+
steps:
196+
- name: Checkout
197+
uses: actions/checkout@v6
198+
with:
199+
ref: ${{ needs.release-please.outputs.tag_name }}
200+
201+
- name: Setup pnpm
202+
uses: pnpm/action-setup@v5
203+
204+
- name: Setup Node.js
205+
uses: actions/setup-node@v6
206+
with:
207+
node-version: 18
208+
cache: pnpm
209+
cache-dependency-path: pnpm-lock.yaml
210+
registry-url: https://registry.npmjs.org
211+
212+
- name: Install dependencies
213+
run: pnpm install --frozen-lockfile
214+
215+
- name: Build
216+
run: pnpm tsup
217+
218+
- name: Publish with provenance (beta)
219+
run: npm publish --provenance --access public --tag beta
220+
env:
221+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
222+
223+
- name: Report publish failure
224+
if: failure()
225+
env:
226+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
227+
TAG: ${{ needs.release-please.outputs.tag_name }}
228+
REPO: ${{ github.repository }}
229+
run: |
230+
echo "::error::npm publish failed for $TAG"
231+
gh release edit "$TAG" --repo "$REPO" \
232+
--notes "$(gh release view "$TAG" --repo "$REPO" --json body --jq .body)
233+
234+
---
235+
> **WARNING**: npm publish failed. Package was NOT published to npm." || true

0 commit comments

Comments
 (0)