add version number

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2016-11-02 07:46:19 +01:00
parent 753a794e94
commit 65d6aff9a2
No known key found for this signature in database
GPG Key ID: 9CE5ED29E7FCD38A
7 changed files with 56 additions and 11 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
box
lib/Version.php
tests/data
tests/vendor
updater.phar

View File

@ -2,9 +2,11 @@ box:
curl -L https://github.com/box-project/box2/releases/download/2.7.4/box-2.7.4.phar -o box
chmod +x box
updater.phar: box updater.php lib/*.php
updater.phar: box updater.php lib/*.php buildVersionFile.php
php buildVersionFile.php
./box build -c box.json
chmod +x updater.phar
rm lib/Version.php
clean:
rm updater.phar

View File

@ -1,6 +1,7 @@
{
"chmod": "0755",
"directories": ["lib"],
"files": ["version.php"],
"finder": [
{
"name": "*.php",

21
buildVersionFile.php Normal file
View File

@ -0,0 +1,21 @@
<?php
$currentTag = trim(shell_exec('git describe --tags'));
exec('git diff-files --quiet', $output, $returnValue);
$dirty = $returnValue === 0 ? '' : ' dirty';
$content = '<?php
namespace NC\Updater;
class Version {
function get() {
return \'' . $currentTag . $dirty . '\';
}
}
';
file_put_contents('lib/Version.php', $content);

View File

@ -26,15 +26,25 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class UpdateCommand extends Command {
protected function configure() {
$this
->setName('update-code')
->setDescription('Updates the code of an Nextcloud instance')
->setHelp("This command fetches the latest code that is announced via the updater server and safely replaces the existing code with the new one.")
;
}
protected function execute(InputInterface $input, OutputInterface $output) {
// TODO
}
protected function configure() {
$this
->setName('update-code')
->setDescription('Updates the code of an Nextcloud instance')
->setHelp("This command fetches the latest code that is announced via the updater server and safely replaces the existing code with the new one.");
}
protected function execute(InputInterface $input, OutputInterface $output) {
if (class_exists('NC\Updater\Version')) {
$versionClass = new Version();
$version = $versionClass->get();
} else {
$version = 'directly run from git checkout';
}
$output->writeln('Nextcloud Updater - version: ' . $version);
$output->writeln('');
// TODO
}
}

View File

@ -6,6 +6,9 @@ require __DIR__ . '/vendor/autoload.php';
use Symfony\Component\Console\Application;
use NC\Updater\UpdateCommand;
ini_set('display_errors', '0');
ini_set('log_errors', '1');
$application = new Application();
$application->add(new UpdateCommand());
$application->setDefaultCommand('update');

7
version.php Normal file
View File

@ -0,0 +1,7 @@
<?php
namespace NC\Updater;
function getUpdaterVersion() {
return '0.0.1-test-4-gd1856c7 dirty';
}