Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: lightweight tags is added as option #825

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -209,6 +209,13 @@ standard-version --no-verify

If you have your GPG key set up, add the `--sign` or `-s` flag to your `standard-version` command.

### Using Lightweight Tags

This is basically the commit checksum stored in a file -- no other information is kept.
It's useful for tagging beta, alpha etc. versions without increasing your git repository size.
Add the `--lightweight-tag` to your `standard-version` command.
See [lightweight tags](https://git-scm.com/book/en/v2/Git-Basics-Tagging#_lightweight_tags) for more information.

### Lifecycle Scripts

`standard-version` supports lifecycle scripts. These allow you to execute your
Expand Down
5 changes: 5 additions & 0 deletions command.js
Expand Up @@ -45,6 +45,11 @@ const yargs = require('yargs')
type: 'boolean',
default: defaults.sign
})
.option('lightweight-tag', {
describe: 'Should the git tag be lightweight? \nThis is basically the commit checksum stored in a file, no other information is kept.',
type: 'boolean',
default: defaults.lightweightTag
})
.option('no-verify', {
alias: 'n',
describe: 'Bypass pre-commit or commit-msg git hooks during the commit phase',
Expand Down
1 change: 1 addition & 0 deletions defaults.js
Expand Up @@ -4,6 +4,7 @@ const defaults = {
infile: 'CHANGELOG.md',
firstRelease: false,
sign: false,
lightweightTag: false,
noVerify: false,
commitAll: false,
silent: false,
Expand Down
16 changes: 10 additions & 6 deletions lib/lifecycles/tag.js
Expand Up @@ -14,14 +14,18 @@ module.exports = async function (newVersion, pkgPrivate, args) {
}

async function execTag (newVersion, pkgPrivate, args) {
let tagOption
if (args.sign) {
tagOption = '-s'
checkpoint(args, 'tagging release %s%s', [args.tagPrefix, newVersion])
if (args.lightweightTag) {
await runExecFile(args, 'git', ['tag', args.tagPrefix + newVersion])
} else {
tagOption = '-a'
let tagOption
if (args.sign) {
tagOption = '-s'
} else {
tagOption = '-a'
}
await runExecFile(args, 'git', ['tag', tagOption, args.tagPrefix + newVersion, '-m', `${formatCommitMessage(args.releaseCommitMessageFormat, newVersion)}`])
}
checkpoint(args, 'tagging release %s%s', [args.tagPrefix, newVersion])
await runExecFile(args, 'git', ['tag', tagOption, args.tagPrefix + newVersion, '-m', `${formatCommitMessage(args.releaseCommitMessageFormat, newVersion)}`])
const currentBranch = await runExecFile('', 'git', ['rev-parse', '--abbrev-ref', 'HEAD'])
let message = 'git push --follow-tags origin ' + currentBranch.trim()
if (pkgPrivate !== true && bump.getUpdatedConfigs()['package.json']) {
Expand Down