Skip to content

Commit 3abed3e

Browse files
authored
feat: migrate to typescript (#1)
1 parent 5ba4dd6 commit 3abed3e

31 files changed

+2225
-1504
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 69 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
- cron: '0 0 * * 1' # Run weekly on Mondays for security checks
10+
11+
permissions:
12+
security-events: write
13+
contents: read
14+
15+
jobs:
16+
quality:
17+
name: Type Check & Build
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '22'
27+
cache: 'npm'
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Type check
33+
run: npm run typecheck
34+
35+
- name: Build
36+
run: npm run build
37+
38+
- name: Upload build artifacts
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: grove-build
42+
path: dist/
43+
44+
security:
45+
name: Security Audit
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v4
50+
51+
- name: Set up Node.js
52+
uses: actions/setup-node@v4
53+
with:
54+
node-version: '20'
55+
cache: 'npm'
56+
57+
- name: Install dependencies
58+
run: npm ci
59+
60+
- name: Run npm audit
61+
run: npm audit --audit-level=moderate
62+
63+
- name: Check for known security vulnerabilities
64+
run: npm audit --parseable --audit-level=high | grep -q "high\|critical" && exit 1 || exit 0

.github/workflows/release.yml

Lines changed: 117 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,136 @@ on:
44
push:
55
tags:
66
- 'v*.*.*'
7+
branches:
8+
- main
79

810
permissions:
911
contents: write
12+
id-token: write
13+
packages: write
1014

1115
jobs:
12-
goreleaser:
16+
prerelease:
17+
name: Prerelease
1318
runs-on: ubuntu-latest
19+
if: github.ref == 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')
1420
steps:
1521
- name: Checkout
1622
uses: actions/checkout@v4
1723
with:
1824
fetch-depth: 0
1925

20-
- name: Set up Go
21-
uses: actions/setup-go@v5
26+
- name: Set up Node.js
27+
uses: actions/setup-node@v4
2228
with:
23-
go-version: '1.23'
29+
node-version: '20'
30+
cache: 'npm'
31+
registry-url: 'https://registry.npmjs.org'
2432

25-
- name: Run GoReleaser
26-
uses: goreleaser/goreleaser-action@v6
33+
- name: Install dependencies
34+
run: npm ci
35+
36+
- name: Generate prerelease version
37+
id: version
38+
run: |
39+
CURRENT_VERSION=$(node -p "require('./package.json').version")
40+
COMMIT_SHA=${GITHUB_SHA::7}
41+
PRERELEASE_VERSION="${CURRENT_VERSION}-preview.${COMMIT_SHA}"
42+
echo "VERSION=${PRERELEASE_VERSION}" >> $GITHUB_OUTPUT
43+
echo "Generated prerelease version: ${PRERELEASE_VERSION}"
44+
45+
- name: Update package.json version
46+
run: npm version ${{ steps.version.outputs.VERSION }} --no-git-tag-version
47+
48+
- name: Build
49+
run: npm run build
50+
51+
- name: Publish prerelease to npm
52+
run: npm publish --tag preview --access public
53+
env:
54+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
55+
56+
- name: Set up Node.js for GitHub Packages
57+
uses: actions/setup-node@v4
2758
with:
28-
distribution: goreleaser
29-
version: '~> v2'
30-
args: release --clean
59+
node-version: '20'
60+
registry-url: 'https://npm.pkg.github.com'
61+
scope: '@captainsafia'
62+
63+
- name: Publish prerelease to GitHub Packages
64+
run: npm publish --tag preview --access public --provenance
3165
env:
32-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
68+
release:
69+
name: Release
70+
runs-on: ubuntu-latest
71+
if: startsWith(github.ref, 'refs/tags/v')
72+
steps:
73+
- name: Checkout
74+
uses: actions/checkout@v4
75+
with:
76+
fetch-depth: 0
77+
78+
- name: Set up Node.js
79+
uses: actions/setup-node@v4
80+
with:
81+
node-version: '20'
82+
cache: 'npm'
83+
registry-url: 'https://registry.npmjs.org'
84+
85+
- name: Install dependencies
86+
run: npm ci
87+
88+
- name: Extract version from tag
89+
id: version
90+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
91+
92+
- name: Update package.json version
93+
run: npm version ${{ steps.version.outputs.VERSION }} --no-git-tag-version
94+
95+
- name: Build
96+
run: npm run build
97+
98+
- name: Publish to npm
99+
run: npm publish --provenance --access public
100+
env:
101+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
102+
103+
- name: Set up Node.js for GitHub Packages
104+
uses: actions/setup-node@v4
105+
with:
106+
node-version: '20'
107+
registry-url: 'https://npm.pkg.github.com'
108+
scope: '@captainsafia'
109+
110+
- name: Publish to GitHub Packages
111+
run: npm publish
112+
env:
113+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
115+
- name: Create GitHub Release
116+
uses: softprops/action-gh-release@v2
117+
env:
118+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119+
with:
120+
tag_name: ${{ github.ref_name }}
121+
name: Release ${{ github.ref_name }}
122+
body: |
123+
## Installation
124+
125+
### From npm
126+
```bash
127+
npm install -g @captainsafia/grove@${{ steps.version.outputs.VERSION }}
128+
```
129+
130+
### From GitHub Packages
131+
```bash
132+
npm install -g @captainsafia/grove@${{ steps.version.outputs.VERSION }} --registry=https://npm.pkg.github.com
133+
```
134+
135+
## Changes
136+
137+
See the [commits](https://github.com/captainsafia/grove/compare/v${{ steps.version.outputs.VERSION }}...HEAD) for details.
138+
draft: false
139+
prerelease: false

0 commit comments

Comments
 (0)