Merge pull request #15 from react18-tools/fix-esm-build #14
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 NPM | |
# publish only when package json has changed - assuming version upgrade | |
on: | |
push: | |
branches: [main] | |
paths: "esbuild-plugin-react18/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 | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: write | |
id-token: write | |
defaults: | |
run: | |
working-directory: ./esbuild-plugin-react18 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
registry-url: https://registry.npmjs.org | |
- run: npm i -g pnpm && pnpm i | |
name: Install dependencies | |
- run: pnpm build --filter esbuild-plugin-react18-example | |
name: build example app to run tests | |
working-directory: . | |
# 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 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: Mark scoped package as deprecated | |
run: | | |
npm deprecate @mayank1513/esbuild-plugin-react18 "Please use https://www.npmjs.com/package/esbuild-plugin-react18 instead. We initially created scoped packages to have similarities with the GitHub Public Repository (which requires packages to be scoped). We are no longer using GPR and thus deprecating all scoped packages for which corresponding un-scoped packages exist." | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |