Skip to content

Commit 211205d

Browse files
committed
feat(core): management commands
1 parent ae9166a commit 211205d

7 files changed

Lines changed: 674 additions & 96 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
tags: [ 'v*' ]
7+
pull_request:
8+
branches: [ main ]
9+
10+
permissions:
11+
contents: read
12+
packages: write
13+
deployments: write
14+
15+
jobs:
16+
test:
17+
name: Test
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Go
24+
uses: actions/setup-go@v4
25+
with:
26+
go-version: '1.21'
27+
cache: true
28+
29+
- name: Download dependencies
30+
run: go mod download
31+
32+
- name: Run tests
33+
run: go test -v -race -coverprofile=coverage.out ./...
34+
35+
- name: Upload coverage to Codecov
36+
uses: codecov/codecov-action@v3
37+
with:
38+
file: ./coverage.out
39+
flags: unittests
40+
name: codecov-umbrella
41+
42+
lint:
43+
name: Lint
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout code
47+
uses: actions/checkout@v4
48+
49+
- name: Set up Go
50+
uses: actions/setup-go@v4
51+
with:
52+
go-version: '1.21'
53+
cache: true
54+
55+
- name: Run golangci-lint
56+
uses: golangci/golangci-lint-action@v6
57+
with:
58+
version: v1.64.8
59+
args: --timeout=5m --config-path .golangci.yml
60+
61+
build:
62+
name: Build
63+
runs-on: ubuntu-latest
64+
needs: [test, lint]
65+
if: github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop'
66+
steps:
67+
- name: Checkout code
68+
uses: actions/checkout@v4
69+
70+
- name: Set up Go
71+
uses: actions/setup-go@v4
72+
with:
73+
go-version: '1.21'
74+
cache: true
75+
76+
- name: Build binary
77+
run: make build
78+
79+
- name: Upload build artifact
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: commitgen-binary
83+
path: commitgen
84+
retention-days: 7
85+
86+
npm-build:
87+
name: NPM Build
88+
runs-on: ubuntu-latest
89+
needs: [test, lint]
90+
steps:
91+
- name: Checkout code
92+
uses: actions/checkout@v4
93+
94+
- name: Set up Node.js
95+
uses: actions/setup-node@v4
96+
with:
97+
node-version: '18'
98+
cache: 'npm'
99+
100+
- name: Install npm dependencies
101+
run: |
102+
npm install
103+
npm install -g pkg
104+
105+
- name: Build npm package
106+
run: |
107+
npm run build
108+
pkg . -t node18-linux-x64 -o commitgen-npm-linux
109+
110+
- name: Upload npm artifact
111+
uses: actions/upload-artifact@v4
112+
with:
113+
name: commitgen-npm-linux
114+
path: commitgen-npm-linux
115+
retention-days: 7
116+
117+
release:
118+
name: Release
119+
runs-on: ubuntu-latest
120+
if: startsWith(github.ref, 'refs/tags/v')
121+
needs: [test, lint, build, npm-build]
122+
steps:
123+
- name: Checkout code
124+
uses: actions/checkout@v4
125+
with:
126+
fetch-depth: 0
127+
128+
- name: Set up Go
129+
uses: actions/setup-go@v4
130+
with:
131+
go-version: '1.21'
132+
cache: true
133+
134+
- name: Run GoReleaser
135+
uses: goreleaser/goreleaser-action@v5
136+
with:
137+
distribution: goreleaser
138+
version: latest
139+
args: release --clean --skip-sign
140+
env:
141+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
142+
143+
- name: Publish to npm
144+
uses: actions/setup-node@v4
145+
with:
146+
node-version: '18'
147+
cache: 'npm'
148+
registry-url: 'https://registry.npmjs.org'
149+
always-auth: true
150+
env:
151+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
152+
153+
- name: Publish npm package
154+
run: |
155+
npm install
156+
npm run build
157+
npm publish
158+
env:
159+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,37 @@ jobs:
7474

7575
- name: Test current release binary (if tagged)
7676
if: startsWith(github.ref, 'refs/tags/')
77+
78+
npm-build:
79+
name: NPM Build
80+
runs-on: ubuntu-latest
81+
needs: [test, lint]
82+
steps:
83+
- name: Checkout code
84+
uses: actions/checkout@v4
85+
86+
- name: Set up Node.js
87+
uses: actions/setup-node@v4
88+
with:
89+
node-version: '18'
90+
cache: 'npm'
91+
92+
- name: Install npm dependencies
93+
run: |
94+
npm install
95+
npm install -g pkg
96+
97+
- name: Build npm package
98+
run: |
99+
npm run build
100+
pkg . -t node18-linux-x64 -o commitgen-npm-linux
101+
102+
- name: Upload npm artifact
103+
uses: actions/upload-artifact@v4
104+
with:
105+
name: commitgen-npm-linux
106+
path: commitgen-npm-linux
107+
retention-days: 7
77108
run: |
78109
# Download and test the released binary
79110
VERSION=${GITHUB_REF#refs/tags/}

.npmignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.github/
2+
.gitignore
3+
*.log
4+
coverage.out
5+
*.tar.gz
6+
*.zip
7+
*.deb
8+
*.rpm
9+
.DS_Store
10+
.env
11+
.env.local
12+
.env.development.local
13+
.env.test.local
14+
.env.production.local
15+
npm-debug.log*
16+
yarn-debug.log*
17+
yarn-error.log*
18+
LICENSE
19+
Dockerfile
20+
Makefile
21+
.go.sum
22+
.go.mod
23+
.goreleaser.yml
24+
.golangci.yml
25+
packaging/
26+
homebrew/
27+
install.sh
28+
install-package.sh
29+
install-package.sh
30+
test-installation.sh
31+
*.md
32+
*.txt
33+
*.out

0 commit comments

Comments
 (0)