algolia / shipjs

Take control of what is going to be your next release.
https://community.algolia.com/shipjs/
MIT License
765 stars 30 forks source link

feat(release): add publish only flag #988

Closed dawidvdh closed 1 year ago

dawidvdh commented 1 year ago

Hi, I have attempted to add an argument in order to be able to only publish and not create git tags and github releases, I don't have too much context over this project so I very well may be missing something please do let me know and I will try fix it.

However I am trying to achieve this as I am currently in a situation where I need to publish to both the npm registry and the github package registry, I am currently achieving it by doing the following:

      - uses: actions/setup-node@v3
        with:
          node-version-file: ".nvmrc"
          registry-url: "https://registry.npmjs.org"
      - run: npm install
      - run: npx shipjs trigger
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
          SLACK_INCOMING_HOOK: ${{ secrets.SLACK_INCOMING_HOOK }}
      - uses: actions/setup-node@v3
        with:
          node-version-file: ".nvmrc"
          registry-url: "https://npm.pkg.github.com"
      - run: npx shipjs trigger -- --publishOnly
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

I set publishOnly in hopes that it would only push the package up to the github registry, however it still attempts to recreate the tag and of course fails:

npm notice Publishing to https://npm.pkg.github.com/
+ @project/package@1.0.0
› Creating a git tag.
$ git tag v1.0.2
fatal: tag 'v1.0.2' already exists
Error: {
  "message": "Exit code is 128",
  "command": "git tag v1.0.2",
  "result": ""
}
    at exec (/home/runner/work/project/node_modules/shipjs-lib/dist/index.esm.js:44:11)
    at default (/home/runner/work/project/node_modules/shipjs/src/util/run.js:22:20)
    at /home/runner/work/project/node_modules/shipjs/src/step/release/createGitTag.js:9:5
    at runStep (/home/runner/work/project/node_modules/shipjs/src/step/runStep.js:11:10)
    at default (/home/runner/work/project/node_modules/shipjs/src/step/release/createGitTag.js:5:3)
    at release (/home/runner/work/project/node_modules/shipjs/src/flow/release.js:45:23)
    at async Proxy.cli (/home/runner/work/project/node_modules/shipjs/src/cli.js:48:5)
    at async /home/runner/work/project/node_modules/shipjs/bin/shipjs:7:5
Error: Process completed with exit code 1.

If there is a better solution to achieve this please do let me know.

Haroenv commented 1 year ago

Thanks for your PR! Before setting this new option, could you pass publishCommand that would publish to both npm and GitHub registry, so you only need to trigger once?