Skip to content

Commit cb58b80

Browse files
authored
chore: migrate to monorepo and improve release automation (#6)
* chore: migrate to pnpm workspace * chore: delete exist src folder * Minimize changes * restore * chore: fix package name and changeset configuration for monorepo structure * fix: point getPackageInfo to the @git-intent/core package.json * fix * chore: remove version * chore: remove workflow_dispatch triggers and add automated build test workflow * fix: add permission in build-test * fix: upgrate actions/upload-artifact@v3 to actions/upload-artifact@v4 * fix * chore: remove frozen-lockfile option * chore: build package in build-test ci * chore: setup git user * chore: remove macOS artifact upload and restrict permissions to read-only contents * fix * chore: build test on Node.js versions 18 and 20 * chore: add git user * chore: remove max-parallel * chore: add changeset
1 parent 607a6b7 commit cb58b80

40 files changed

+1274
-1136
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"fixed": [["@git-intent/core", "@git-intent/cli"]],
5+
"linked": [],
6+
"access": "public",
7+
"baseBranch": "main",
8+
"updateInternalDependencies": "patch",
9+
"ignore": []
10+
}

.changeset/plenty-pans-lick.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@git-intent/core": patch
3+
"@git-intent/cli": patch
4+
---
5+
6+
chore: migrate to monorepo and improve release automation

.github/workflows/binary-build.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Binary Build & Release
2+
3+
on:
4+
repository_dispatch:
5+
types: [trigger-binary-build]
6+
7+
permissions:
8+
contents: write
9+
packages: write
10+
11+
jobs:
12+
build:
13+
name: Build Binary
14+
runs-on: ubuntu-latest
15+
outputs:
16+
checksum: ${{ steps.create_checksum.outputs.checksum }}
17+
version: ${{ steps.get_version.outputs.version }}
18+
steps:
19+
- name: Checkout Repo
20+
uses: actions/checkout@v4
21+
22+
- uses: pnpm/action-setup@v4
23+
name: Install pnpm
24+
id: pnpm-install
25+
26+
- name: Setup Node.js 20.x
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: 20.x
30+
cache: "pnpm"
31+
registry-url: "https://registry.npmjs.org"
32+
33+
- name: Install Dependencies
34+
run: pnpm install
35+
36+
- name: Setup Git User
37+
run: |
38+
git config --global user.email "[email protected]"
39+
git config --global user.name "Juhyeok Kang"
40+
41+
- name: Get Version
42+
id: get_version
43+
run: |
44+
echo "version=${{ github.event.client_payload.version }}" >> $GITHUB_OUTPUT
45+
46+
- name: Build Packages
47+
run: pnpm build
48+
49+
- name: Build Binary (macOS)
50+
run: pnpm --filter "@git-intent/cli" pkg:build:macos
51+
52+
- name: Create Checksum
53+
id: create_checksum
54+
run: |
55+
cd packages/cli/build
56+
ls -la
57+
cp git-intent-macos git-intent
58+
VERSION="${{ steps.get_version.outputs.version }}"
59+
tar -czf git-intent-$VERSION-darwin-amd64.tar.gz git-intent
60+
CHECKSUM=$(shasum -a 256 git-intent-$VERSION-darwin-amd64.tar.gz | awk '{print $1}')
61+
echo "checksum=$CHECKSUM" >> $GITHUB_OUTPUT
62+
echo "::notice::Binary checksum: $CHECKSUM"
63+
64+
- name: Create GitHub Release
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
run: |
68+
VERSION="${{ steps.get_version.outputs.version }}"
69+
gh release create v$VERSION \
70+
--title "v$VERSION" \
71+
--generate-notes \
72+
packages/cli/build/git-intent-$VERSION-darwin-amd64.tar.gz
73+
74+
- name: Trigger Homebrew Update
75+
uses: peter-evans/repository-dispatch@v3
76+
with:
77+
token: ${{ secrets.GITHUB_TOKEN }}
78+
event-type: trigger-homebrew-update
79+
client-payload: '{"version": "${{ steps.get_version.outputs.version }}", "sha256": "${{ steps.create_checksum.outputs.checksum }}"}'

.github/workflows/build-test.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: CI - Build & Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
test:
20+
name: Build & Test (OS=${{ matrix.os }}, Node=${{ matrix.node-version }})
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
os: [ubuntu-latest, macos-latest]
26+
node-version: [18.x, 20.x]
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
- name: Configure Git user
32+
run: |
33+
git config user.name "Juhyeok Kang"
34+
git config user.email "[email protected]"
35+
36+
- uses: pnpm/action-setup@v4
37+
name: Install pnpm
38+
id: pnpm-install
39+
40+
- name: Setup Node.js & pnpm cache
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: ${{ matrix.node-version }}
44+
cache: "pnpm"
45+
46+
- name: Install dependencies
47+
run: pnpm install
48+
49+
- name: Build packages
50+
run: pnpm build
51+
52+
- name: Test CLI (Node.js)
53+
run: node packages/cli/dist/index.cjs --version
54+
55+
- name: Build macOS binary
56+
if: runner.os == 'macOS'
57+
run: pnpm --filter "@git-intent/cli" pkg:build:macos
58+
59+
- name: Test macOS binary
60+
if: runner.os == 'macOS'
61+
run: |
62+
chmod +x packages/cli/build/git-intent-macos
63+
./packages/cli/build/git-intent-macos --version

.github/workflows/homebrew-update.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Homebrew Formula Update
2+
3+
on:
4+
repository_dispatch:
5+
types: [trigger-homebrew-update]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
update-formula:
12+
name: Update Homebrew Formula
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Get Version and Checksum
16+
id: get_info
17+
run: |
18+
echo "version=${{ github.event.client_payload.version }}" >> $GITHUB_OUTPUT
19+
echo "checksum=${{ github.event.client_payload.sha256 }}" >> $GITHUB_OUTPUT
20+
21+
- name: Trigger Homebrew Formula Update
22+
uses: peter-evans/repository-dispatch@v3
23+
with:
24+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
25+
repository: offlegacy/homebrew-git-intent
26+
event-type: update-formula
27+
client-payload: '{"version": "${{ steps.get_info.outputs.version }}", "sha256": "${{ steps.get_info.outputs.checksum }}"}'

.github/workflows/release.yml

Lines changed: 29 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,25 @@
1-
name: Release
1+
name: Changeset Release
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
version:
7-
description: "Version to release (e.g., 1.0.0)"
8-
required: true
9-
type: string
10-
skip_npm:
11-
description: 'Skip npm publish'
12-
type: boolean
13-
default: false
14-
skip_homebrew:
15-
description: 'Skip Homebrew formula update'
16-
type: boolean
17-
default: false
4+
push:
5+
branches:
6+
- main
187

198
concurrency: ${{ github.workflow }}-${{ github.ref }}
209

2110
permissions:
2211
contents: write
2312
packages: write
24-
actions: write
13+
pull-requests: write
14+
id-token: write # npm provenance
2515

2616
jobs:
2717
release:
28-
name: Release
18+
name: Changeset Release
2919
runs-on: ubuntu-latest
20+
outputs:
21+
published: ${{ steps.changesets.outputs.published }}
22+
version: ${{ steps.changesets.outputs.version }}
3023
steps:
3124
- name: Checkout Repo
3225
uses: actions/checkout@v4
@@ -43,53 +36,30 @@ jobs:
4336
registry-url: "https://registry.npmjs.org"
4437

4538
- name: Install Dependencies
46-
run: pnpm install --frozen-lockfile
39+
run: pnpm install
4740

48-
- name: Update Version
49-
if: ${{ !inputs.skip_npm }}
41+
- name: Setup Git User
5042
run: |
51-
git config --local user.email "github-actions[bot]@users.noreply.github.com"
52-
git config --local user.name "github-actions[bot]"
53-
npm version ${{ github.event.inputs.version }} -m "Release v%s"
54-
git push origin main
55-
git push --tags
43+
git config --global user.email "[email protected]"
44+
git config --global user.name "Juhyeok Kang"
5645
57-
- name: Build Package
58-
run: pnpm build
59-
60-
- name: Build Binary (macOS)
61-
run: pnpm pkg:build:macos
62-
63-
- name: Create Checksum
64-
id: create_checksum
65-
run: |
66-
cd build
67-
ls -la
68-
cp git-intent-macos git-intent
69-
tar -czf git-intent-${{ github.event.inputs.version }}-darwin-amd64.tar.gz git-intent
70-
echo "checksum=$(shasum -a 256 git-intent-${{ github.event.inputs.version }}-darwin-amd64.tar.gz | awk '{print $1}')" >> $GITHUB_OUTPUT
71-
72-
- name: Publish to npm
73-
if: ${{ !inputs.skip_npm }}
74-
run: pnpm publish --no-git-checks
75-
env:
76-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
77-
78-
- name: Create GitHub Release
79-
if: ${{ !inputs.skip_npm }}
46+
- name: Create Release Pull Request or Publish to npm
47+
id: changesets
48+
uses: changesets/action@v1
49+
with:
50+
publish: pnpm release
51+
version: pnpm version-packages
52+
commit: "chore: version packages"
53+
title: "chore: version packages"
8054
env:
8155
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82-
run: |
83-
gh release create v${{ github.event.inputs.version }} \
84-
--title "v${{ github.event.inputs.version }}" \
85-
--generate-notes \
86-
build/git-intent-${{ github.event.inputs.version }}-darwin-amd64.tar.gz
56+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
8757

88-
- name: Update Homebrew formula
89-
if: ${{ !inputs.skip_homebrew }}
58+
# Dispatch to other workflows if published
59+
- name: Trigger Binary Build
60+
if: steps.changesets.outputs.published == 'true'
9061
uses: peter-evans/repository-dispatch@v3
9162
with:
92-
token: ${{ secrets.PAT }}
93-
repository: offlegacy/homebrew-git-intent
94-
event-type: update-formula
95-
client-payload: '{"version": "${{ github.event.inputs.version }}", "sha256": "${{ steps.create_checksum.outputs.checksum }}"}'
63+
token: ${{ secrets.GITHUB_TOKEN }}
64+
event-type: trigger-binary-build
65+
client-payload: '{"version": "${{ steps.changesets.outputs.version }}"}'

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
build
22
dist
3-
node_modules
3+
node_modules
4+
5+
.turbo

package.json

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "git-intent",
3-
"version": "0.0.10",
43
"description": "Git workflow tool for intentional commits — define your commit intentions first for clearer, more atomic changes.",
4+
"private": true,
55
"keywords": [
66
"git",
77
"intentional-commits",
@@ -13,49 +13,24 @@
1313
"todo-driven"
1414
],
1515
"license": "MIT",
16-
"files": ["dist"],
17-
"type": "module",
18-
"bin": {
19-
"git-intent": "./dist/index.cjs"
20-
},
21-
"publishConfig": {
22-
"access": "public",
23-
"registry": "https://registry.npmjs.org/"
24-
},
16+
"packageManager": "[email protected]",
2517
"scripts": {
26-
"dev": "tsup --watch",
27-
"build": "tsup",
28-
"start": "node dist/index.cjs",
18+
"dev": "turbo dev",
19+
"build": "turbo build",
2920
"format": "biome format",
3021
"format:fix": "biome format --write",
31-
"pkg:build:macos": "pkg . --no-bytecode -t node18-macos-arm64 -o build/git-intent-macos",
32-
"test": "vitest",
33-
"test:ui": "vitest --ui"
34-
},
35-
"pkg": {
36-
"assets": ["dist/**/*"],
37-
"outputPath": "build"
38-
},
39-
"dependencies": {
40-
"chalk": "^4.1.2",
41-
"commander": "^13.1.0",
42-
"external-editor": "^3.1.0",
43-
"fs-extra": "^11.3.0",
44-
"nanoid": "^3.3.7",
45-
"ora": "^5.4.1",
46-
"prompts": "^2.4.2",
47-
"simple-git": "^3.27.0"
22+
"test": "turbo test",
23+
"clean": "turbo clean",
24+
"changeset": "changeset",
25+
"version-packages": "changeset version",
26+
"release": "turbo build && changeset publish",
27+
"cli": "pnpm --filter=@git-intent/cli start"
4828
},
4929
"devDependencies": {
5030
"@biomejs/biome": "^1.9.4",
51-
"@types/fs-extra": "^11.0.4",
52-
"@types/node": "^20.11.24",
53-
"@types/prompts": "^2.4.9",
54-
"pkg": "^5.8.1",
55-
"tsup": "^8.0.2",
56-
"type-fest": "^4.39.1",
57-
"typescript": "^5.3.3",
58-
"vitest": "^1.3.1"
59-
},
60-
"packageManager": "[email protected]"
31+
"@changesets/cli": "^2.29.2",
32+
"tsup": "^8.4.0",
33+
"turbo": "^2.5.2",
34+
"typescript": "^5.8.3"
35+
}
6136
}

0 commit comments

Comments
 (0)