Skip to content

Commit 1731cd5

Browse files
committed
fix
1 parent 3387d0e commit 1731cd5

File tree

7 files changed

+3453
-829
lines changed

7 files changed

+3453
-829
lines changed

.github/assets/token.png

641 KB
Loading

.github/workflows/publish.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Publish package to npm
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- 'main'
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
env:
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
- name: Install
19+
run: yarn install --frozen-lockfile
20+
- name: Build
21+
run: yarn build
22+
- name: Release
23+
run: yarn release

.releaserc.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"branches": [
3+
"+([0-9])?(.{+([0-9]),x}).x",
4+
"main",
5+
"next",
6+
"next-major",
7+
{"name": "beta", "prerelease": true},
8+
{"name": "alpha", "prerelease": true}
9+
],
10+
"plugins": [
11+
"@semantic-release/commit-analyzer",
12+
"@semantic-release/release-notes-generator",
13+
"@semantic-release/changelog",
14+
"@semantic-release/npm",
15+
"@semantic-release/git",
16+
"@semantic-release/github"
17+
]
18+
}

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A simple node boilerplate made in typescript using swc.
44

55
👻 A version without rust compiler [swc](https://swc.rs/) is available [here](https://github.com/maxgfr/boilerplate-typescript-node).
66

7-
🤖 A more complex repository is available for creating npm package [here](https://github.com/maxgfr/typescript-boilerplate-package).
7+
🤖 A version without [`semantic-release`](https://github.com/semantic-release/semantic-release) is available [here](https://github.com/maxgfr/typescript-swc-starter/tree/without-package).
88

99
👾 You can also use a branch which use dotenv [here](https://github.com/maxgfr/typescript-swc-starter/tree/with-dotenv).
1010

@@ -40,3 +40,16 @@ yarn dev # For running the code in development thanks to swc and nodemon
4040
yarn test # For running unit test
4141
yarn test:watch # For watching unit test
4242
```
43+
44+
## Publish to npm
45+
46+
Set `NPM_TOKEN` in your Github actions secret, and that's it :)
47+
48+
![Alt Text](https://raw.githubusercontent.com/maxgfr/typescript-swc-starter/main/.github/assets/token.png)
49+
50+
To test this package, just do that :
51+
52+
```ts
53+
import { sayHello } from 'typescript-swc-starter';
54+
sayHello();
55+
```

package.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"keywords": [
2727
"boilerplate",
2828
"typescript",
29+
"release",
2930
"swc"
3031
],
3132
"scripts": {
@@ -50,10 +51,17 @@
5051
"lint:fix": "eslint ./src --ext .ts --fix",
5152
"prettier": "prettier '**/*.{ts,json,md}'",
5253
"prettier:write": "prettier --write '**/*.{ts,json,md}'",
53-
"lint-staged": "lint-staged"
54+
"lint-staged": "lint-staged",
55+
"release": "semantic-release"
5456
},
5557
"dependencies": {},
5658
"devDependencies": {
59+
"@semantic-release/changelog": "^6.0.3",
60+
"@semantic-release/commit-analyzer": "^9.0.2",
61+
"@semantic-release/git": "^10.0.1",
62+
"@semantic-release/github": "^8.0.7",
63+
"@semantic-release/npm": "^10.0.3",
64+
"@semantic-release/release-notes-generator": "^11.0.1",
5765
"@swc/cli": "0.1.62",
5866
"@swc/core": "^1.3.35",
5967
"@swc/helpers": "^0.5.0",
@@ -72,7 +80,12 @@
7280
"nodemon": "2.0.22",
7381
"prettier": "2.8.8",
7482
"regenerator-runtime": "^0.13.11",
83+
<<<<<<< HEAD
7584
"rimraf": "5.0.1",
85+
=======
86+
"rimraf": "5.0.0",
87+
"semantic-release": "^21.0.2",
88+
>>>>>>> 12bb2a8 (feat: add semantic-release)
7689
"ts-node": "^10.9.1",
7790
"typescript": "5.0.4"
7891
}

src/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
import { sayHello } from './hello.js';
2-
3-
function main() {
4-
sayHello();
5-
}
6-
7-
main();
1+
export * from './hello.js';

0 commit comments

Comments
 (0)