Skip to content

Commit 72ce552

Browse files
committed
ci: publish
1 parent 1f69307 commit 72ce552

12 files changed

Lines changed: 561 additions & 42 deletions

File tree

.github/workflows/publish.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish to npm
1+
name: Publish
22

33
on:
44
workflow_dispatch:
@@ -93,10 +93,19 @@ jobs:
9393
if: ${{ inputs.dry-run }}
9494
run: pnpm publish:dry
9595

96-
- name: Publish to npm
96+
- name: Ensure npm 11.5.1 or later
9797
if: ${{ !inputs.dry-run }}
98-
run: pnpm publish:packages --provenance --no-git-checks
99-
# Trusted Publishers (OIDC) 사용으로 NODE_AUTH_TOKEN 불필요
98+
run: npm install -g npm@latest
99+
100+
- name: Publish kstyled to npm
101+
if: ${{ !inputs.dry-run }}
102+
run: npm publish --access public --provenance
103+
working-directory: ./packages/kstyled
104+
105+
- name: Publish babel-plugin-kstyled to npm
106+
if: ${{ !inputs.dry-run }}
107+
run: npm publish --access public --provenance
108+
working-directory: ./packages/babel-plugin-kstyled
100109

101110
- name: Push changes
102111
if: ${{ !inputs.dry-run }}
@@ -105,12 +114,14 @@ jobs:
105114
git push origin v${{ steps.version.outputs.VERSION }}
106115
107116
- name: Create GitHub Release
108-
if: ${{ !inputs.dry-run }}
109-
uses: actions/create-release@v1
110-
env:
111-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117+
if: ${{ !inputs.dry-run && steps.version.outputs.VERSION }}
118+
uses: softprops/action-gh-release@v2
112119
with:
113120
tag_name: v${{ steps.version.outputs.VERSION }}
114-
release_name: Release v${{ steps.version.outputs.VERSION }}
121+
name: v${{ steps.version.outputs.VERSION }}
115122
draft: false
116123
prerelease: false
124+
generate_release_notes: true
125+
env:
126+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127+

CONTRIBUTING.md

Lines changed: 67 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -268,34 +268,66 @@ bun run dev
268268

269269
### Publishing a New Version
270270

271-
1. **Update package versions**
271+
We support two methods for publishing: **GitHub Actions (Recommended)** and **Manual**.
272272

273-
**Option A: Automatic (Recommended)**
273+
#### Method 1: GitHub Actions (Recommended)
274274

275-
Use the version scripts to automatically bump versions in both packages:
275+
The easiest way to publish is using the automated GitHub Actions workflow:
276276

277-
```bash
278-
pnpm version:patch # 0.1.2 → 0.1.3 (bug fixes)
279-
pnpm version:minor # 0.1.3 → 0.2.0 (new features)
280-
pnpm version:major # 0.2.0 → 1.0.0 (breaking changes)
281-
```
277+
1. **Go to GitHub Actions**
278+
279+
Navigate to: `https://github.com/hyodotdev/kstyled/actions/workflows/publish.yml`
280+
281+
2. **Run workflow**
282+
283+
- Click "Run workflow"
284+
- Select branch: `main`
285+
- Choose version bump type:
286+
- `patch` - Bug fixes (0.3.0 → 0.3.1)
287+
- `minor` - New features (0.3.0 → 0.4.0)
288+
- `major` - Breaking changes (0.3.0 → 1.0.0)
289+
- Optional: Check "Dry run" to test without publishing
282290

283-
This updates both `kstyled` and `babel-plugin-kstyled` at once.
291+
3. **Wait for completion**
284292

285-
**Option B: Manual**
293+
The workflow will automatically:
294+
- ✅ Build all packages
295+
- ✅ Run type checking and tests
296+
- ✅ Bump versions in both packages
297+
- ✅ Commit and push changes
298+
- ✅ Publish to npm (with OIDC authentication)
299+
- ✅ Create git tag
300+
- ✅ Create GitHub Release with auto-generated notes
286301

287-
Manually edit version in both packages:
288-
- `packages/kstyled/package.json`
289-
- `packages/babel-plugin-kstyled/package.json`
302+
4. **Verify**
290303

291-
Example: `"version": "0.1.3"`
304+
Check that:
305+
- New version appears on npm
306+
- GitHub Release is created
307+
- Git tag is pushed
292308

293-
> **Note**: The root `package.json` version is for development only and doesn't affect npm publishing.
309+
**Note**: The workflow uses OpenID Connect (OIDC) for npm authentication, so no NPM_TOKEN is needed.
310+
311+
#### Method 2: Manual Publishing
312+
313+
If you need to publish manually:
314+
315+
1. **Update package versions**
316+
317+
Use the version scripts to automatically bump versions in both packages:
318+
319+
```bash
320+
pnpm version:patch # 0.3.0 → 0.3.1 (bug fixes)
321+
pnpm version:minor # 0.3.0 → 0.4.0 (new features)
322+
pnpm version:major # 0.3.0 → 1.0.0 (breaking changes)
323+
```
324+
325+
This updates both `kstyled` and `babel-plugin-kstyled` at once using the custom `scripts/bump-version.js` script.
294326

295327
2. **Build and test everything**
296328

297329
```bash
298-
pnpm build && pnpm typecheck && pnpm lint
330+
pnpm build && pnpm typecheck && pnpm test
299331
```
300332

301333
Make sure all checks pass with 0 errors.
@@ -304,7 +336,8 @@ bun run dev
304336

305337
```bash
306338
git add packages/*/package.json
307-
git commit -m "chore: bump version to 0.1.3"
339+
git commit -m "chore: release v0.3.1"
340+
git tag v0.3.1
308341
```
309342

310343
4. **Verify npm login**
@@ -339,35 +372,40 @@ bun run dev
339372
pnpm publish:packages
340373
```
341374

342-
This publishes both `kstyled` and `babel-plugin-kstyled` to npm with public access as the `latest` version.
343-
344-
**Option B: Beta/Preview Release (next tag)**
375+
For provenance (recommended):
345376

346377
```bash
347-
pnpm publish:packages --tag next
378+
pnpm publish:packages --provenance
348379
```
349380

350-
This publishes both packages with the `next` tag, allowing users to test pre-release versions without affecting the stable `latest` version:
381+
This publishes both `kstyled` and `babel-plugin-kstyled` to npm with public access as the `latest` version.
382+
383+
**Option B: Beta/Preview Release (next tag)**
351384

352385
```bash
353-
# Users can install the next version with:
354-
npm install kstyled@next babel-plugin-kstyled@next
386+
pnpm publish:packages --tag next
355387
```
356388

357389
Use this for:
358390
- Testing major changes before stable release
359391
- Preview releases for early adopters
360392
- Release candidates (e.g., `0.3.0-rc.1`)
361393

362-
7. **Create and push git tag**
394+
7. **Push changes and tags**
363395

364396
```bash
365-
git tag v0.1.3
366-
git push
367-
git push --tags
397+
git push origin main
398+
git push origin v0.3.1
368399
```
369400

370-
8. **Verify publication**
401+
8. **Create GitHub Release (optional)**
402+
403+
Go to: `https://github.com/hyodotdev/kstyled/releases/new`
404+
- Select the tag you just pushed
405+
- Generate release notes automatically
406+
- Publish release
407+
408+
9. **Verify publication**
371409

372410
```bash
373411
npm view kstyled version

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export default function App() {
5454

5555
- ⚡️ **Zero runtime** - Styles compiled to `StyleSheet.create` at build time
5656
- 🎨 **Familiar API** - styled-components syntax you already know
57+
-**Flexible syntax** - Supports `${16}px`, `${'16px'}`, and `${16}` (unlike styled-components/emotion)
5758
- 🎭 **Theme support** - Built-in ThemeProvider with TypeScript
5859
- 💪 **Full TypeScript** - Complete type inference
5960
- 📦 **Tiny bundle** - Minimal runtime code

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@
3636
"prepublish": "pnpm build && pnpm typecheck && pnpm test",
3737
"publish:packages": "pnpm publish -r --filter '!example' --filter '!kstyled-docs' --access public",
3838
"publish:dry": "pnpm publish -r --filter '!example' --filter '!kstyled-docs' --access public --dry-run",
39-
"version:patch": "pnpm -r --filter '!example' --filter '!kstyled-docs' exec npm version patch --no-git-tag-version",
40-
"version:minor": "pnpm -r --filter '!example' --filter '!kstyled-docs' exec npm version minor --no-git-tag-version",
41-
"version:major": "pnpm -r --filter '!example' --filter '!kstyled-docs' exec npm version major --no-git-tag-version"
39+
"version:patch": "node scripts/bump-version.js patch",
40+
"version:minor": "node scripts/bump-version.js minor",
41+
"version:major": "node scripts/bump-version.js major",
42+
"version:get": "node -p \"require('./packages/kstyled/package.json').version\""
4243
},
4344
"devDependencies": {
4445
"@turbo/gen": "^2.3.3",

packages/babel-plugin-kstyled/src/__tests__/transform.test.ts

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,107 @@ describe('babel-plugin-kstyled', () => {
328328
});
329329
});
330330

331+
describe('Template Literal Interpolation with Units', () => {
332+
test('should handle interpolation with px unit suffix', () => {
333+
const input = `
334+
import { styled } from 'kstyled';
335+
import { View } from 'react-native';
336+
337+
const Box = styled(View)\`
338+
width: \${({$size = 'medium'}) =>
339+
$size === 'small' ? 16 : $size === 'large' ? 24 : 20}px;
340+
height: \${({$size = 'medium'}) =>
341+
$size === 'small' ? 16 : $size === 'large' ? 24 : 20}px;
342+
border-radius: \${({$size = 'medium'}) =>
343+
$size === 'small' ? 8 : $size === 'large' ? 12 : 10}px;
344+
\`;
345+
`;
346+
347+
const output = transform(input);
348+
349+
// Should contain width, height, borderRadius
350+
expect(output).toContain('width');
351+
expect(output).toContain('height');
352+
expect(output).toContain('borderRadius');
353+
// The px suffix should be stripped automatically
354+
// Values should be numbers, not strings with 'px'
355+
expect(output).not.toContain('px');
356+
expect(output).toBeDefined();
357+
});
358+
359+
test('should handle simple interpolation with px unit', () => {
360+
const input = `
361+
import { styled } from 'kstyled';
362+
import { View } from 'react-native';
363+
364+
const SIZE = 16;
365+
const Box = styled(View)\`
366+
width: \${SIZE}px;
367+
height: \${SIZE}px;
368+
\`;
369+
`;
370+
371+
const output = transform(input);
372+
373+
expect(output).toContain('width');
374+
expect(output).toContain('height');
375+
// px should be stripped from interpolations
376+
expect(output).not.toContain('px');
377+
expect(output).toBeDefined();
378+
});
379+
380+
test('should handle multiple units in interpolations', () => {
381+
const input = `
382+
import { styled } from 'kstyled';
383+
import { Text } from 'react-native';
384+
385+
const FONT_SIZE = 14;
386+
const LINE_HEIGHT = 20;
387+
const Label = styled(Text)\`
388+
font-size: \${FONT_SIZE}px;
389+
line-height: \${LINE_HEIGHT}px;
390+
letter-spacing: \${0.5}px;
391+
\`;
392+
`;
393+
394+
const output = transform(input);
395+
396+
expect(output).toContain('fontSize');
397+
expect(output).toContain('lineHeight');
398+
expect(output).toContain('letterSpacing');
399+
// All px units should be stripped
400+
expect(output).not.toContain('px');
401+
});
402+
403+
test('should handle string values with px units from functions', () => {
404+
const input = `
405+
import { styled } from 'kstyled';
406+
import { View } from 'react-native';
407+
408+
const Box = styled(View)\`
409+
width: \${({$size = 'medium'}) =>
410+
$size === 'small' ? '16px' : $size === 'large' ? '24px' : '20px'};
411+
height: \${({$size = 'medium'}) =>
412+
$size === 'small' ? '16px' : $size === 'large' ? '24px' : '20px'};
413+
border-radius: \${({$size = 'medium'}) =>
414+
$size === 'small' ? '8px' : $size === 'large' ? '12px' : '10px'};
415+
\`;
416+
`;
417+
418+
const output = transform(input);
419+
420+
expect(output).toContain('width');
421+
expect(output).toContain('height');
422+
expect(output).toContain('borderRadius');
423+
// String values like '16px' are preserved in the function
424+
// They will be normalized at runtime by normalizeStyleValue
425+
expect(output).toContain('16px');
426+
expect(output).toContain('24px');
427+
expect(output).toContain('20px');
428+
expect(output).toBeDefined();
429+
});
430+
});
431+
331432
describe('Comprehensive React Native Property Support', () => {
332433
test('should support all ViewStyle border properties', () => {
333434
const input = `

0 commit comments

Comments
 (0)