Skip to content

Commit 3e6c020

Browse files
authored
Merge pull request #2 from laggage/publish-@cnblogs
chore: publish to npmjs in ci
2 parents e6e1436 + 4dfe940 commit 3e6c020

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

.github/workflows/publish.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Publish to npmjs.com
2+
on:
3+
push:
4+
tags:
5+
- "v*.*.*"
6+
env:
7+
NPM_TOKEN: ${{secrets.GITLAB_NPM_TOKEN}}
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Setup node
14+
uses: actions/setup-node@v2
15+
with:
16+
node-version: 18.x
17+
cache: 'npm'
18+
- name: Publish
19+
run: ./publish.sh ${GITHUB_REF#refs/*/}

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//registry.npmjs.org/:_authToken=${NPM_TOKEN}

publish.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
[ -z ${1} ] && echo "Please input version" && exit 0
6+
version=${1}
7+
originName="markdown-it-attrs"
8+
scopedName="@cnblogs\/markdown-it-attrs"
9+
10+
sed -i "s/\"name\": \"${originName}\"/\"name\": \"${scopedName}\"/" "package.json"
11+
12+
npm version --no-git-tag-version ${version}
13+
npm publish --access public
14+
15+
sed -i "s/\"name\": \"${scopedName}\"/\"name\": \"${originName}\"/" "package.json"

0 commit comments

Comments
 (0)