Skip to content

Commit 7c9afa0

Browse files
committed
chore: Add pretter
chore: Add github workflows
1 parent 5c620b2 commit 7c9afa0

9 files changed

Lines changed: 337 additions & 1 deletion

File tree

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Description
2+
3+
<!-- Describe your changes in detail -->
4+
5+
## Type of Change
6+
7+
<!-- Mark the relevant option with an "x" -->
8+
9+
- [ ] Feature (new functionality)
10+
- [ ] Bug fix
11+
- [ ] Improvement/Refactor
12+
- [ ] Documentation
13+
- [ ] Dependencies update
14+
15+
## Testing
16+
17+
<!-- Describe how you tested your changes -->
18+
19+
## Checklist
20+
21+
- [ ] Code follows project style guidelines
22+
- [ ] Self-review completed
23+
- [ ] Comments added for complex code
24+
- [ ] Documentation updated (if needed)
25+
- [ ] No new warnings generated
26+

.github/labeler.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Auto-label PRs based on title patterns
2+
# This helps with automatic release notes generation
3+
4+
"type: feature":
5+
- title: ["feat:", "feature:", "add "]
6+
- head: ["feat/", "feature/", "add/"]
7+
8+
"type: bug":
9+
- title: ["fix:", "bug:", "bugfix:", "resolve "]
10+
- head: ["fix/", "bug/", "bugfix/"]
11+
12+
"type: improvement":
13+
- title: ["refactor:", "improve:", "update ", "enhance "]
14+
- head: ["refactor/", "improve/", "update/"]
15+
16+
"type: docs":
17+
- title: ["docs:", "documentation:"]
18+
- head: ["docs/", "documentation/"]
19+
20+
dependencies:
21+
- title: ["deps:", "dependencies:", "bump "]
22+
- head: ["deps/", "dependencies/"]
23+

.github/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- ignore-for-release
5+
authors:
6+
- dependabot
7+
- github-actions
8+
categories:
9+
- title: Features
10+
labels:
11+
- "type: feature"
12+
- title: Bugs
13+
labels:
14+
- "type: bug"
15+
- title: Improvements
16+
labels:
17+
- "type: improvement"
18+
- title: Documentation
19+
labels:
20+
- "type: docs"
21+
- docs
22+
- title: Dependencies
23+
labels:
24+
- dependencies
25+
- dependabot
26+
- title: Other Changes
27+
labels:
28+
- "*"
29+
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Version Bump
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
version:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Configure Git for tag creation
29+
run: |
30+
git config user.name "github-actions[bot]"
31+
git config user.email "github-actions[bot]@users.noreply.github.com"
32+
33+
- name: Create Release Pull Request or Publish
34+
id: changesets
35+
uses: changesets/action@v1
36+
with:
37+
# changeset publish automatically creates git tags in format: package-name@version
38+
# For single package repo, it creates: v1.0.0 format
39+
publish: |
40+
npm run build
41+
npm run release
42+
# Push tags created by changeset publish
43+
git push --follow-tags
44+
version: npm run version
45+
commit: "chore: version packages"
46+
title: "chore: version packages"
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
NPM_TOKEN: ${{ secrets.npm_token }}
50+
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}

.github/workflows/npm-publish.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# ⚠️ THIS WORKFLOW IS DISABLED ⚠️
2+
#
3+
# Versioning and publishing is now handled automatically by changeset-version.yml
4+
# Changesets workflow automatically:
5+
# 1. Creates version bump PR when changesets are merged to master
6+
# 2. Publishes to npm when version bump PR is merged
7+
#
8+
# This workflow is kept for reference but will NOT run automatically.
9+
# If you need manual release via GitHub Release, you can:
10+
# 1. Delete changeset-version.yml
11+
# 2. Uncomment the "on:" section below
12+
# 3. Remove workflow_dispatch
13+
14+
name: Node.js Package (Legacy - Disabled)
15+
16+
# DISABLED - uncomment to enable manual release via GitHub Release
17+
# on:
18+
# release:
19+
# types: [created]
20+
21+
# Only allows manual trigger, prevents automatic execution
22+
on:
23+
workflow_dispatch:
24+
25+
jobs:
26+
build:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: actions/setup-node@v4
31+
with:
32+
node-version: 20
33+
- run: npm ci
34+
- run: npm test
35+
36+
publish-npm:
37+
needs: build
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v4
41+
- uses: actions/setup-node@v4
42+
with:
43+
node-version: 20
44+
registry-url: https://registry.npmjs.org/
45+
- run: npm ci
46+
- run: npm publish
47+
env:
48+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

.github/workflows/pr-labeler.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: PR Labeler
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
jobs:
8+
label:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
pull-requests: write
13+
steps:
14+
- name: Label PR based on title
15+
uses: actions/labeler@v5
16+
with:
17+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
18+
configuration-path: .github/labeler.yml
19+
sync-labels: true
20+
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Backup: Generate Release Notes from commits
2+
# This workflow generates release notes from commits when PRs are not available.
3+
# For PR-based releases, use GitHub's built-in "Generate release notes" button
4+
# which uses .github/release.yml configuration.
5+
6+
name: Generate Release Notes (Backup)
7+
8+
# DISABLED - Using GitHub's built-in "Generate release notes" instead
9+
# This workflow is kept for reference but will NOT run automatically.
10+
# To enable: uncomment the "on:" section below and remove workflow_dispatch
11+
12+
# on:
13+
# release:
14+
# types: [created]
15+
16+
# Only allows manual trigger, prevents automatic execution
17+
on:
18+
workflow_dispatch:
19+
20+
jobs:
21+
generate-release-notes:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: write
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Generate Release Notes from Commits
32+
id: generate_notes
33+
uses: actions/github-script@v7
34+
with:
35+
script: |
36+
const { data: release } = await github.rest.repos.getRelease({
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
release_id: context.payload.release.id,
40+
});
41+
42+
const tagName = release.tag_name;
43+
const previousTag = await github.rest.repos.listTags({
44+
owner: context.repo.owner,
45+
repo: context.repo.repo,
46+
per_page: 2,
47+
});
48+
49+
let previousTagName = '';
50+
if (previousTag.data.length > 1) {
51+
previousTagName = previousTag.data[1].name;
52+
}
53+
54+
// Get commits between tags
55+
const { data: commits } = await github.rest.repos.compareCommits({
56+
owner: context.repo.owner,
57+
repo: context.repo.repo,
58+
base: previousTagName || 'HEAD~50',
59+
head: tagName,
60+
});
61+
62+
// Categorize commits
63+
const breaking = [];
64+
const features = [];
65+
const fixes = [];
66+
const improvements = [];
67+
const docs = [];
68+
const other = [];
69+
70+
commits.commits.forEach(commit => {
71+
const message = commit.commit.message;
72+
const firstLine = message.split('\n')[0];
73+
74+
if (firstLine.toLowerCase().includes('breaking') || firstLine.includes('!:')) {
75+
breaking.push(`- ${firstLine}`);
76+
} else if (firstLine.toLowerCase().startsWith('feat') || firstLine.toLowerCase().includes('feature')) {
77+
features.push(`- ${firstLine}`);
78+
} else if (firstLine.toLowerCase().startsWith('fix') || firstLine.toLowerCase().includes('bug')) {
79+
fixes.push(`- ${firstLine}`);
80+
} else if (firstLine.toLowerCase().startsWith('refactor') || firstLine.toLowerCase().includes('improve')) {
81+
improvements.push(`- ${firstLine}`);
82+
} else if (firstLine.toLowerCase().startsWith('docs') || firstLine.toLowerCase().includes('doc')) {
83+
docs.push(`- ${firstLine}`);
84+
} else if (!firstLine.toLowerCase().startsWith('chore') && !firstLine.toLowerCase().startsWith('ci') && !firstLine.toLowerCase().startsWith('build')) {
85+
other.push(`- ${firstLine}`);
86+
}
87+
});
88+
89+
// Build release notes
90+
let releaseNotes = `## Release ${tagName}\n\n`;
91+
92+
if (breaking.length > 0) {
93+
releaseNotes += `### Breaking Changes\n${breaking.join('\n')}\n\n`;
94+
}
95+
if (features.length > 0) {
96+
releaseNotes += `### New Features\n${features.join('\n')}\n\n`;
97+
}
98+
if (fixes.length > 0) {
99+
releaseNotes += `### Bug Fixes\n${fixes.join('\n')}\n\n`;
100+
}
101+
if (improvements.length > 0) {
102+
releaseNotes += `### Improvements\n${improvements.join('\n')}\n\n`;
103+
}
104+
if (docs.length > 0) {
105+
releaseNotes += `### Documentation\n${docs.join('\n')}\n\n`;
106+
}
107+
if (other.length > 0) {
108+
releaseNotes += `### Other Changes\n${other.join('\n')}\n\n`;
109+
}
110+
111+
if (previousTagName) {
112+
releaseNotes += `\n**Full Changelog**: ${previousTagName}...${tagName}`;
113+
}
114+
115+
// Update release
116+
await github.rest.repos.updateRelease({
117+
owner: context.repo.owner,
118+
repo: context.repo.repo,
119+
release_id: context.payload.release.id,
120+
body: releaseNotes
121+
});
122+
123+
console.log('Release notes generated successfully!');
124+

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"endOfLine": "auto",
3+
"semi": false,
4+
"singleQuote": false,
5+
"tabWidth": 2,
6+
"trailingComma": "es5",
7+
"arrowParens": "always",
8+
"printWidth": 60
9+
}
10+

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@
4040
"prepublishOnly": "medusa plugin:build",
4141
"publish-local": "npx medusa plugin:publish",
4242
"publish-package": "dotenv npm publish --access public",
43-
"email:dev": "email dev --dir emails-previews"
43+
"email:dev": "email dev --dir emails-previews",
44+
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
45+
"format:check": "prettier --check \"src/**/*.{ts,tsx}\"",
46+
"changeset": "changeset",
47+
"version": "changeset version",
48+
"release": "changeset publish",
49+
"release:manual": "npm run build && npm publish --access public"
4450
},
4551
"dependencies": {
4652
"@react-email/components": "^0.3.3",

0 commit comments

Comments
 (0)