semver icon indicating copy to clipboard operation
semver copied to clipboard

Github Auth Issue

Open DanielNetzer opened this issue 2 years ago โ€ข 5 comments

For some strange reason I keep getting the following error:

[core] ๐Ÿ“ฆ Committed "chore(core): release version 0.1.0 [skip-ci]".
[core] ๐Ÿ”– Tagged "core-0.1.0".
[core] โŒ Error: fatal: could not read Username for '[https://github.com'](https://github.com%27/): terminal prompts disabled

    at /home/ubuntu/myagent/_work/152/s/node_modules/@jscutlery/semver/src/executors/common/exec.js:10:34
    at ChildProcess.exithandler (node:child_process:406:5)
    at ChildProcess.emit (node:events:527:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)

> nx run sdk:version --noVerify --push --commitMessageFormat="chore(${projectName}): release version ${version} [skip-ci]"

[sdk] ๐ŸŸ  No previous version tag found, fallback to version 0.0.0.
        New version will be calculated based on all changes since first commit.
        If your project is already versioned, please tag the latest release commit with sdk-x.y.z and run this command again.
[sdk] ๐Ÿ†• Calculated new version "0.1.0".
[sdk] ๐Ÿ“œ Generated CHANGELOG.md.
[sdk] ๐Ÿ“ Updated package.json version.
[sdk] ๐Ÿ“ฆ Committed "chore(sdk): release version 0.1.0 [skip-ci]".
[sdk] ๐Ÿ”– Tagged "sdk-0.1.0".
[sdk] โŒ Error: fatal: could not read Username for '[https://github.com'](https://github.com%27/): terminal prompts disabled

    at /home/ubuntu/myagent/_work/152/s/node_modules/@jscutlery/semver/src/executors/common/exec.js:10:34
    at ChildProcess.exithandler (node:child_process:406:5)
    at ChildProcess.emit (node:events:527:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)

 

 >  NX   Running target "version" failed

this error originated from an Azure DevOps agent, I tried to debug the code for the github.

the project.json for one of the projects is:

"version": {
      "executor": "@jscutlery/semver:version",
      "options": {
        "preset": "conventional",
        "postTargets": ["core:github", "core:publish"]
      }
    },
    "github": {
      "executor": "@jscutlery/semver:github",
      "options": {
        "tag": "${tag}",
        "notes": "${notes}"
      }
    },
    "publish": {
      "executor": "ngx-deploy-npm:deploy",
      "options": {
        "access": "public"
      }
    }

all of the other projects are configured in a similar manner. any help will be appreciated.

DanielNetzer avatar May 26 '22 14:05 DanielNetzer

Hi @DanielNetzer, the error occurs when semver tries to Git push the version, it seems like your repo is configured with https instead of ssh. You can find more details here.

edbzn avatar May 27 '22 07:05 edbzn

@edbzn wdyt about supporting all different methods in semver similar to what semantic-release does? try HTTP, HTTPS, and SSH? Also another thing I noticed is that when the pipeline fails tags are kept on the origin which causes errors when running the version command again since the git tag already exists.

DanielNetzer avatar May 27 '22 18:05 DanielNetzer

@edbznย wdyt about supporting all different methods inย semverย similar to what semantic-release does? try HTTP, HTTPS, and SSH?

It would need further investigation but could be a new feature.

edbzn avatar May 27 '22 20:05 edbzn

Hey @edbzn attaching logs from the CI pipeline.

2022-05-26T19:13:25.8970223Z ##[section]Starting: Release
2022-05-26T19:13:25.8977181Z ==============================================================================
2022-05-26T19:13:25.8977495Z Task         : Command line
2022-05-26T19:13:25.8977795Z Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
2022-05-26T19:13:25.8978087Z Version      : 2.201.1
2022-05-26T19:13:25.8978394Z Author       : Microsoft Corporation
2022-05-26T19:13:25.8978734Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
2022-05-26T19:13:25.8979081Z ==============================================================================
2022-05-26T19:13:26.0212207Z Generating script.
2022-05-26T19:13:26.0225487Z ========================== Starting Command Output ===========================
2022-05-26T19:13:26.0264772Z [command]/bin/bash --noprofile --norc /home/ubuntu/myagent/_work/_temp/c29a6628-dcb8-4b61-bc50-00b0be9554ff.sh
2022-05-26T19:13:26.3518500Z 
2022-05-26T19:13:26.3520659Z > [email protected] release
2022-05-26T19:13:26.3523009Z > nx run-many --all --target version --verbose --base=origin/main~1 --head=HEAD --push --noVerify --trackDeps --skipRootChangelog --commitMessageFormat='chore(${projectName}): release version ${version} [skip-ci]'
2022-05-26T19:13:26.3524112Z 
2022-05-26T19:13:26.8883268Z 
2022-05-26T19:13:26.8893208Z  >  NX   Running target version for 3 project(s):
2022-05-26T19:13:26.8894090Z 
2022-05-26T19:13:26.8895391Z     - extension
2022-05-26T19:13:26.8896565Z     - core
2022-05-26T19:13:26.8897480Z     - sdk
2022-05-26T19:13:26.8898074Z    
2022-05-26T19:13:26.8898798Z    With flags:
2022-05-26T19:13:26.8899746Z      --verbose=true
2022-05-26T19:13:26.8900667Z      --base=origin/main~1
2022-05-26T19:13:26.8901587Z      --head=HEAD
2022-05-26T19:13:26.8902482Z      --push=true
2022-05-26T19:13:26.8903424Z      --noVerify=true
2022-05-26T19:13:26.8904309Z      --trackDeps=true
2022-05-26T19:13:26.8905202Z      --skipRootChangelog=true
2022-05-26T19:13:26.8906353Z      --commitMessageFormat=chore(${projectName}): release version ${version} [skip-ci]
2022-05-26T19:13:26.8907164Z 
2022-05-26T19:13:26.8907669Z  
2022-05-26T19:13:27.8194320Z 
2022-05-26T19:13:27.8196499Z > nx run sdk:version --verbose --base=origin/main~1 --head=HEAD --push --noVerify --trackDeps --skipRootChangelog --commitMessageFormat="chore(${projectName}): release version ${version} [skip-ci]"
2022-05-26T19:13:27.8197745Z 
2022-05-26T19:13:27.8203776Z [sdk] ๐Ÿ†• Calculated new version "0.1.1".
2022-05-26T19:13:27.8204928Z [sdk] ๐Ÿ“œ Generated CHANGELOG.md.
2022-05-26T19:13:27.8205918Z [sdk] ๐Ÿ“ Updated package.json version.
2022-05-26T19:13:27.8207020Z [sdk] ๐Ÿ“ฆ Committed "chore(sdk): release version 0.1.1 [skip-ci]".
2022-05-26T19:13:27.8208226Z [sdk] โŒ Error: Failed to create "sdk-0.1.1", this tag already exists.
2022-05-26T19:13:27.8209138Z             This occurs because you already versioned the changes, but on a different branch than the base branch.
2022-05-26T19:13:27.8210735Z             Please delete the tag locally by running "git tag -d sdk-0.1.1", delete the tag from the remote repository as well, and run this command again.
2022-05-26T19:13:27.8211967Z     at /home/ubuntu/myagent/_work/152/s/node_modules/@jscutlery/semver/src/executors/version/utils/git.js:75:49
2022-05-26T19:13:27.8213004Z     at Observable.init [as _subscribe] (/home/ubuntu/myagent/_work/152/s/node_modules/rxjs/dist/cjs/internal/observable/throwError.js:8:64)
2022-05-26T19:13:27.8214402Z     at Observable._trySubscribe (/home/ubuntu/myagent/_work/152/s/node_modules/rxjs/dist/cjs/internal/Observable.js:41:25)
2022-05-26T19:13:27.8215394Z     at /home/ubuntu/myagent/_work/152/s/node_modules/rxjs/dist/cjs/internal/Observable.js:35:31
2022-05-26T19:13:27.8217330Z     at Object.errorContext (/home/ubuntu/myagent/_work/152/s/node_modules/rxjs/dist/cjs/internal/util/errorContext.js:22:9)
2022-05-26T19:13:27.8218724Z     at Observable.subscribe (/home/ubuntu/myagent/_work/152/s/node_modules/rxjs/dist/cjs/internal/Observable.js:26:24)
2022-05-26T19:13:27.8220096Z     at /home/ubuntu/myagent/_work/152/s/node_modules/rxjs/dist/cjs/internal/operators/catchError.js:17:31
2022-05-26T19:13:27.8221141Z     at OperatorSubscriber._this._error (/home/ubuntu/myagent/_work/152/s/node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:43:21)
2022-05-26T19:13:27.8222352Z     at OperatorSubscriber.Subscriber.error (/home/ubuntu/myagent/_work/152/s/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
2022-05-26T19:13:27.8223492Z     at /home/ubuntu/myagent/_work/152/s/node_modules/@jscutlery/semver/src/executors/common/exec.js:10:28
2022-05-26T19:13:27.8224129Z 
2022-05-26T19:13:27.8224663Z  
2022-05-26T19:13:27.8225067Z 
2022-05-26T19:13:27.8225694Z  >  NX   Running target "version" failed
2022-05-26T19:13:27.8226183Z 
2022-05-26T19:13:27.8227083Z    Tasks not run because their dependencies failed:
2022-05-26T19:13:27.8227804Z    
2022-05-26T19:13:27.8228886Z    - extension:version
2022-05-26T19:13:27.8229893Z    - core:version
2022-05-26T19:13:27.8230654Z    
2022-05-26T19:13:27.8231243Z    Failed tasks:
2022-05-26T19:13:27.8231829Z    
2022-05-26T19:13:27.8232674Z    - sdk:version
2022-05-26T19:13:27.8233111Z 
2022-05-26T19:13:27.8420911Z ##[error]Bash exited with code '1'.
2022-05-26T19:13:27.8459499Z ##[section]Finishing: Release

to overcome this issue I've added full tag deletion to my release command. the pipeline fails because it tries to generate the same tag again as you can see.

DanielNetzer avatar May 28 '22 14:05 DanielNetzer

What it looks like it happening in that second post is semver isn't seeing your previous tags on whichever branch is being used so it is calculating a version that already exists before pushing.

I had a similar issue when getting started. Do you merge your main branch back into the dev branches? If you don't connect those branches I think semver/git doesn't see them properly.

Screen Shot 2022-06-11 at 5 35 46 AM

For example, here's what happens when I run semver on that test branch, even though the commit is after v7.9.0.

dereekb@dbMBP dbcomponents % nx run workspace:version --dryRun

> nx run workspace:version --dryRun

[workspace] ๐Ÿ†• Calculated new version "7.9.0".

---
# [7.9.0](https://github.com/dereekb/dbx-components/compare/v7.8.1-dev...v7.9.0) (2022-06-11)
---

[workspace] ๐Ÿ“œ Generated CHANGELOG.md.

dereekb avatar Jun 11 '22 10:06 dereekb