diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..d140d30 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,19 @@ +name: Publish to npmjs.com +on: + push: + tags: + - "v*.*.*" +env: + NPM_TOKEN: ${{secrets.GITLAB_NPM_TOKEN}} +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup node + uses: actions/setup-node@v2 + with: + node-version: 18.x + cache: 'npm' + - name: Publish + run: ./publish.sh ${GITHUB_REF#refs/*/} diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..ae64359 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +//registry.npmjs.org/:_authToken=${NPM_TOKEN} diff --git a/publish.sh b/publish.sh new file mode 100755 index 0000000..2dfb752 --- /dev/null +++ b/publish.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +[ -z ${1} ] && echo "Please input version" && exit 0 +version=${1} +originName="markdown-it-attrs" +scopedName="@cnblogs\/markdown-it-attrs" + +sed -i "s/\"name\": \"${originName}\"/\"name\": \"${scopedName}\"/" "package.json" + +npm version --no-git-tag-version ${version} +npm publish --access public + +sed -i "s/\"name\": \"${scopedName}\"/\"name\": \"${originName}\"/" "package.json"