Releases: alextremp/versiona
v3.0.0
Fixes 3rd party usage:
TypeError: versiona is not a function
In order to keep what is intended to be as explained in the README, a major version is released due to incompatibility in v2 caused by commonjs interop with node's require caused by the export default clause:
In v2, usage must be:
const versiona = require('versiona').default
That's an ugly usage, so v3 will export the module directly with module.exports and usage will be kept to:
const versiona = require('versiona')
v2.0.1
Fixes:
- error requiring version from another project
Error: Cannot find module './versiona'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
src/main/versiona.js was not packed in the v2.0.0 version because of same naming with root's versiona.js used for self-publishing.
v2.0.0
v2.0.0 is the first versiona version, refer to:
Republished as v2 because of v1 was unpublished from NPM.
400 Bad Request - PUT https://registry.npmjs.org/versiona - Cannot publish over previously published version "1.0.0"
But v1.0.0 does not exist anymore in NPM 🤷♂
v1.0.0-beta.1
resolve path for package json
v1.0.0
Versiona is a Travis CI helper tool for NPM projects where teams use Github tags to create new Releases, so assuming:
- Use Travis CI
- Use Github release tagging in semver format:
- vX.Y.Z tag will publish X.Y.Z version in NPM
- vX.Y.Z-beta.A tag will publish X.Y.Z-beta.A beta version in NPM
This library will:
- Update your package version to the Github tag specific version
- Publish the new version to NPM
- Commit to Github the updated package.json
- Commit to master for Release versions (vX.Y.Z)
- Commit to develop/vX for Beta Release versions (vX.Y.Z-beta.A)
By releasing your NPM packages this way, you will:
- have full control of when a new version should be publicly available
- know which release tag corresponds to each available NPM version of your package
- don't publish from localhost! ;)
Usage
Install versiona:
npm i versiona --save-dev
Create a versiona.js script into your project:
const versiona = require('versiona')
versiona({
repoOrg: 'your_repo_org_or_username', // required, ex: 'alextremp'
repoName: 'your_repo_name', // required, ex: 'versiona'
pathToPackageJSON: 'path_to_package.json', // defaults to 'package.json', set the relative path to package json if it's not in the same folder than the script
test: false // true if just want to test the config without publishing / committing, defaults to false
})
Add a new script task into your package.json:
"scripts": {
"versiona": "node versiona.js"
}
Call the versiona task from Travis:
- In this travis sample:
dist: trusty
language: node_js
node_js:
- "8"
cache:
directories:
- node_modules
before_install:
- npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
script:
- npm run check
- |
echo TRAVIS_BRANCH=$TRAVIS_BRANCH - TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST - TRAVIS_TAG=$TRAVIS_TAG
if [[ $TRAVIS_TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-beta\.[0-9]+)?$ ]]; then
echo DEPLOY VERSION - TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$PR, BRANCH=$BRANCH
TRAVIS_TAG=$TRAVIS_TAG GH_TOKEN=$GH_TOKEN npm run version
fi
- NPM_TOKEN is required to publish packages to NPM
- GH_TOKEN is required to commit back to Github
- This library only uses the tokens, does not store / send / ... them to anywhere
Troubleshooting
Failed publishing from a tag
Revert a tag locally
git tag -d vX.Y.Z
Revert a tag in Github
git push --delete origin vX.Y.Z
Maintainers
This library uses itself to publish to NPM.