Skip to content
Snippets Groups Projects
Commit 5bdc68c5 authored by Cam Saul's avatar Cam Saul Committed by GitHub
Browse files

Merge pull request #5574 from metabase/mac-app-build-script-improvements

Mac app build script improvements
parents 3543183d 6772cd92
Branches
Tags
No related merge requests found
......@@ -36,7 +36,6 @@ OSX/Resources/metabase.jar
OSX/build
/osx-artifacts
OSX/dsa_priv.pem
bin/config.json
bin/release/aws-eb/metabase-aws-eb.zip
*.sqlite
/reset-password-artifacts
......
{
"codesigningIdentity": "Developer ID Application: Metabase, Inc",
"slackWebhookURL": "",
"awsProfile": "metabase",
"awsBucket": ""
"awsBucket": "downloads.metabase.com"
}
......@@ -8,11 +8,9 @@ use File::Copy 'copy';
use File::Copy::Recursive 'rcopy'; # CPAN
use File::Path 'remove_tree';
use File::stat 'stat';
use JSON 'encode_json', 'from_json'; # CPAN
use Readonly; # CPAN
use String::Util 'trim'; # CPAN
use Text::Caml; # CPAN
use WWW::Curl::Simple; # CPAN
use Metabase::Util;
......@@ -298,30 +296,6 @@ sub create_dmg {
# ------------------------------------------------------------ UPLOADING ------------------------------------------------------------
sub announce_on_slack {
Readonly my $slack_url => config('slackWebhookURL') or return;
Readonly my $version => version();
Readonly my $awsURL => 'https://s3.amazonaws.com/' . config('awsBucket') . '/' . upload_subdir() . '/Metabase.dmg';
my $text = "Metabase OS X $version 'Complexity-Embracing Toucan' Is Now Available!\n\n" .
"Get it here: $awsURL\n\n";
open(my $file, get_file_or_die($release_notes)) or die $!;
while (<$file>) {
m/^\s+<li>.*$/ && s|^\s+<li>(.*)</li>$|$1| && ($text .= '* ' . $_);
}
my $json = encode_json {
channel => '#general',
username => 'OS X Bot',
icon_emoji => ':bird:',
text => trim($text)
};
my $curl = WWW::Curl::Simple->new;
unless ((my $response = $curl->post($slack_url, $json))->code == 200) {
die 'Error posting to slack: ' . $response->code . ' ' . $response->content . "\n";
}
}
# Upload artifacts to AWS
# Make sure to run `aws configure --profile metabase` first to set up your ~/.aws/config file correctly
......@@ -352,8 +326,6 @@ sub upload {
's3', 'cp', $upload_dir,
"s3://$aws_bucket") == 0 or die "Upload failed: $!\n";
announce_on_slack;
announce "Upload finished."
}
......
# Metabase OS X App
NOTE: These instructions are only for packaging a built Metabase uberjar into `Metabase.app`. They are not useful if your goal is to work on Metabase itself; for development, please see our [developers' guide](developers-guide.md).
NOTE: These instructions are only for packaging a built Metabase uberjar into `Metabase.app`. They are not useful if your goal is to work on Metabase itself; for development, please see our [developers' guide](developers-guide.md).
## Prereqs
1. Install XCode.
2. Run `./bin/build` to build the latest version of the uberjar.
1. Install XCode command-line tools. In `Xcode` > `Preferences` > `Locations` select your current Xcode version in the `Command Line Tools` drop-down.
3. Update Perl. I'm not sure these steps are actually needed, so feel free to try skipping it and come back to it if it fails:
```bash
# Upgrade Perl
brew install perl
# Add new version of perl to your $PATH
# (replace "5.24.0_1" below with whatever version you installed)
echo 'export PATH="/usr/local/Cellar/perl/5.24.0_1/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
# Double-check that we're using the newer version of CPAN
# (If this is your first time running CPAN, use the default config settings when prompted)
cpan --version # You should see a line like "running under Perl version 5.24.0."
```
1. Run `./bin/build` to build the latest version of the uberjar.
4. Next, you'll need to run the following commands before building the app:
1. Next, you'll need to run the following commands before building the app:
```bash
# Fetch and initialize git submodule
git submodule update --init
# Install libcurl (needed by WWW::Curl::Simple (I think))
brew install curl && brew link curl --force
# The new version of LLVM is snippy so have CPAN pass compiler flags to fix errors
# (Make sure this file exists first. If you didn't upgrade Perl in the step above,
# it might be in a different location; perhaps called "Config.pm".
# You may need to run "cpan" (no arguments) to generate an appropriate initial config.
# As above, you can go with the defaults).
sed -i '' -e "s/'make_arg' => q\[\]/'make_arg' => q\[CCFLAGS=\"-Wno-return-type\"\]/" ~/.cpan/CPAN/MyConfig.pm
# Install Perl modules used by ./bin/osx-setup and ./bin/osx-release
# You may have to run this as sudo if you didn't upgrade perl as described in step above
cpan install File::Copy::Recursive JSON Readonly String::Util Text::Caml WWW::Curl::Simple
cpan install File::Copy::Recursive Readonly String::Util Text::Caml
# Copy JRE and uberjar
./bin/osx-setup
```
......@@ -66,19 +42,27 @@ brew install awscli
# You just need the access key ID and secret key; use the defaults for locale and other options.
aws configure --profile metabase
# Copy & Edit Config file. Alternative ask Cam for a copy of his
cp bin/config.json.template bin/config.json
emacs bin/config.json
# Obtain a copy of the private key used for signing the app (ask Cam)
# and put a copy of it at ./dsa_priv.pem
cp /path/to/private/key.pem OSX/dsa_priv.pem
```
You'll probably also want an Apple Developer ID Application Certificate in your computer's keychain. You'll need to generate a Certificate Signing Request from Keychain Access, and have Sameer go to [the Apple Developer Site](https://developer.apple.com/account/mac/certificate/) and generate one for you, then load the file on your computer.
You'll need the `Apple Developer ID Application Certificate` in your computer's keychain.
You'll need to generate a Certificate Signing Request from Keychain Access, and have Sameer go to [the Apple Developer Site](https://developer.apple.com/account/mac/certificate/)
and generate one for you, then load the file on your computer.
Finally, you may need to open the project a single time in Xcode to make sure the appropriate "build schemes" are generated (these are not checked into CI).
Run `open OSX/Metabase.xcodeproj` to open the project, which will automatically generate the appropriate schemes. This only needs to be done once.
After that, you are good to go:
```bash
# Bundle entire app, and upload to s3
./bin/osx-release
```
## Debugging ./bin/osx-release
* You can run individual steps of the release script by passing in the appropriate step subroutines. e.g. `./bin/osx-release create_dmg upload`.
The entire sequence of different steps can be found at the bottom of `./bin/osx-release`.
* Generating the DMG seems to be somewhat finicky, so if it fails with a message like "Device busy" trying the step again a few times usually resolves the issue.
You can continue the build process from the DMG creation step by running `./bin/osx-release create_dmg upload`.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment