Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Adding build script #44

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
/puli.json
/box.json
/.puli
/.idea
*.iml
.travis/build-key.pem
.travis/secrets.tar
23 changes: 19 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
language: php

sudo: false

cache:
directories:
- $HOME/.composer/cache/files

- $HOME/.composer/cache/files
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason why you removed these spaces?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no not really but the travis shell script removes it (:

matrix:
include:
- php: 5.3
- php: 5.4
- php: 5.5
- php: 5.6
env:
- EXECUTE_DEPLOYMENT=true
- php: hhvm
- php: nightly
- php: 7.0
Expand All @@ -34,9 +33,25 @@ script: if [[ $COVERAGE = yes ]]; then vendor/bin/phpunit --verbose --coverage-c

after_script: if [[ $COVERAGE = yes ]]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi

after_success:
- openssl aes-256-cbc -K $encrypted_7a05c4e35c71_key -iv $encrypted_7a05c4e35c71_iv
-in .travis/secrets.tar.enc -out .travis/secrets.tar -d
- if [[ $EXECUTE_DEPLOYMENT == 'true' && ($TRAVIS_BRANCH == 'master' || $TRAVIS_TAG != '') && $TRAVIS_PULL_REQUEST == 'false' ]]; then composer install --no-dev ; fi
- if [[ $EXECUTE_DEPLOYMENT == 'true' && ($TRAVIS_BRANCH == 'master' || $TRAVIS_TAG != '') && $TRAVIS_PULL_REQUEST == 'false' ]]; then ./bin/deploy.sh ; fi
- if [[ $EXECUTE_DEPLOYMENT == 'true' && ($TRAVIS_BRANCH == 'master' || $TRAVIS_TAG != '') && $TRAVIS_PULL_REQUEST == 'false' ]]; then ./puli.phar ; fi

notifications:
webhooks:
urls: ['https://webhooks.gitter.im/e/9ccc2378e6c0de6480f8']
on_success: change
on_failure: always
on_start: never

deploy:
- provider: releases
skip_cleanup: true
api_key:
secure: XufYEOR4sihf4gJ9zTizrupydaQnkCVZLDbdXRAmfVNgDQNkSI2a8aKyGxxH2YTmJn65DHiFAuNMv5LIwG1e1XuiuW4ZFsEOj7o+qV5NZCzkTiYY4qYVlsut2lk8Y6dOaJl9wjvBKxK/ELbs66M4NS/3qSluaGAL1K3DtuBzF0MFLT0S4HhwoYkkJaTx3XZcCNSJA7kxT/yhSpMOhlmVXw89yJbxHiVya/YVLBHGSFpN8WpHSYxZuOnWw4OZrvS/Le+v9cvxqK1JLzV6tKe6X3DtBRzyVoO+c0CXm7Q0nn+HYtuZHnn2uOsLb68kRo8R2jjRImF/q6xdhoUHmrKFa8GgaVZkYHoCYVIbX0e2DzLvgo5DXEs1H8sNKFBjI0zRj8B9CDV6Blqap3a4d6JBsmmTAt4sFENWU4Gekv/vfB9PEIjmbLl+5/YHQcHtzU+kMnAGzpJ2d+M9BOjiUPdEHSek7vaEdE5ySAMM/0PZo2y9ZP1Go7yzHybip3WdLO6G8Q0HOoYUL0orJ9rZOT+NYBIgWXHymyFM2TJvoGlgsQRzagVseyH8qbmGo1FuMrTGePYjCo00xT3S2RgW4nXMPi0Qx6dsTUqGZDr8v1Qz2gKJlgP/a7Wpd+P1km+ibkVyqb94CgCx3Ryxf7YBplUuPT9Th+f/AiGOFh9OLA729M4=
file: puli.phar
on:
tags: true
Binary file added .travis/secrets.tar.enc
Binary file not shown.
9 changes: 9 additions & 0 deletions DEPLOY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Deploy

```
ssh-keygen -t rsa -b 4096 -C "<your email address>"
```

* store deploy key in github

cp $HOME/.ssh/<repo>_rsa .travis/build-key.pem
39 changes: 39 additions & 0 deletions bin/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
# Unpack secrets; -C ensures they unpack *in* the .travis directory
tar xvf .travis/secrets.tar -C .travis

# Setup SSH agent:
eval "$(ssh-agent -s)" #start the ssh agent
chmod 600 .travis/build-key.pem
ssh-add .travis/build-key.pem

# Get box and build PHAR
wget https://box-project.github.io/box2/manifest.json
BOX_URL=$(php bin/parse-manifest.php manifest.json)
rm manifest.json
wget -O box.phar ${BOX_URL}
chmod 755 box.phar
./box.phar build -vv

# TODO if build with gh-pages
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's happening with these TODOs?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will remove it when its clear how we deploy the files (:


# Setup git defaults:
# TODO set username and email
# git config --global user.email "[email protected]"
# git config --global user.name "Johannes Wachter"

# Add SSH-based remote to GitHub repo:
# TODO remote
# git remote add deploy [email protected]:wachterjohannes/cli.git
# git fetch deploy

# Checkout gh-pages and add PHAR file and version:
# git checkout -b gh-pages deploy/gh-pages
# git pull deploy gh-pages
# mv build/* ./puli.phar
# sha1sum puli.phar > puli.phar.version
# git add puli.phar puli.phar.version

# Commit and push:
# git commit -m 'Rebuilt phar'
# git push deploy gh-pages:gh-pages
30 changes: 30 additions & 0 deletions bin/parse-manifest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

chdir(__DIR__ . '/../');
$fallbackUrl = 'https://github.com/box-project/box2/releases/download/2.6.0/box-2.6.0.phar';

if (!isset($argv[1]) || !is_file($argv[1])) {
return $fallbackUrl;
}

$manifestJson = file_get_contents($argv[1]);
$files = json_decode($manifestJson, true);

if (!is_array($files)) {
echo $fallbackUrl;
exit(0);
}

foreach ($files as $file) {
if (!is_array($file) || !isset($file['version'])) {
continue;
}

if (version_compare($file['version'], '2.6.0', '>=')) {
echo $file['url'];
exit(0);
}
}

echo $fallbackUrl;
exit(0);