From 8e78c77fc148fecb413aef136ad6ff3a9789d9c0 Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Thu, 8 Jan 2015 23:54:24 +0100 Subject: [PATCH] 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 --- .gitattributes | 31 +++++++++++++++++++++++++++++++ common.php | 4 ++-- index.php | 2 +- lib/helpers.php | 22 ++++++++++++++++++++++ scripts/make-archive.sh | 38 -------------------------------------- scripts/make-release.sh | 19 +++++++++++++++++++ scripts/make-tag.sh | 6 ------ 7 files changed, 75 insertions(+), 47 deletions(-) create mode 100644 .gitattributes delete mode 100755 scripts/make-archive.sh create mode 100755 scripts/make-release.sh delete mode 100755 scripts/make-tag.sh diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..0b89dbe --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/common.php b/common.php index e07a61b..f4f4ee5 100644 --- a/common.php +++ b/common.php @@ -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); } -}); +}); \ No newline at end of file diff --git a/index.php b/index.php index c6d373f..955d929 100644 --- a/index.php +++ b/index.php @@ -1,12 +1,12 @@ /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 diff --git a/scripts/make-release.sh b/scripts/make-release.sh new file mode 100755 index 0000000..90502d2 --- /dev/null +++ b/scripts/make-release.sh @@ -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 \ No newline at end of file diff --git a/scripts/make-tag.sh b/scripts/make-tag.sh deleted file mode 100755 index 108444f..0000000 --- a/scripts/make-tag.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -VERSION=$1 - -git tag -a v$VERSION -m "Version $VERSION" -git push origin v$VERSION