Skip to content

Merge pull request #2 from mayank1513/prepare-for-transfer #3

Merge pull request #2 from mayank1513/prepare-for-transfer

Merge pull request #2 from mayank1513/prepare-for-transfer #3

Workflow file for this run

name: Publish to NPM
# publish only when package json has changed - assuming version upgrade
on:
push:
branches: [main]
paths: "lib/nthul/package.json"
jobs:
publish:
# Don't run just after creating repo from template
# Also avoid running after merging set-up PR
if: github.run_number > 2 && github.event.repository.owner.login == 'react18-tools'
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
id-token: write
defaults:
run:
working-directory: ./lib/nthul
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org
- run: npm i -g pnpm && pnpm i
name: Install dependencies
# fail and not publish if any of the unit tests are failing
- name: Test
run: pnpm test
- name: Create release and publish to NPM
run: pnpm build && pnpm publish-package
# continue on error to publish scoped package name <- by default repo is setup for a non-scoped + scoped package name
continue-on-error: true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.event.repository.owner.login }}
REPO: ${{ github.event.repository.name }}
- name: Publish Scoped package to NPM
# continue on error - expecing npm to trow error if scoping is done twice
continue-on-error: true
id: publish_scoped
run: cd dist && node ../scope.js && npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.event.repository.owner.login }}
REPO: ${{ github.event.repository.name }}
- name: Publish package with long name for better SEO
continue-on-error: true
run: |
cd dist
sed -i -e "s/.*name.*/\t\"name\": \"nextjs-themes-ultralight\",/" package.json
npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}