Skip to content

Commit bd8abe2

Browse files
deploy action, lint, tsconfig, deps
1 parent ab857c0 commit bd8abe2

19 files changed

Lines changed: 2713 additions & 7838 deletions

.github/workflows/npm-deploy.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
branches:
6+
- 1.x
7+
- 0.x
8+
workflow_dispatch:
9+
10+
jobs:
11+
verify_version:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
should_publish: ${{ steps.check.outputs.should_publish }}
15+
version: ${{ steps.check.outputs.version }}
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Check if package.json version changed
23+
id: check
24+
run: |
25+
echo "Current branch: ${{ github.ref }}"
26+
27+
# Get current version
28+
CURRENT_VERSION=$(jq -r .version package.json)
29+
echo "Current version: $CURRENT_VERSION"
30+
31+
# Get previous commit hash
32+
git rev-parse HEAD~1 || git rev-parse HEAD
33+
PREV_COMMIT=$(git rev-parse HEAD~1 2>/dev/null || git rev-parse HEAD)
34+
35+
# Check if package.json changed
36+
if git diff --name-only HEAD~1 HEAD | grep "package.json"; then
37+
echo "Package.json was changed in this commit"
38+
39+
# Get previous version if possible
40+
if git show "$PREV_COMMIT:package.json" 2>/dev/null; then
41+
PREV_VERSION=$(git show "$PREV_COMMIT:package.json" | jq -r .version)
42+
echo "Previous version: $PREV_VERSION"
43+
44+
if [ "$CURRENT_VERSION" != "$PREV_VERSION" ]; then
45+
echo "Version changed from $PREV_VERSION to $CURRENT_VERSION"
46+
echo "should_publish=true" >> $GITHUB_OUTPUT
47+
else
48+
echo "Version unchanged"
49+
echo "should_publish=false" >> $GITHUB_OUTPUT
50+
fi
51+
else
52+
echo "First commit with package.json, will publish"
53+
echo "should_publish=true" >> $GITHUB_OUTPUT
54+
fi
55+
else
56+
echo "Package.json not changed in this commit"
57+
echo "should_publish=false" >> $GITHUB_OUTPUT
58+
fi
59+
60+
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
61+
62+
publish:
63+
needs: verify_version
64+
if: needs.verify_version.outputs.should_publish == 'true'
65+
runs-on: ubuntu-latest
66+
permissions:
67+
contents: write
68+
steps:
69+
- name: Checkout repository
70+
uses: actions/checkout@v4
71+
with:
72+
fetch-depth: 0
73+
74+
- name: Create Git tag
75+
run: |
76+
git config user.name "github-actions[bot]"
77+
git config user.email "github-actions[bot]@users.noreply.github.com"
78+
git tag -a "v${{ needs.verify_version.outputs.version }}" -m "Release v${{ needs.verify_version.outputs.version }}"
79+
git push origin "v${{ needs.verify_version.outputs.version }}"
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
83+
- name: Setup Bun
84+
uses: oven-sh/setup-bun@v2
85+
86+
- name: Install dependencies
87+
run: bun install --frozen-lockfile
88+
89+
- name: Build package
90+
run: bun run build
91+
92+
- name: Publish to npm
93+
run: |
94+
# strip “refs/heads/” prefix
95+
BRANCH=${GITHUB_REF#refs/heads/}
96+
if [[ "$BRANCH" == "1.x" ]]; then
97+
echo "Publishing to npm under the 'beta' tag"
98+
bun publish --tag beta
99+
else
100+
echo "Publishing to npm under the 'latest' tag"
101+
bun publish
102+
fi
103+
env:
104+
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
105+
106+
create_release:
107+
needs: [verify_version, publish]
108+
if: needs.verify_version.outputs.should_publish == 'true'
109+
runs-on: ubuntu-latest
110+
permissions:
111+
contents: write
112+
steps:
113+
- name: Create GitHub Release
114+
uses: actions/create-release@v1
115+
env:
116+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117+
with:
118+
tag_name: "v${{ needs.verify_version.outputs.version }}"
119+
release_name: "v${{ needs.verify_version.outputs.version }}"
120+
body: "Release v${{ needs.verify_version.outputs.version }}"
121+
draft: false
122+
prerelease: false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
.turbo
3+
dist

biome.json

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

0 commit comments

Comments
 (0)