introduce release script

This script replaces make-archive.sh and make-tag.sh.

Switch to 'git archive' to create a ZIP file from the repo. Its way
more faster, automates a lot things and works with the GitHub download
HEAD/Release/Tag as ZIP functionality as well.

git archive reads the file .gitattributes to determine which files has
to be excluded from the zip file.

It replaces the following placeholders in common.php:

$Format:%d$": with the output of git log --pretty=format:%d which
contains the tag of the last commit (if tagged).

$Format:%H$": with the hash of the latest included commit.

If no tag can be found the hash is appended to "master" and shown as
version number.

The approach is kind of hackish since no distinct format option for the
tag exists.

Fixes #231, https://github.com/fguillot/miniflux/issues/213#issuecomment-65631765
This commit is contained in:
Mathias Kresin 2015-01-08 23:54:24 +01:00
parent ad7d1ae7bc
commit 8e78c77fc1
7 changed files with 75 additions and 47 deletions

31
.gitattributes vendored Normal file
View File

@ -0,0 +1,31 @@
# used to remove files from deployment using `git archive`
# version number
common.php export-subst
# git files
.gitattributes export-ignore
.gitignore export-ignore
# core
data/*.sqlite export-ignore
scripts export-ignore
Dockerfile export-ignore
.travis.yml export-ignore
# documentation
**/docs/ export-ignore
**/README.* export-ignore
# composer files
composer.json export-ignore
vendor/composer/installed.json export-ignore
# theme sources
**/scss/ export-ignore
**/less/ export-ignore
**/*.rb export-ignore
# unittests
phpunit.xml export-ignore
**/tests/ export-ignore

View File

@ -6,7 +6,7 @@ if (file_exists(__DIR__.'/config.php')) {
require __DIR__.'/config.php';
}
defined('APP_VERSION') or define('APP_VERSION', 'master');
defined('APP_VERSION') or define('APP_VERSION', Helper\parseAppVersion('$Format:%d$','$Format:%H$'));
defined('HTTP_TIMEOUT') or define('HTTP_TIMEOUT', 20);
defined('BASE_URL_DIRECTORY') or define('BASE_URL_DIRECTORY', dirname($_SERVER['PHP_SELF']));
@ -63,4 +63,4 @@ PicoDb\Database::bootstrap('db', function() {
die($html);
}
});
});

View File

@ -1,12 +1,12 @@
<?php
require __DIR__.'/lib/helpers.php';
require __DIR__.'/common.php';
require __DIR__.'/vendor/fguillot/picofarad/lib/PicoFarad/Template.php';
require __DIR__.'/vendor/fguillot/picofarad/lib/PicoFarad/Response.php';
require __DIR__.'/vendor/fguillot/picofarad/lib/PicoFarad/Request.php';
require __DIR__.'/vendor/fguillot/picofarad/lib/PicoFarad/Session.php';
require __DIR__.'/vendor/fguillot/picofarad/lib/PicoFarad/Router.php';
require __DIR__.'/lib/helpers.php';
use PicoFarad\Router;
use PicoFarad\Response;

View File

@ -2,6 +2,28 @@
namespace Helper;
/*
* get Version number from git archive output
*/
function parseAppVersion($refnames, $commithash)
{
$version = 'master';
if ($refnames !== '$Format:%d$') {
$tag = preg_replace('/\s*\(.*tag:\sv([^,]+).*\)/i', '\1', $refnames);
if (!is_null($tag) && $tag !== $refnames) {
return $tag;
}
}
if ($commithash !== '$Format:%H$') {
$version .= '.'.$commithash;
}
return $version;
}
function favicon(array $favicons, $feed_id)
{
if (! empty($favicons[$feed_id])) {

View File

@ -1,38 +0,0 @@
#!/bin/sh
VERSION=$1
APP="miniflux"
cd /tmp
rm -rf /tmp/$APP /tmp/$APP-*.zip 2>/dev/null
git clone --depth 1 https://github.com/fguillot/$APP.git
rm -rf $APP/data/*.sqlite \
$APP/.git \
$APP/scripts \
$APP/Dockerfile \
$APP/vendor/composer/installed.json
find $APP -name docs -type d -exec rm -rf {} +;
find $APP -name tests -type d -exec rm -rf {} +;
find $APP -name composer.json -delete
find $APP -name phpunit.xml -delete
find $APP -name .travis.yml -delete
find $APP -name README.* -delete
find $APP -name .gitignore -delete
find $APP -name *.less -delete
find $APP -name *.scss -delete
find $APP -name *.rb -delete
sed -i.bak s/master/$VERSION/g $APP/common.php && rm -f $APP/*.bak
zip -r $APP-$VERSION.zip $APP
mv $APP-*.zip ~/Devel/websites/$APP
cd ~/Devel/websites/$APP/
unlink $APP-latest.zip
ln -s $APP-$VERSION.zip $APP-latest.zip
rm -rf /tmp/$APP 2>/dev/null

19
scripts/make-release.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
if [ $# -eq 0 ]; then
echo 1>&2 "$0: version number missing"
exit 2
fi
VERSION=$1
APP="miniflux"
# tag the release
git tag -a v$VERSION -m "Version $VERSION" && git push origin v$VERSION || exit 2
# create the archive
git archive v$VERSION -o ~/Devel/websites/$APP/$APP-$VERSION.zip
cd ~/Devel/websites/$APP/
unlink $APP-latest.zip
ln -s $APP-$VERSION.zip $APP-latest.zip

View File

@ -1,6 +0,0 @@
#!/bin/sh
VERSION=$1
git tag -a v$VERSION -m "Version $VERSION"
git push origin v$VERSION