Created
March 5, 2015 20:05
-
-
Save Gioyik/701b65ec164705c57a85 to your computer and use it in GitHub Desktop.
Script to auto publish npm packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use v5.14; | |
use warnings; | |
use Path::Class; | |
my ($ma, $mi, $ri) = file('package.json')->slurp =~ m/"version": "(\d+)\.(\d+)\.(\d+)"/; | |
say "Current version: $ma.$mi.$ri"; | |
$ri++; | |
print "Next version [$ma.$mi.$ri]: "; | |
my $VERSION = (<> =~ s/\s+//rg) || "$ma.$mi.$ri"; | |
for ('package.json') { | |
my $new = file($_)->slurp =~ s/"version": ".+?"/"version": "$VERSION"/r; | |
my $fh = file($_)->open('w'); | |
print $fh $new; | |
close $fh; | |
} | |
print "Realy want to publish [$VERSION] to npm? [yN]: "; | |
if (<> =~ /y/i) { | |
say "Publishing..."; | |
system('npm publish'); | |
system("git add -u"); | |
system("git commit -m '$VERSION'"); | |
system("git tag $VERSION"); | |
system("git push --tags"); | |
system("git push"); | |
} else { | |
say "Canceled"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment