MetaMask / action-npm-publish

GitHub Action to publish to NPM
MIT License
8 stars 6 forks source link

Add --dry-run #4

Closed rickycodes closed 2 years ago

rickycodes commented 2 years ago

Add --dry-run as default.

If you run this action without an NPM_TOKEN it'll perform a --drun-run publish.

Consumers wishing to perform a --dry-run can now do so by adding a new job just prior to the job performing the actual npm publish.

An example configuration would look something like:

  publish-npm-dry-run:
    runs-on: ubuntu-latest
    needs: publish-release
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.sha }}
      - uses: actions/cache@v3
        id: restore-build
        with:
          path: ./dist
          key: ${{ github.sha }}
        # Set `ignore-scripts` to skip `prepublishOnly` because the release was built already in the publish-release job
      - run: npm config set ignore-scripts true
      - name: Publish
        uses: MetaMask/action-npm-publish@v1.0.0

  publish-npm:
    environment: npm-publish
    runs-on: ubuntu-latest
    needs: publish-npm-dry-run
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.sha }}
      - uses: actions/cache@v3
        id: restore-build
        with:
          path: ./dist
          key: ${{ github.sha }}
        # Set `ignore-scripts` to skip `prepublishOnly` because the release was built already in the publish-release job
      - run: npm config set ignore-scripts true
      - name: Publish
        uses: MetaMask/action-npm-publish@v1.0.0
        with:
          npm-token: ${{ secrets.NPM_TOKEN }}

This means a person coming in to approve the final npm publish job run can view the output of the dry-run job preceding it and verify the publish is going to do what's expected.

closes: #3