semver
semver copied to clipboard
tag project-x.y.z exists locally but has not been pushed
Hi guys,
I'm having the same error similar to this issue: #461
error: tag project-x.y.z exists locally but has not been pushed
"release": {
"executor": "@jscutlery/semver:version",
"options": {
"push": true,
"postTargets": ["project:github"]
}
},
"github": {
"executor": "@jscutlery/semver:github",
"options": {
"tag": "${tag}",
"notesFile": "./apps/angular/project/CHANGELOG.md"
}
}
I'm also getting this error, my error is here: https://github.com/Samelogic/microsurveys/runs/7366584884?check_suite_focus=true
Well, I think I fixed this bug multiple times without fixing it finally... :scream:
We are experiencing the same issue. Seems like the Github action tries to create the same tag for Github release.
> nx run apps-corporate:version
[apps-corporate] 🟠 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 [email protected] and run this command again.
[apps-corporate] 🆕 Calculated new version "0.1.0".
[apps-corporate] 📜 Generated CHANGELOG.md.
[apps-corporate] 📦 Committed "chore(apps-corporate): release version 0.1.0".
[apps-corporate] 🔖 Tagged "[email protected]".
Error: tag [email protected] exists locally but has not been pushed to XXX/Monorepo, please push it before continuing or specify the `--target` flag to create a new tag
at /home/runner/work/Monorepo/Monorepo/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)
[apps-corporate] ❌ Error: Something went wrong with post-target "apps-corporate:github".
at /home/runner/work/Monorepo/Monorepo/node_modules/@jscutlery/semver/src/executors/version/utils/post-target.js:[22](https://github.com/XXX/Monorepo/runs/7928604381?check_suite_focus=true#step:6:23):[27](https://github.com/XXX/Monorepo/runs/7928604381?check_suite_focus=true#step:6:28)
at Generator.next (<anonymous>)
at fulfilled (/home/runner/work/Monorepo/Monorepo/node_modules/tslib/tslib.js:115:62)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Any news here?
@samuelfernandez setting "push": true in version scheme resolved the problem for us. The error happened because the tag was not pushed before creating Github Release. You can see it from the error message.
Make sure you removed all unwanted tags locally and remotely and run git fetch.
I can confirm that everything now works and @edbzn can close it.
@AndriiTsok that was a fast answer, thanks so much! Would it be useful to explain that in the readme and config examples for github builder?
no idea if this works but nx run apps-corporate:version || exit 0
to brute force a positive exit code
I am getting a similar error after successful deployment
"version": {
"executor": "@jscutlery/semver:version",
"options": {
"preset": "conventional",
"baseBranch": "main",
"tagPrefix": "release/${projectName}@",
"push": true,
"commitMessageFormat": "release(${projectName}): version ${version} [skip ci]",
"postTargets": ["my-project:deploy", "my-project:github"],
"syncVersions": false,
"trackDeps": true,
"skipCommitTypes": ["docs", "ci", "release"]
}
},
"github": {
"executor": "@jscutlery/semver:github",
"options": {
"target": "main",
"tag": "${tag}",
"notes": "${notes}"
}
},
"deploy": {
"executor": "ngx-deploy-npm:deploy",
"options": {
"access": "restricted",
"buildTarget": "production",
"registry": "https://npm.pkg.github.com/"
}
}
🚀 Successfully published via ngx-deploy-npm! Have a nice day!
[my-project] 🎉 Ran post-target "my-project:deploy".
Error
at /home/circleci/project/node_modules/@jscutlery/semver/src/executors/common/exec.js:10:34
at exithandler (node:child_process:427:5)
at ChildProcess.errorhandler (node:child_process:439:5)
at ChildProcess.emit (node:events:513:28)
at ChildProcess._handle.onexit (node:internal/child_process:289:12)
at onErrorNT (node:internal/child_process:476:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
[my-project] ❌ Error: Something went wrong with post-target "my-project:github".
at /home/circleci/project/node_modules/@jscutlery/semver/src/executors/version/utils/post-target.js:25:31
at Generator.next (<anonymous>)
at fulfilled (/home/circleci/project/node_modules/tslib/tslib.js:164:62)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Finally i found the problem causing this error: As stated here: @jscutlery/semver:github requires GitHub CLI to be installed. I added installation steps for linuxbrew and Github CLI
Here is my working circleci config.yml
version: 2.1
orbs:
node: circleci/[email protected]
# - - - - - - - -
# executors
# - - - - - - - -
executors:
node-docker:
docker:
- image: cimg/node:18.15.0
# - - - - - - - -
# commands
# - - - - - - - -
commands:
workspace-setup:
steps:
- checkout
- attach_workspace:
at: .
login-to-npm-registry:
steps:
- run:
name: 'login to npm registry'
command: echo "//npm.pkg.github.com/:_authToken=$GITHUB_NPM_TOKEN" >> ~/.npmrc
git-login:
steps:
- run:
name: git login
command: |
git config --global user.email "[email protected]"
git config --global user.name "xxx"
install-linux-brew:
steps:
- run:
name: Install and set Linuxbrew
command: |
sudo apt-get install build-essential curl file git
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
echo 'export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin/:$PATH"' >> $BASH_ENV
echo 'export MANPATH="/home/linuxbrew/.linuxbrew/share/man:$MANPATH"' >> $BASH_ENV
echo 'export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:$INFOPATH"' >> $BASH_ENV
# - - - - - - - -
# jobs
# - - - - - - - -
jobs:
npm-init:
executor: node-docker
steps:
- checkout
- node/install-packages:
app-dir: '.'
with-cache: false
- persist_to_workspace:
root: .
paths:
- .npm/
- node_modules/
unit-test:
executor: node-docker
steps:
- workspace-setup
- run:
name: Run Unit Tests
command: npx nx run my-project:test --configuration=ci
publish-package:
executor: node-docker
steps:
- workspace-setup
- login-to-npm-registry
- git-login
- install-linux-brew
- run:
name: Install Github CLI
command: brew install gh
- run:
name: publish package
command: npx nx run my-project:version
publish-beta-package-dev:
executor: node-docker
steps:
- workspace-setup
- login-to-npm-registry
- git-login
- run:
name: publish beta package dev
command: npx nx run my-project:beta-release
# - - - - - - - -
# workflows
# - - - - - - - -
workflows:
version: 2
verify:
jobs:
- npm-init
- unit-test:
requires:
- npm-init
context:
- NPM
- publish-package:
filters:
branches:
only:
- main
requires:
- unit-test
context:
- NPM
- publish-beta-package-dev:
filters:
branches:
only:
- dev
requires:
- unit-test
context:
- NPM
@gabsmprocha This error means your tags were not pushed to the remote. It does not automatically goes with git push.
First, you have to create your tag with git tag project-x.y.z
and then send it with git push --tags
.
Then your Github will be in sync with your remote tags and the semver will be able to infer your correct version.
Finally i found the problem causing this error: As stated here: @jscutlery/semver:github requires GitHub CLI to be installed. I added installation steps for linuxbrew and Github CLI
Here is my working circleci config.yml
version: 2.1 orbs: node: circleci/[email protected] # - - - - - - - - # executors # - - - - - - - - executors: node-docker: docker: - image: cimg/node:18.15.0 # - - - - - - - - # commands # - - - - - - - - commands: workspace-setup: steps: - checkout - attach_workspace: at: . login-to-npm-registry: steps: - run: name: 'login to npm registry' command: echo "//npm.pkg.github.com/:_authToken=$GITHUB_NPM_TOKEN" >> ~/.npmrc git-login: steps: - run: name: git login command: | git config --global user.email "[email protected]" git config --global user.name "xxx" install-linux-brew: steps: - run: name: Install and set Linuxbrew command: | sudo apt-get install build-essential curl file git sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)" echo 'export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin/:$PATH"' >> $BASH_ENV echo 'export MANPATH="/home/linuxbrew/.linuxbrew/share/man:$MANPATH"' >> $BASH_ENV echo 'export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:$INFOPATH"' >> $BASH_ENV # - - - - - - - - # jobs # - - - - - - - - jobs: npm-init: executor: node-docker steps: - checkout - node/install-packages: app-dir: '.' with-cache: false - persist_to_workspace: root: . paths: - .npm/ - node_modules/ unit-test: executor: node-docker steps: - workspace-setup - run: name: Run Unit Tests command: npx nx run my-project:test --configuration=ci publish-package: executor: node-docker steps: - workspace-setup - login-to-npm-registry - git-login - install-linux-brew - run: name: Install Github CLI command: brew install gh - run: name: publish package command: npx nx run my-project:version publish-beta-package-dev: executor: node-docker steps: - workspace-setup - login-to-npm-registry - git-login - run: name: publish beta package dev command: npx nx run my-project:beta-release # - - - - - - - - # workflows # - - - - - - - - workflows: version: 2 verify: jobs: - npm-init - unit-test: requires: - npm-init context: - NPM - publish-package: filters: branches: only: - main requires: - unit-test context: - NPM - publish-beta-package-dev: filters: branches: only: - dev requires: - unit-test context: - NPM
well, GitHub CLI is preinstalled on all GitHub-hosted runners: https://docs.github.com/en/actions/using-workflows/using-github-cli-in-workflows