pankajpatel/list-repos

View on GitHub
.github/workflows/publish.yml

Summary

Maintainability
Test Coverage
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: package-release

on:
  release:
    types: [created]

jobs:
  setup:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
      - uses: actions/setup-node@v3
        with:
          node-version: 14
      - name: node_modules cache
        id: node-modules-cache
        uses: actions/cache@v3
        env:
          cache-name: node-modules-yarn
          cache-fingerprint: ${{ env.node-version }}-${{ hashFiles('yarn.lock') }}
        with:
          path: node_modules
          key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.cache-fingerprint }}
          restore-keys: ${{ runner.os }}-${{ env.cache-name }}

      - name: Yarn install
        # called at most once for the workflow by the "setup" job
        if: steps.node-modules-cache.outputs.cache-hit != 'true'
        run: yarn install --prefer-offline --frozen-lockfile

  publish-npm:
    needs: [ setup ]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
      - uses: actions/setup-node@v3
        with:
          node-version: 14
          registry-url: https://registry.npmjs.org/
      - run: npm i -g yarn
      - run: yarn install --prefer-offline --frozen-lockfile
      - run: yarn build
      - run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}