Skip to content

Commit 1f69307

Browse files
committed
ci: use oidc connect to deploy pkg
1 parent f8d790b commit 1f69307

1 file changed

Lines changed: 116 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Publish to npm
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version bump type'
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
dry-run:
15+
description: 'Dry run (test without publishing)'
16+
required: false
17+
type: boolean
18+
default: false
19+
20+
permissions:
21+
contents: write
22+
id-token: write
23+
24+
jobs:
25+
publish:
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
token: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Setup Node.js
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: '20'
39+
registry-url: 'https://registry.npmjs.org'
40+
# Trusted Publishers (OIDC) 사용 - NPM_TOKEN 불필요
41+
42+
- name: Setup pnpm
43+
uses: pnpm/action-setup@v4
44+
45+
- name: Configure git
46+
run: |
47+
git config user.name "github-actions[bot]"
48+
git config user.email "github-actions[bot]@users.noreply.github.com"
49+
50+
- name: Install dependencies
51+
run: pnpm install --frozen-lockfile
52+
53+
- name: Build packages
54+
run: pnpm build
55+
56+
- name: Run type check
57+
run: pnpm typecheck
58+
59+
- name: Run tests
60+
run: pnpm test
61+
62+
- name: Bump version
63+
if: ${{ !inputs.dry-run }}
64+
run: |
65+
case "${{ inputs.version }}" in
66+
patch)
67+
pnpm version:patch
68+
;;
69+
minor)
70+
pnpm version:minor
71+
;;
72+
major)
73+
pnpm version:major
74+
;;
75+
esac
76+
77+
- name: Get new version
78+
if: ${{ !inputs.dry-run }}
79+
id: version
80+
run: |
81+
VERSION=$(node -p "require('./packages/kstyled/package.json').version")
82+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
83+
echo "New version: $VERSION"
84+
85+
- name: Commit version bump
86+
if: ${{ !inputs.dry-run }}
87+
run: |
88+
git add .
89+
git commit -m "chore: release v${{ steps.version.outputs.VERSION }}"
90+
git tag v${{ steps.version.outputs.VERSION }}
91+
92+
- name: Publish to npm (dry-run)
93+
if: ${{ inputs.dry-run }}
94+
run: pnpm publish:dry
95+
96+
- name: Publish to npm
97+
if: ${{ !inputs.dry-run }}
98+
run: pnpm publish:packages --provenance --no-git-checks
99+
# Trusted Publishers (OIDC) 사용으로 NODE_AUTH_TOKEN 불필요
100+
101+
- name: Push changes
102+
if: ${{ !inputs.dry-run }}
103+
run: |
104+
git push origin main
105+
git push origin v${{ steps.version.outputs.VERSION }}
106+
107+
- name: Create GitHub Release
108+
if: ${{ !inputs.dry-run }}
109+
uses: actions/create-release@v1
110+
env:
111+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112+
with:
113+
tag_name: v${{ steps.version.outputs.VERSION }}
114+
release_name: Release v${{ steps.version.outputs.VERSION }}
115+
draft: false
116+
prerelease: false

0 commit comments

Comments
 (0)