-
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.
- Loading branch information
1 parent
879ca6e
commit ba8012e
Showing
2,117 changed files
with
6,972 additions
and
226,101 deletions.
There are no files selected for viewing
File renamed without changes.
Binary file not shown.
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,14 @@ | ||
# Contribution Guidelines | ||
|
||
## Rules | ||
|
||
There are a few basic ground-rules for contributors: | ||
|
||
1. **No `--force` pushes** or modifying the Git history in any way. | ||
2. **External API changes and significant modifications** should be subject to a **pull request** to solicit feedback from other contributors. | ||
3. Use a non-`master` branch for ongoing work. | ||
4. Adhere to existing code style as much as possible. | ||
|
||
## Releases | ||
|
||
Declaring formal releases remains the prerogative of the project maintainer. |
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,150 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
/** | ||
* @author Chris Corbyn <[email protected]> | ||
* | ||
* Copyright © 2013-2014 Chris Corbyn. | ||
*/ | ||
|
||
/* Generate releases in Github */ | ||
|
||
namespace Boris; | ||
|
||
require __DIR__ . '/lib/autoload.php'; | ||
|
||
$args = getopt('hv:', array( | ||
'help', | ||
'version:' | ||
)); | ||
|
||
if (count($args) != 1) { | ||
help(); | ||
exit(1); | ||
} | ||
|
||
foreach ($args as $opt => $value) { | ||
switch ($opt) { | ||
case 'v': | ||
case 'version': | ||
version($value); | ||
exit(0); | ||
|
||
case 'h': | ||
case 'help': | ||
help(); | ||
exit(0); | ||
|
||
default: | ||
unknown($opt); | ||
exit(1); | ||
} | ||
} | ||
|
||
function help() | ||
{ | ||
echo <<<HELP | ||
Boris release generator script. | ||
Usage: | ||
./release.php --version 1.2 Create a release for v1.2 | ||
./release.php --help Display this help message | ||
HELP; | ||
} | ||
|
||
function version($newVersion) | ||
{ | ||
$token = get_token(); | ||
$user = get_user(); | ||
$repo = get_repo(); | ||
$oldVersion = Boris::VERSION; | ||
$phar = "boris.phar"; | ||
|
||
printf("Building version v%s...\n", $newVersion); | ||
|
||
printf(" Updating Boris::VERSION (%s) to %s...\n", $oldVersion, $newVersion); | ||
`perl -pi -e 's/$oldVersion/$newVersion/' lib/Boris/Boris.php README.md`; | ||
|
||
printf(" Committing changes...\n"); | ||
`git commit -am "Version bump to $newVersion"`; | ||
|
||
printf(" Pushing changes upstream...\n"); | ||
`git push`; | ||
|
||
printf(" Creating tag v%s...\n", $newVersion); | ||
`git tag -a "v$newVersion" -m "Auto-generated tag"`; | ||
|
||
printf(" Pushing tags upstream...\n"); | ||
`git push --tags`; | ||
|
||
printf(" Creating release on github...\n"); | ||
$response = `curl \ | ||
-sL \ | ||
-XPOST \ | ||
-H "Authorization: token $token" \ | ||
--data-binary '{"tag_name":"v$newVersion"}' \ | ||
https://api.github.com/repos/$user/$repo/releases`; | ||
|
||
$json = json_decode($response, true); | ||
$id = $json['id']; | ||
|
||
if (empty($id)) { | ||
printf("Failed.\n"); | ||
printf("%s\n", $response); | ||
exit(1); | ||
} | ||
|
||
printf(" Building phar...\n"); | ||
`box build`; | ||
|
||
printf("Uploading phar to GitHub...\n"); | ||
`curl -XPOST \ | ||
-sL \ | ||
-H "Authorization: token $token" \ | ||
-H "Content-Type: application/octet-stream" \ | ||
--data-binary @$phar \ | ||
https://uploads.github.com/repos/$user/$repo/releases/$id/assets?name=$phar`; | ||
|
||
printf("Done.\n"); | ||
} | ||
|
||
function get_token() | ||
{ | ||
if (getenv('GITHUB_TOKEN')) { | ||
return getenv('GITHUB_TOKEN'); | ||
} else { | ||
printf("Missing environment variable \$GITHUB_TOKEN\n"); | ||
exit(1); | ||
} | ||
} | ||
|
||
function get_origin() | ||
{ | ||
$remotes = `git remote -v`; | ||
if (!preg_match('/^origin\s+(\S*?.git)\s+\(push\)/m', $remotes, $matches)) { | ||
printf("Unable to find origin in $remotes\n"); | ||
exit(1); | ||
} | ||
return $matches[1]; | ||
} | ||
|
||
function get_user() | ||
{ | ||
$origin = get_origin(); | ||
if (!preg_match('#^.*?[/:]([^/]+)/([^/]+)\.git$#', $origin, $matches)) { | ||
printf("Don't know how to parse $origin\n"); | ||
exit(1); | ||
} | ||
return $matches[1]; | ||
} | ||
|
||
function get_repo() | ||
{ | ||
$origin = get_origin(); | ||
if (!preg_match('#^.*?[/:]([^/]+)/([^/]+)\.git$#', $origin, $matches)) { | ||
printf("Don't know how to parse $origin\n"); | ||
exit(1); | ||
} | ||
return $matches[2]; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.