forked from ANTsX/ANTs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: Version info in repo (ANTsX#1246)
* ENH: Encode version information in repo This avoids the placeholder version name 0.0.0.0 for tarball builds, which causes problems with external builds. Version.cmake now contains hard-coded version numbers that are used for builds (from git or tarball source). For releases, a variable is set so that binaries have version vA.B.C. For other commits (not a tagged release), the version is vA.B.C.dev. Builds from git repos still contain the additional information about the number of commits post-tag, and the short hash. To make a release, first be up to date on master, with a clean repo. Then run Utilities/tagRelease.pl. This will update Version.cmake, commit + push the changes, tag that commit, then change Version.cmake back into dev mode, and commit + push the result. Use 7 chars for short hash instead of 5 (git default is 7)
- Loading branch information
Showing
7 changed files
with
187 additions
and
111 deletions.
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
|
||
my $masterBranchLabel = "master"; | ||
|
||
if ($#ARGV < 0) { | ||
print qq{ | ||
$0 <tag> | ||
Run this from the ANTs/ directory to tag a release. | ||
Given a tag "vX.Y.Z", the script will | ||
1. Check user is on the ${masterBranchLabel} branch, with no uncommitted changes | ||
2. Update Version.cmake to set the version major, minor, patch | ||
3. Commit Version.cmake and push to origin ${masterBranchLabel} | ||
4. git tag with the release tag and push the tags | ||
}; | ||
|
||
exit 1; | ||
} | ||
|
||
my $tag = $ARGV[0]; | ||
|
||
if (!($tag =~ m/^v[0-9]\.[0-9]\.[0-9]/) ) { | ||
print "Tags for release should be in the format vX.Y.Z where X,Y,Z are integers\n"; | ||
exit(1); | ||
} | ||
|
||
# Check that we are ready to update version | ||
|
||
my $cleanTree = qq{On branch ${masterBranchLabel} | ||
Your branch is up to date with 'origin/${masterBranchLabel}'. | ||
nothing to commit, working tree clean | ||
}; | ||
|
||
my $status = `git status -b`; | ||
|
||
if (!($status eq $cleanTree)) { | ||
print "Must be up to date and on branch $masterBranchLabel to tag a release.\ngit status output:\n"; | ||
# run it again so output is colorized | ||
system("git status -b"); | ||
exit(1); | ||
} | ||
|
||
# Multiple tags get weird | ||
chomp(my $existingTag = `git tag --points-at HEAD`); | ||
if ($existingTag) { | ||
print "There is already a tag $existingTag on this commit. Exiting\n"; | ||
exit(1); | ||
} | ||
|
||
# Check tag matches Version.cmake | ||
open(my $inFH, "<", "Version.cmake"); | ||
my $versionDotCmake = do { local $/; <$inFH> }; | ||
close($inFH); | ||
|
||
my ($tagVersionMajor,$tagVersionMinor,$tagVersionPatch) = ($tag =~ m/^v([0-9])\.([0-9])\.([0-9])/); | ||
|
||
$versionDotCmake =~ s/set\(\$\{PROJECT_NAME\}_VERSION_MAJOR "[0-9]+"\)/set\(\$\{PROJECT_NAME\}_VERSION_MAJOR "${tagVersionMajor}"\)/ | ||
or die("Cannot find version information in Version.cmake"); | ||
|
||
$versionDotCmake =~ s/set\(\$\{PROJECT_NAME\}_VERSION_MINOR "[0-9]+"\)/set\(\$\{PROJECT_NAME\}_VERSION_MINOR "${tagVersionMinor}"\)/ | ||
or die("Cannot find version information in Version.cmake"); | ||
|
||
$versionDotCmake =~ s/set\(\$\{PROJECT_NAME\}_VERSION_PATCH "[0-9]+"\)/set\(\$\{PROJECT_NAME\}_VERSION_PATCH "${tagVersionPatch}"\)/ | ||
or die("Cannot find version information in Version.cmake"); | ||
|
||
$versionDotCmake =~ s/set\(\$\{PROJECT_NAME\}_RELEASE_VERSION 0\)/set\(\$\{PROJECT_NAME\}_RELEASE_VERSION 1\)/; | ||
|
||
open(my $outFH, ">", "Version.cmake"); | ||
print $outFH $versionDotCmake; | ||
close($outFH); | ||
|
||
print "Modified version information in Version.cmake. Review git diff:\n"; | ||
system("git diff"); | ||
print "\nProceed with tag? Please enter (yY/nN):"; | ||
chomp(my $proceed = <STDIN>); | ||
|
||
if (!(lc($proceed) eq "y")) { | ||
print "Reverting changes\n"; | ||
system("git checkout Version.cmake"); | ||
exit(1); | ||
} | ||
|
||
print("\nUpdating Version.cmake\n"); | ||
system("git add Version.cmake"); | ||
system("git commit -m \"Updating version for release $tag\""); | ||
print("\nPushing changed Version.cmake\n"); | ||
system("git push origin $masterBranchLabel") == 0 | ||
or die("Could not push updated Version.cmake"); | ||
print("\nApplying tag\n"); | ||
system("git tag -a $tag -m \"Tagging release $tag\""); | ||
system("git push --tags"); | ||
|
||
print("\nUpdating Version.cmake for development"); | ||
|
||
$versionDotCmake =~ s/set\(\$\{PROJECT_NAME\}_RELEASE_VERSION 1\)/set\(\$\{PROJECT_NAME\}_RELEASE_VERSION 0\)/; | ||
|
||
open(my $outFH, ">", "Version.cmake"); | ||
print $outFH $versionDotCmake; | ||
close($outFH); | ||
|
||
system("git add Version.cmake"); | ||
system("git commit -m \"Updating version for development post $tag\""); | ||
print("\nPushing changed Version.cmake\n"); | ||
system("git push origin $masterBranchLabel") == 0 |
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