|
| 1 | +name: Publish to NPM |
| 2 | + |
| 3 | +# publish only when package json has changed - assuming version upgrade |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + paths: "lib/package.json" |
| 8 | + |
| 9 | +jobs: |
| 10 | + publish: |
| 11 | + # Don't run just after creating repo from template |
| 12 | + # Also avoid running after merging set-up PR |
| 13 | + if: github.run_number > 2 && github.event.repository.owner.login == 'react18-tools' |
| 14 | + runs-on: ubuntu-latest |
| 15 | + permissions: |
| 16 | + contents: write |
| 17 | + id-token: write |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + |
| 24 | + - uses: actions/setup-node@v4 |
| 25 | + with: |
| 26 | + node-version: 20 |
| 27 | + registry-url: https://registry.npmjs.org |
| 28 | + - name: Setup Git |
| 29 | + run: | |
| 30 | + git config --global user.name "mayank1513" |
| 31 | + git config --global user.email "mayank.srmu@gmail.com" |
| 32 | + - run: npm i -g pnpm && pnpm i |
| 33 | + name: Install dependencies |
| 34 | + # fail and not publish if any of the unit tests are failing |
| 35 | + - name: Test |
| 36 | + run: pnpm test |
| 37 | + working-directory: ./lib |
| 38 | + # - name: Copy Readme file |
| 39 | + # run: cp ./README.md ./lib # will be uncommented while rebranding |
| 40 | + - name: Apply changesets, publish and create release, branches and tags |
| 41 | + run: node ./scripts/publish.js |
| 42 | + env: |
| 43 | + BRANCH: ${{ github.ref_name }} |
| 44 | + DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} |
| 45 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |
| 46 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + - name: Run docs workflow as it will fail when trying to make parallel updates |
| 49 | + run: gh workflow run docs.yml |
| 50 | + env: |
| 51 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments