changesets / action

661 stars 231 forks source link

Publish both to GPR and to NPM #52

Open vlilloh opened 4 years ago

vlilloh commented 4 years ago

I've correctly setup the Changesets Release Action to publish to GPR:

name: Release

on:
  push:
    branches:
      - master

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@master
        with:
          fetch-depth: 0
      - name: Setup Node.js
        uses: actions/setup-node@master
        with:
          node-version: 14
          registry-url: https://npm.pkg.github.com
      - name: Install dependencies
        run: npm i
      - name: Build packages
        run: npm run build
      - name: Create Release Pull Request or Publish to GPR/NPM
        uses: changesets/action@master
        with:
          publish: npx changeset publish
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          # NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

But I can't setup the Changesets Release Action to publish the packages both to GPR and to NPM. Is it possible in the latest version?

mark-omarov commented 3 years ago

I'm not sure it's possible what you're asking for, at least in a single step in a job. I think when you're publishing a package it checks the registry, that might be specified in .npmrc for example, but I guess it can be only a single registry per package. And I think it's not a good idea, in general, to publish to both registries anyway.

Also, I noticed you use secrets.GITHUB_TOKEN, nothing wrong with that except you want changesets/action's generated PR to trigger other workflows. GITHUB_TOKEN does not trigger workflows, in case you'll encounter this problem - add your github personal access token to the secrets (eg. name GH_TOKEN) and refer to it for GITHUB_TOKEN like this:

GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

This is not what you've asked for, but might be helpful.

zoubingwu commented 1 month ago

4 years later, I think it's very reasonable to publish to multiple registries simultaneously now due to the emergence of various runtimes and various registries like Deno, Bun, GitHub, and jsr.io?

Does anyone using changeset/actions to publish to multiple registries?