Skip to content

Commit 87af92d

Browse files
extracted from frontmcp
0 parents  commit 87af92d

31 files changed

Lines changed: 11640 additions & 0 deletions
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
name: Create release branch (next/{semver})
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump:
7+
description: "Semver bump"
8+
required: true
9+
type: choice
10+
options: [patch, minor, major]
11+
default: patch
12+
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
17+
jobs:
18+
create:
19+
runs-on: ubuntu-latest
20+
environment: release
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Setup Node
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version-file: ".nvmrc"
32+
cache: "yarn"
33+
34+
- name: Install deps
35+
run: yarn install --frozen-lockfile
36+
37+
- name: Configure git user
38+
run: |
39+
git config user.name "agentfront[bot]"
40+
git config user.email "agentfront[bot]@users.noreply.github.com"
41+
42+
- name: Compute next version
43+
id: next
44+
shell: bash
45+
run: |
46+
set -euo pipefail
47+
BUMP="${{ inputs.bump }}"
48+
49+
CURRENT=$(node -e "console.log(require('./package.json').version)")
50+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
51+
52+
if [ "$BUMP" = "major" ]; then
53+
MAJOR=$((MAJOR + 1))
54+
MINOR=0
55+
PATCH=0
56+
elif [ "$BUMP" = "minor" ]; then
57+
MINOR=$((MINOR + 1))
58+
PATCH=0
59+
else
60+
PATCH=$((PATCH + 1))
61+
fi
62+
63+
NEXT="$MAJOR.$MINOR.$PATCH"
64+
echo "Current: $CURRENT, Next: $NEXT"
65+
echo "value=$NEXT" >> "$GITHUB_OUTPUT"
66+
67+
- name: Get last release tag
68+
id: last_tag
69+
shell: bash
70+
run: |
71+
LAST_TAG=$(git tag --list "v*" --sort=-version:refname | head -n1 || echo "")
72+
if [ -z "$LAST_TAG" ]; then
73+
LAST_TAG=$(git rev-list --max-parents=0 HEAD)
74+
fi
75+
echo "tag=$LAST_TAG" >> "$GITHUB_OUTPUT"
76+
echo "Last tag: $LAST_TAG"
77+
78+
- name: Create branch next/${{ steps.next.outputs.value }}
79+
shell: bash
80+
run: |
81+
NEXT="${{ steps.next.outputs.value }}"
82+
git switch -c "next/$NEXT"
83+
84+
- name: Bump version in package.json
85+
shell: bash
86+
run: |
87+
NEXT="${{ steps.next.outputs.value }}"
88+
node -e "
89+
const fs = require('fs');
90+
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
91+
pkg.version = '$NEXT';
92+
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
93+
"
94+
95+
- name: Generate changelog entry
96+
shell: bash
97+
run: |
98+
set -euo pipefail
99+
NEXT="${{ steps.next.outputs.value }}"
100+
LAST_TAG="${{ steps.last_tag.outputs.tag }}"
101+
TODAY=$(date -u +"%Y-%m-%d")
102+
103+
# Get commits since last tag
104+
COMMITS=$(git log "$LAST_TAG"...HEAD --oneline --no-merges 2>/dev/null || echo "Initial release")
105+
106+
# Generate changelog entry
107+
ENTRY="## [$NEXT] - $TODAY
108+
109+
### Changes
110+
"
111+
# Parse commits into categories
112+
FEATURES=""
113+
FIXES=""
114+
OTHER=""
115+
116+
while IFS= read -r line; do
117+
if [ -z "$line" ]; then continue; fi
118+
commit_msg="${line#* }"
119+
if [[ "$commit_msg" =~ ^feat ]]; then
120+
FEATURES+="- ${commit_msg#feat: }
121+
"
122+
elif [[ "$commit_msg" =~ ^fix ]]; then
123+
FIXES+="- ${commit_msg#fix: }
124+
"
125+
else
126+
OTHER+="- $commit_msg
127+
"
128+
fi
129+
done <<< "$COMMITS"
130+
131+
if [ -n "$FEATURES" ]; then
132+
ENTRY+="
133+
#### Added
134+
$FEATURES"
135+
fi
136+
137+
if [ -n "$FIXES" ]; then
138+
ENTRY+="
139+
#### Fixed
140+
$FIXES"
141+
fi
142+
143+
if [ -n "$OTHER" ]; then
144+
ENTRY+="
145+
#### Other
146+
$OTHER"
147+
fi
148+
149+
# Prepend to CHANGELOG.md
150+
if [ -f "CHANGELOG.md" ]; then
151+
echo "$ENTRY" > CHANGELOG.new.md
152+
echo "" >> CHANGELOG.new.md
153+
cat CHANGELOG.md >> CHANGELOG.new.md
154+
mv CHANGELOG.new.md CHANGELOG.md
155+
else
156+
echo "# Changelog
157+
158+
$ENTRY" > CHANGELOG.md
159+
fi
160+
161+
- name: Commit release preparation
162+
shell: bash
163+
run: |
164+
NEXT="${{ steps.next.outputs.value }}"
165+
git add -A
166+
git commit -m "chore(release): prepare v$NEXT"
167+
168+
- name: Push branch
169+
shell: bash
170+
run: |
171+
NEXT="${{ steps.next.outputs.value }}"
172+
git push --set-upstream origin "next/$NEXT"
173+
174+
- name: Open PR
175+
env:
176+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
177+
shell: bash
178+
run: |
179+
NEXT="${{ steps.next.outputs.value }}"
180+
181+
gh pr create \
182+
--base "main" \
183+
--head "next/$NEXT" \
184+
--title "v$NEXT" \
185+
--body "Release v$NEXT
186+
187+
## Checklist
188+
- [ ] Review changelog
189+
- [ ] Verify version bump is correct
190+
- [ ] Tests pass"
191+
192+
- name: Summary
193+
run: |
194+
echo "✅ Created branch: next/${{ steps.next.outputs.value }}"
195+
echo "➡️ Bump: ${{ inputs.bump }}"
196+
echo "📦 PR title: v${{ steps.next.outputs.value }}"
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Publish on next/* merge
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
permissions:
8+
contents: write
9+
id-token: write
10+
11+
concurrency:
12+
group: publish-${{ github.event.pull_request.number || github.run_id }}
13+
cancel-in-progress: false
14+
15+
jobs:
16+
publish:
17+
if: >
18+
github.event.pull_request.merged == true &&
19+
startsWith(github.event.pull_request.head.ref, 'next/')
20+
runs-on: ubuntu-latest
21+
environment: npm
22+
23+
steps:
24+
- name: Determine release ref
25+
id: release_ref
26+
shell: bash
27+
env:
28+
MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }}
29+
run: |
30+
if [ -n "$MERGE_SHA" ] && [ "$MERGE_SHA" != "null" ]; then
31+
echo "ref=$MERGE_SHA" >> "$GITHUB_OUTPUT"
32+
else
33+
echo "ref=main" >> "$GITHUB_OUTPUT"
34+
fi
35+
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
with:
39+
fetch-depth: 0
40+
ref: ${{ steps.release_ref.outputs.ref }}
41+
42+
- name: Setup Node
43+
uses: actions/setup-node@v4
44+
with:
45+
node-version-file: ".nvmrc"
46+
cache: "yarn"
47+
registry-url: "https://registry.npmjs.org/"
48+
49+
- name: Update npm for trusted publishing
50+
run: npm install -g npm@latest
51+
52+
- name: Install dependencies
53+
run: yarn install --frozen-lockfile
54+
55+
- name: Configure git
56+
run: |
57+
git config user.name "agentfront[bot]"
58+
git config user.email "agentfront[bot]@users.noreply.github.com"
59+
60+
- name: Determine version from branch
61+
id: version
62+
shell: bash
63+
env:
64+
HEAD_REF: ${{ github.event.pull_request.head.ref }}
65+
run: |
66+
if [[ "$HEAD_REF" =~ ^next/([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
67+
VERSION="${BASH_REMATCH[1]}"
68+
else
69+
VERSION=$(node -e "console.log(require('./package.json').version)")
70+
fi
71+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
72+
echo "Release version: $VERSION"
73+
74+
- name: Create and push git tag
75+
shell: bash
76+
run: |
77+
VERSION="${{ steps.version.outputs.version }}"
78+
TAG="v$VERSION"
79+
80+
git fetch --tags
81+
if git rev-parse "$TAG" >/dev/null 2>&1; then
82+
echo "Tag $TAG already exists"
83+
else
84+
git tag -a "$TAG" -m "Release $TAG"
85+
git push origin "$TAG"
86+
fi
87+
88+
- name: Build
89+
run: yarn build
90+
91+
- name: Test
92+
run: yarn test
93+
94+
- name: Publish to npm
95+
run: npm publish --provenance --access public
96+
97+
- name: Create GitHub Release
98+
uses: softprops/action-gh-release@v2
99+
with:
100+
tag_name: v${{ steps.version.outputs.version }}
101+
name: v${{ steps.version.outputs.version }}
102+
generate_release_notes: true
103+
env:
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
106+
- name: Summary
107+
run: |
108+
echo "✅ Published: v${{ steps.version.outputs.version }}"
109+
echo "🏷️ Tag: v${{ steps.version.outputs.version }}"

.github/workflows/push.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ci-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build-and-test:
15+
name: "Build & Test"
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
node-version: [18.x, 20.x, 22.x, 24.x]
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Setup Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
cache: 'yarn'
28+
29+
- name: Install dependencies
30+
run: yarn install --frozen-lockfile
31+
32+
- name: Build
33+
run: yarn build
34+
35+
- name: Test
36+
run: yarn test

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output
5+
dist/
6+
7+
# Coverage
8+
coverage/
9+
10+
# IDE
11+
.idea/
12+
.vscode/
13+
*.swp
14+
*.swo
15+
16+
# OS
17+
.DS_Store
18+
Thumbs.db
19+
20+
# Logs
21+
*.log
22+
npm-debug.log*
23+
yarn-debug.log*
24+
yarn-error.log*
25+
26+
# Environment
27+
.env
28+
.env.local
29+
.env.*.local
30+
31+
# Temporary files
32+
tmp/
33+
temp/
34+
*.tmp

0 commit comments

Comments
 (0)