Skip to content

Commit 4a1f6db

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent f10c86e commit 4a1f6db

5 files changed

Lines changed: 1940 additions & 74 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 14 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,32 @@
1-
name: "@smakss/react-scroll-direction"
1+
name: Release
22

33
on:
4-
release:
5-
types: [created]
4+
push:
5+
branches: [master]
66

77
jobs:
8-
build:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- uses: actions/checkout@v4
12-
- uses: pnpm/action-setup@v4
13-
with:
14-
version: 10
15-
- uses: actions/setup-node@v4
16-
with:
17-
node-version: 20
18-
cache: pnpm
19-
- run: pnpm install --frozen-lockfile
20-
- run: pnpm generate
21-
- uses: actions/upload-artifact@v4
22-
with:
23-
name: built-package
24-
path: |
25-
./dist
26-
package.json
27-
28-
publish-npm:
29-
needs: build
8+
release:
309
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
issues: write
13+
pull-requests: write
3114
steps:
3215
- uses: actions/checkout@v4
33-
- uses: actions/download-artifact@v4
3416
with:
35-
name: built-package
17+
fetch-depth: 0
3618
- uses: pnpm/action-setup@v4
3719
with:
3820
version: 10
3921
- uses: actions/setup-node@v4
4022
with:
41-
node-version: 18
23+
node-version: 20
4224
registry-url: https://registry.npmjs.org/
4325
scope: "@smakss"
4426
cache: pnpm
4527
- run: pnpm install --frozen-lockfile
46-
- run: pnpm generate
47-
- run: |
48-
if grep -q "beta" package.json; then
49-
echo "Publishing Beta to npm"
50-
npm publish --tag beta
51-
else
52-
echo "Publishing Release to npm"
53-
npm publish
54-
fi
55-
env:
56-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
57-
58-
publish-gpr:
59-
needs: build
60-
runs-on: ubuntu-latest
61-
steps:
62-
- uses: actions/checkout@v4
63-
- uses: actions/download-artifact@v4
64-
with:
65-
name: built-package
66-
- uses: pnpm/action-setup@v4
67-
with:
68-
version: 10
69-
- uses: actions/setup-node@v4
70-
with:
71-
node-version: 18
72-
registry-url: https://npm.pkg.github.com/
73-
scope: "@smakss"
74-
cache: pnpm
75-
- run: pnpm install --frozen-lockfile
76-
- run: pnpm generate
77-
- run: |
78-
if grep -q "beta" package.json; then
79-
echo "Publishing Beta to GitHub Package Registry"
80-
npm publish --tag beta
81-
else
82-
echo "Publishing Release to GitHub Package Registry"
83-
npm publish
84-
fi
28+
- run: pnpm build
29+
- run: pnpm release
8530
env:
86-
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.releaserc.cjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
branches: ['master'],
3+
plugins: [
4+
'@semantic-release/commit-analyzer',
5+
'@semantic-release/release-notes-generator',
6+
[
7+
'@semantic-release/changelog',
8+
{
9+
changelogFile: 'CHANGELOG.md'
10+
}
11+
],
12+
'@semantic-release/npm',
13+
[
14+
'@semantic-release/github',
15+
{
16+
assets: ['dist/**']
17+
}
18+
],
19+
[
20+
'@semantic-release/git',
21+
{
22+
assets: ['CHANGELOG.md', 'package.json', 'pnpm-lock.yaml']
23+
}
24+
]
25+
]
26+
};

CONTRIBUTING.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,24 @@ This will install all the necessary development dependencies and set up Git hook
2424
- New environment variables
2525
- New database migrations
2626
- Any other relevant information
27-
3. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
28-
4. Ensure your PR has a single purpose. If it addresses more than one issue or introduces more than one feature, split them into separate PRs.
29-
5. Describe your PR thoroughly. Explain the purpose of your PR, how you approached the problem, and include any relevant information or screenshots for context.
27+
3. Ensure your PR has a single purpose. If it addresses more than one issue or introduces more than one feature, split them into separate PRs.
28+
4. Describe your PR thoroughly. Explain the purpose of your PR, how you approached the problem, and include any relevant information or screenshots for context.
29+
30+
## Release Process
31+
32+
Releases are automated with semantic-release on every push to the `master` branch.
33+
34+
- Do not manually bump versions or edit the changelog; semantic-release handles both.
35+
- Follow Conventional Commits so the release type can be inferred.
36+
- The GitHub Actions workflow requires these secrets:
37+
- `NPM_TOKEN` (publish to npm)
38+
- `GITHUB_TOKEN` (create GitHub release)
39+
40+
To run a local dry run:
41+
42+
```bash
43+
pnpm release --dry-run
44+
```
3045

3146
## Coding Standards
3247

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
"devDependencies": {
88
"@commitlint/cli": "^20.4.0",
99
"@commitlint/config-conventional": "^20.4.0",
10+
"@semantic-release/changelog": "^6.0.3",
11+
"@semantic-release/commit-analyzer": "^13.0.1",
12+
"@semantic-release/git": "^10.0.1",
13+
"@semantic-release/github": "^12.0.3",
14+
"@semantic-release/npm": "^13.1.3",
15+
"@semantic-release/release-notes-generator": "^14.1.0",
1016
"@types/react": "^19.2.10",
1117
"@typescript-eslint/eslint-plugin": "^8.54.0",
1218
"@typescript-eslint/parser": "^8.54.0",
@@ -17,6 +23,7 @@
1723
"husky": "^9.1.7",
1824
"lint-staged": "^16.2.7",
1925
"prettier": "^3.8.1",
26+
"semantic-release": "^25.0.3",
2027
"typescript": "^5.9.3",
2128
"vite": "^6.4.1",
2229
"vite-plugin-dts": "^4.5.4"
@@ -75,6 +82,7 @@
7582
"lint": "npx eslint --cache --cache-location ./node_modules/.cache/.eslintcache --max-warnings=0 .",
7683
"lint:fix": "npx eslint --fix .",
7784
"setup": "pnpm install && husky",
85+
"release": "semantic-release",
7886
"typecheck": "tsc -b .",
7987
"update:deps": "rm -rf node_modules pnpm-lock.yaml && npx npm-check-updates -u && pnpm install"
8088
},

0 commit comments

Comments
 (0)