Skip to content

Instantly share code, notes, and snippets.

@ken39arg
Created October 5, 2021 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ken39arg/9e7352681e92845c2f55da4f5e40686c to your computer and use it in GitHub Desktop.
Save ken39arg/9e7352681e92845c2f55da4f5e40686c to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
my $old_version=`git describe --tag --abbrev=0`;
chomp $old_version;
my ($major, $minor, $patch) = (0, 0, 0);
if ($old_version =~ /v?(\d+)\.(\d+)\.(\d+)/) {
($major, $minor, $patch) = ($1, $2, $3);
}
printf "old version: %s\n", $old_version;
for (@ARGV) {
if (/major/) {
$major++;
$minor = 0;
$patch = -1;
} elsif (/minor/) {
$minor++;
$patch = -1;
} elsif (/version=v?(\d+)\.(\d+)\.(\d+)/) {
($major, $minor, $patch) = ($1, $2, $3 - 1);
}
}
$patch++;
my $new_version = sprintf "v%d.%d.%d", $major, $minor, $patch;
printf "new version: %s\n", $new_version;
my $notes = `git log --first-parent $old_version...origin/develop --pretty=format:'%h %s'`;
my $command = sprintf "gh release create %s --title %s --notes '%s'", $new_version, $new_version, $notes;
print `$command`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment