Skip to content

publish when merge to main #42

publish when merge to main

publish when merge to main #42

Workflow file for this run

#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'
- 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: Configure npm authentication
run: |
echo "//registry.npmjs.org/:_authToken=${{ env.NODE_AUTH_TOKEN }}" > ~/.npmrc
cat ~/.npmrc
- name: Install dependencies
run: npm install
- 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: ${{ vars.NPM_TOKEN }}
run: |
npm config set //registry.npmjs.org/:_authToken=${env.NODE_AUTH_TOKEN}
npm publish