Publish on NPM #12
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 on NPM | |
permissions: | |
contents: write | |
id-token: write | |
on: | |
workflow_dispatch: | |
jobs: | |
publish: | |
if: github.ref == 'refs/heads/main' | |
timeout-minutes: 5 | |
runs-on: | |
labels: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: pnpm/action-setup@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'pnpm' | |
cache-dependency-path: pnpm-lock.yaml | |
scope: '@cbjsdev' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Git Identity | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: Install dependencies | |
run: pnpm i | |
- name: Publish packages | |
run: pnpm lerna publish --no-private --force-publish --conventional-commits --no-changelog --yes | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: | | |
export PREVIOUS_TAG=$(git tag --sort=-creatordate --merged origin/main | sed -n '2p') | |
export LATEST_TAG=$(git tag --sort=-creatordate --merged origin/main | sed -n '1p') | |
npx changelogithub --from $PREVIOUS_TAG --to $LATEST_TAG | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |