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

trigger workflow fails to create a tag #992

Closed opichon closed 1 year ago

opichon commented 1 year ago

Describe the bug Ship.js trigger action fails to create a tag after publishing the packages. The actions generate the following error message:

› Creating a git tag.
$ git tag -a v0.6.4 -m v0.6.4
Committer identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: empty ident name (for <runner@fv-az180-932.oqwrao4tgo5u1osypft1dvkhhh.cx.internal.cloudapp.net>) not allowed
Error: {
  "message": "Exit code is 128",
  "command": "git tag -a v0.6.4 -m v0.6.4",
  "result": ""

To Reproduce Steps to reproduce the behavior:

  1. upgrade to shipjs v0.25.1
  2. create a release
  3. merge the PR

Expected behavior After publishing the packages, shipjs should create a tag in the repo.

Additional context This behavior started after upgrading to the latest release of shipjs v0.25.1. I wonder if the github workflow has changed with that release. Bizarrely, I don't see a 0.25.1 release in the github repo. The latest release documented here is v0.25.0.

I am using pnpm, so the shipjs-trigger workflow is slightly modified from your original, but I don't see that the changes are relevant here:

name: Ship js trigger
on:
  pull_request:
    types:
      - closed
jobs:
  build:
    name: Release
    runs-on: ubuntu-latest
    if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'releases/v')
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
          ref: main
      - name: Setup node 16
        uses: actions/setup-node@v3
        with:
          node-version: 16
          registry-url: "https://registry.npmjs.org"
      - name: Install pnpm
        uses: pnpm/action-setup@v2
        with:
          run_install: |
            - version: 7
            - recursive: true
              args: [--frozen-lockfile, --strict-peer-dependencies]
      - run:
          pnpm -r 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 }}
opichon commented 1 year ago

The bug is fixed if we modify the shipjs-trigger workflow as follows:

     ...
     - run: |
          git config --global user.email "github-actions[bot]@users.noreply.github.com"
          git config --global user.name "github-actions[bot]"
    - run: npx shipjs trigger
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
          SLACK_INCOMING_HOOK: ${{ secrets.SLACK_INCOMING_HOOK }}
Haroenv commented 1 year ago

Since 0.25.1, we write annotated tags, which indeed require git credentials to write. The documentation has been updated, but sorry for the inconvenience. I'll update the changelog to make it clearer these credentials are needed.