Skip to content

Commit

Permalink
Merge pull request #2 from laggage/publish-@cnblogs
Browse files Browse the repository at this point in the history
chore: publish to npmjs in ci
  • Loading branch information
laggage authored Feb 26, 2023
2 parents e6e1436 + 4dfe940 commit 3e6c020
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
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 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/*/}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
15 changes: 15 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 3e6c020

Please sign in to comment.