Pushing tag after npm version
See original GitHub issueI’m trying to push the latest version created via npm version
to github, but the following code doesn’t work
package.json
{
script: {
"version": "node pushVersion.js"
}
}
pushVersion.js
const fs = require('fs')
const packageJson = fs.readFileSync('./package.json')
const version = JSON.parse(packageJson).version || 0
const simpleGit = require('simple-git')
const git = simpleGit()
let latestTag = `v${version}`
git
.push(['origin', latestTag])
.exec(() => console.log('%s is on github', latestTag))
If I inject .addTag(latestTag)
before .push(...)
- the tag gets pushed, but I recieve an error that the tag already exist.
Getting the tags with .tags(...)
will provice me a list of tags which doesn’t contain the latest version bumped by npm version.
How can I push a single tag after npm version? manually typing `git push origin <tagname> works.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to automatically push tag to git after npm version ...
npm version : Run this in a package directory to bump the version and write the new data back to package. json [..]...
Read more >Add git version tag after publishing to npm · Muffin Man
It is supported by npm, and it will be executed after every npm publish . Only thing left to do is to add...
Read more >Adding dist-tags to packages - npm Docs
By default, running npm publish will tag your package with the latest dist-tag. To use another dist-tag, use the --tag flag when publishing....
Read more >Understanding NPM Versioning With Git Tags | by Davis Barber
At first glance, this command looks simple. npm version bumps our package version for us, altering the version in our package.json file in...
Read more >How to use npm version lifecycle scripts to make ... - Github-Gist
you bump the version of your package and publish to npm; the new version rolls out to users. However, you never make a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That was perfect! that does exactly what I wanted to achieve. Only “issue” is the
git.tags()
which doesn’t return the TagList, hencetags.all
fails sincetags
will beundefined
.I’ve added the final setup (with corrections) here for future references:
projectRoot/package.json
projectRoot/pushVersion.js
Do you have NPM’s git-tag-version set to
false
when you runnpm version
? If not, there should be a git tag already created in your local.Try switching to:
If that’s still not working as expected - please can you run your code with debug enabled and include the relevant bit of the log in the issue