-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
2,628 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"useBuiltIns": "entry", | ||
"corejs": "3.6.4", | ||
"modules": false | ||
}, | ||
"@babel/preset-typescript" | ||
] | ||
], | ||
"exclude": "node_modules/**" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# ESLint 的忽略配置文件 | ||
# http://eslint.cn/docs/user-guide/configuring | ||
|
||
build/ | ||
dist/ | ||
dev/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module.exports = { | ||
"env": { | ||
"browser": true, | ||
"es6": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended" | ||
], | ||
"globals": { | ||
"Atomics": "readonly", | ||
"SharedArrayBuffer": "readonly", | ||
"globalThis":"readonly" | ||
}, | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 11, | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"rules": { | ||
// 允许 debugger 运行在 开发 环境中 | ||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', | ||
// 关闭 var 关键字的提示 | ||
"no-var":'off', | ||
// 警告 case 穿透 | ||
"no-fallthrough":'warn', | ||
// 无用变量 | ||
"no-unused-vars": "off", | ||
// typescript 的 无用变量 | ||
"@typescript-eslint/no-unused-vars": "error", | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Pre Publish | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
pre-publish: | ||
# needs: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
fetch-depth: 0 | ||
|
||
- name: Set timezone to Asia/Shanghai | ||
uses: szenius/[email protected] | ||
with: | ||
timezoneLinux: "Asia/Shanghai" | ||
|
||
- name: Echo current time | ||
run: timedatectl | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.11.1 | ||
|
||
- name: Install pnpm | ||
run: | | ||
npm install -g pnpm | ||
# pnpm config set store-dir $(pwd)/.pnpm-store | ||
# pnpm config set recursive-optional true | ||
- name: Install Dependence | ||
run: pnpm install --no-frozen-lockfile | ||
|
||
- name: Build dist | ||
run: | | ||
git pull -p | ||
pnpm run build | ||
- name: Pre publish | ||
run: npm publish --dry-run | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
|
||
- uses: dorny/paths-filter@v3 | ||
id: changes | ||
with: | ||
filters: | | ||
update: | ||
- 'main/**' | ||
- 'types/**' | ||
- 'utils/**' | ||
- README.md | ||
- package.json | ||
- rollup.config.js | ||
- tsconfig.json | ||
- .babelrc | ||
- .github/workflows/publish.yml | ||
- name: Repository Dispatch | ||
if: steps.changes.outputs.update == 'true' | ||
uses: peter-evans/repository-dispatch@v3 | ||
with: | ||
token: ${{ secrets.TOKEN }} | ||
# 也可以直接写成R: GITHUB_REPOSITORY | ||
# https://docs.github.com/zh/actions/learn-github-actions/variables | ||
repository: ${{ github.repository }} | ||
event-type: to-publish-npm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: Publish | ||
on: | ||
repository_dispatch: | ||
types: [to-publish-npm] | ||
|
||
jobs: | ||
pre-publish: | ||
# needs: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
fetch-depth: 0 | ||
|
||
- name: Set timezone to Asia/Shanghai | ||
uses: szenius/[email protected] | ||
with: | ||
timezoneLinux: "Asia/Shanghai" | ||
|
||
- name: Echo current time | ||
run: timedatectl | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.11.1 | ||
|
||
- name: Set Git user and email | ||
run: | | ||
git config --local user.name ${{vars.NAME}} | ||
git config --local user.email ${{vars.EMAIL}} | ||
git config --local --list | ||
- name: Update Version | ||
run: | | ||
# 更新版本号并获取新版本号 | ||
VERSION=$(npm version patch --no-git-tag-version --silent) | ||
echo "VERSION=$VERSION" | ||
# 将新版本号输出到环境变量 | ||
echo "NEW_VERSION=$VERSION" >> $GITHUB_ENV | ||
SHORT_GITHUB_SHA=$(echo ${GITHUB_SHA:0:8}) | ||
echo "SHORT_GITHUB_SHA=$SHORT_GITHUB_SHA" | ||
# 将八位hash输出到环境变量 | ||
echo "SHORT_GITHUB_SHA=$SHORT_GITHUB_SHA" >> $GITHUB_ENV | ||
TAG_NAME="${VERSION}-${SHORT_GITHUB_SHA}" | ||
echo "TAG_NAME=$TAG_NAME" | ||
# 将组合的TAG_NAME输出到环境变量 | ||
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV | ||
- name: Install pnpm | ||
run: | | ||
npm install -g pnpm | ||
# pnpm config set store-dir $(pwd)/.pnpm-store | ||
# pnpm config set recursive-optional true | ||
- name: Install Dependence | ||
run: pnpm install --no-frozen-lockfile | ||
|
||
- name: Build dist | ||
run: | | ||
git pull -p | ||
pnpm run build | ||
- name: Add Npm Token | ||
run: | | ||
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ./.npmrc | ||
ls -al | ||
cat ./.npmrc | ||
- name: Publish | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
|
||
- name: Package specific files | ||
run: | | ||
zip -r ${{ env.TAG_NAME }}.zip ./package.json ./dist ./LICENSE | ||
ls -al | ||
# - name: "✏️ Generate release changelog" | ||
# uses: heinrichreimer/[email protected] | ||
# with: | ||
# token: ${{ secrets.TOKEN }} | ||
|
||
- name: Create GitHub Release | ||
uses: softprops/action-gh-release@v2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.TOKEN }} | ||
with: | ||
token: ${{ secrets.TOKEN }} | ||
name: "Release ${{ env.NEW_VERSION }}" | ||
tag_name: "${{ env.TAG_NAME }}" | ||
body: "Check the changelog for details." | ||
draft: false | ||
prerelease: false | ||
generate_release_notes: true | ||
files: ${{ env.TAG_NAME }}.zip | ||
|
||
- name: Commit and push Version | ||
run: | | ||
git add package.json | ||
git commit -m "Bump version to ${{ env.TAG_NAME }}" | ||
git tag -a "${{ env.TAG_NAME }}" -m "Release ${{ env.TAG_NAME }}" | ||
git push origin main | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.