publish when merge to main #48
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
#name: Publish to pnpm | |
# | |
#on: | |
# push: | |
# branches: | |
# - main | |
# | |
#jobs: | |
# publish: | |
# runs-on: ubuntu-latest | |
# | |
# steps: | |
# - name: Checkout repository | |
# uses: actions/checkout@v4 | |
# | |
# - name: Setup Node.js | |
# uses: actions/setup-node@v4 | |
# with: | |
# node-version: '20' | |
# registry-url: 'https://registry.npmjs.org' | |
# | |
# - name: Install dependencies | |
# run: npm install | |
# - name: Whoami | |
# env: | |
# GH_TOKEN: ${{ github.token }} | |
# run: | | |
# git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" | |
# git config --global user.name "$(gh api /users/${GITHUB_ACTOR} | jq .name -r)" | |
# git config -l | |
# - name: Bump version and tag | |
# id: bump_version | |
# run: | | |
# VERSION=$(npm version patch -m "chore(release): %s") | |
# - name: Push new tag to repository | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# run: | | |
# git push origin HEAD:main --tags | |
# - name: Publish to pnpm | |
# env: | |
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
# run: | | |
# npm adduser | |
# npm whoami | |
# npm publish | |
name: Publish to npm | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
registry-url: 'https://registry.npmjs.org' | |
always-auth: true | |
- name: Whoami | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" | |
git config --global user.name "$(gh api /users/${GITHUB_ACTOR} | jq .name -r)" | |
git config -l | |
- name: Install dependencies | |
run: npm install | |
- name: test config | |
run: cat $NPM_CONFIG_USERCONFIG | |
- name: Build | |
run: npm run build | |
- name: Bump version and push tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
npx standard-version --release-as patch | |
git push --follow-tags origin main | |
- name: Publish to npm | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
npm publish |