Skip to content

Instantly share code, notes, and snippets.

@jjrscott
Created February 5, 2017 22:13
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 jjrscott/c647b2d554a41f3bb960fd8f6979a18d to your computer and use it in GitHub Desktop.
Save jjrscott/c647b2d554a41f3bb960fd8f6979a18d to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
# This script builds an archive release of a project. It should be run thus:
# $ cd <the project directory>
# $ build_project
use strict;
use Data::Dumper;
use Getopt::Long;
my $scheme;
my $productVersion;
my $productBuild;
GetOptions
(
"scheme=s" => \$scheme,
"product-version=s" => \$productVersion,
"product-build=s" => \$productBuild,
);
if (!defined $productBuild)
{
$productBuild = 0;
foreach my $tag (qx(git tag -l 'build-*'))
{
chomp $tag;
$tag =~ s/build-//;
$productBuild = $tag if ($productBuild < $tag);
}
$productBuild += 1;
}
my $currentDate=`date "+%Y-%m-%d-%H%M%S"`;
chomp $currentDate;
my $archivePrefix="$ENV{HOME}/Downloads/${scheme}_${productVersion}_${productBuild}_${currentDate}";
my $archivePath="${archivePrefix}.xcarchive";
my $derivedDataPath="${archivePrefix}.build";
system "xcodebuild", "-scheme", "${scheme}", "archive", "-archivePath", "${archivePath}", "-derivedDataPath", "${derivedDataPath}", "PRODUCT_VERSION=${productVersion}", "PRODUCT_BUILD=${productBuild}";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment