Skip to content

Commit

Permalink
release workflow (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyuhang0 authored Aug 31, 2023
1 parent 80dc0a8 commit 89a5180
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ jobs:
git diff
exit 1
fi
- run: |
npm run version
if [ "$(git diff | wc -l)" -gt "0" ]; then
echo "Check version fail, please run 'npm run version' to fix."
git diff
exit 1
fi
19 changes: 19 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Publish

on:
release:
types: [published]

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 5 additions & 0 deletions docs/dev-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# How to release

1. Update the version in `package.json` and run `npm run version`. Then merge the PR.
2. Publish a new GitHub release.
3. The npm pacakge will be published automatically.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"pretest": "npm run build",
"test": "jest __tests__ --passWithNoTests",
"integrationTest": "npm run build && jest integration-test --passWithNoTests",
"version": "echo \"export const Version = '$npm_package_version'\" > src/version.ts && git add src/version.ts && npm run build",
"version": "echo \"export const Version = '$npm_package_version'\" > src/version.ts",
"prepublishOnly": "npm run build"
},
"prettier": {
Expand Down

0 comments on commit 89a5180

Please sign in to comment.