From 689c3955db0f764b0676f8ae19e7db5d895c137e Mon Sep 17 00:00:00 2001 From: Patrick Jahns Date: Thu, 23 Aug 2018 09:26:09 +0200 Subject: [PATCH 1/3] added ability to build the app --- .gitignore | 1 + Makefile | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c795b05 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1234df9 --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +SHELL := /bin/bash + +# directories +build_dir=build +dist_dir=$(build_dir)/dist +app_name=$(notdir $(CURDIR)) +package_dir=$(CURDIR)/$(dist_dir)/$(app_name) + +# start with displaying help +.DEFAULT_GOAL := help + +help: + @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' + + + +## +## Build +##-------------------------------------- + + +.PHONY: dist +dist: ## create releasable tarball +dist: + rm -rf $(dist_dir) + mkdir -p $(dist_dir) + tar -czf $(dist_dir)/$(app_name).tar.gz \ + --exclude-vcs \ + --exclude="../$(app_name)/build" \ + ../$(app_name) + From 38bda3800f7a697b2dc48657a5cfe49f501d489f Mon Sep 17 00:00:00 2001 From: Patrick Jahns Date: Tue, 28 Aug 2018 13:06:56 +0200 Subject: [PATCH 2/3] bootstrapped basic pipeline to lint the app to ensure it is installable --- .drone.yml | 47 +++++++++++++++ .gitignore | 5 +- Makefile | 66 +++++++++++++++++----- composer.json | 15 +++++ composer.lock | 57 +++++++++++++++++++ vendor-bin/php-parallel-lint/composer.json | 5 ++ 6 files changed, 181 insertions(+), 14 deletions(-) create mode 100644 .drone.yml create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 vendor-bin/php-parallel-lint/composer.json diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..55d5aa0 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,47 @@ +workspace: + base: /var/www/owncloud + path: apps/testing + +branches: + - master + +pipeline: + prepare-lint: + image: owncloudci/php + pull: true + commands: + - make vendor-bin/php-parallel-lint/vendor + + lint-php5: + image: owncloudci/php:5.6 + pull: true + group: lint + commands: + - make test-php-lint + + lint-php70: + image: owncloudci/php:7.0 + pull: true + group: lint + commands: + - make test-php-lint + + lint-php71: + image: owncloudci/php:7.1 + pull: true + group: lint + commands: + - make test-php-lint + + lint-php72: + image: owncloudci/php:7.2 + pull: true + group: lint + commands: + - make test-php-lint + + build: + image: owncloudci/php:7.1 + pull: true + commands: + - make dist \ No newline at end of file diff --git a/.gitignore b/.gitignore index c795b05..73afa8d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ -build \ No newline at end of file +build +/vendor/ +vendor-bin/**/vendor +vendor-bin/**/composer.lock \ No newline at end of file diff --git a/Makefile b/Makefile index 1234df9..01b5f93 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,20 @@ SHELL := /bin/bash +COMPOSER_BIN := $(shell command -v composer 2> /dev/null) +ifndef COMPOSER_BIN + $(error composer is not available on your system, please install composer) +endif + # directories -build_dir=build -dist_dir=$(build_dir)/dist app_name=$(notdir $(CURDIR)) -package_dir=$(CURDIR)/$(dist_dir)/$(app_name) +build_dir=$(CURDIR)/build +dist_dir=$(build_dir)/dist +src_files=README.md LICENSE +src_dirs=appinfo data img lib locking +all_src=$(src_dirs) $(src_files) + +# bin file definitions +PHPLINT=php -d zend.enable_gc=0 vendor-bin/php-parallel-lint/vendor/bin/parallel-lint # start with displaying help .DEFAULT_GOAL := help @@ -15,17 +25,47 @@ help: ## -## Build +## Build targets ##-------------------------------------- - .PHONY: dist -dist: ## create releasable tarball -dist: - rm -rf $(dist_dir) - mkdir -p $(dist_dir) - tar -czf $(dist_dir)/$(app_name).tar.gz \ - --exclude-vcs \ - --exclude="../$(app_name)/build" \ - ../$(app_name) +dist: ## Build distribution +dist: distdir package + +.PHONY: distdir +distdir: + rm -rf $(build_dir) + mkdir -p $(dist_dir)/$(app_name) + cp -R $(all_src) $(dist_dir)/$(app_name) + +.PHONY: package +package: + tar -czf $(dist_dir)/$(app_name).tar.gz -C $(dist_dir) $(app_name) + +## +## Tests +##-------------------------------------- + +.PHONY: test-php-lint +test-php-lint: ## Run phan +test-php-lint: vendor-bin/php-parallel-lint/vendor + $(PHPLINT) appinfo lib locking + +# +# Dependency management +#-------------------------------------- + +composer.lock: composer.json + @echo composer.lock is not up to date. + +vendor: + composer install --no-dev + +vendor/bamarni/composer-bin-plugin: + composer install + +vendor-bin/php-parallel-lint/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/php-parallel-lint/composer.lock + composer bin php-parallel-lint install --no-progress +vendor-bin/php-parallel-lint/composer.lock: vendor-bin/php-parallel-lint/composer.json + @echo php-parallel-lint composer.lock is not up to date. \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..9574b12 --- /dev/null +++ b/composer.json @@ -0,0 +1,15 @@ +{ + "name": "owncloud/testing", + "description": "ownCloud testing app", + "type": "owncloud-app", + "license": "AGPL", + "require": {}, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.2" + }, + "extra": { + "bamarni-bin": { + "bin-links": false + } + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..00cc44d --- /dev/null +++ b/composer.lock @@ -0,0 +1,57 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "a1f4c002bfc144d81b235e34066bb3d4", + "packages": [], + "packages-dev": [ + { + "name": "bamarni/composer-bin-plugin", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/bamarni/composer-bin-plugin.git", + "reference": "62fef740245a85f00665e81ea8f0aa0b72afe6e7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bamarni/composer-bin-plugin/zipball/62fef740245a85f00665e81ea8f0aa0b72afe6e7", + "reference": "62fef740245a85f00665e81ea8f0aa0b72afe6e7", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0" + }, + "require-dev": { + "composer/composer": "dev-master", + "symfony/console": "^2.5 || ^3.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Bamarni\\Composer\\Bin\\Plugin", + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Bamarni\\Composer\\Bin\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "time": "2017-09-11T13:13:58+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/vendor-bin/php-parallel-lint/composer.json b/vendor-bin/php-parallel-lint/composer.json new file mode 100644 index 0000000..a05eec3 --- /dev/null +++ b/vendor-bin/php-parallel-lint/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "jakub-onderka/php-parallel-lint": "^1.0" + } +} From 31cc9f447bd41e7988984111a7f7eb049500a2eb Mon Sep 17 00:00:00 2001 From: Patrick Jahns Date: Tue, 28 Aug 2018 13:28:51 +0200 Subject: [PATCH 3/3] added automation for publishing tag latest directly is github release --- .drone.yml | 13 ++++++++++++- README.md | 7 +++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 55d5aa0..95218e8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -44,4 +44,15 @@ pipeline: image: owncloudci/php:7.1 pull: true commands: - - make dist \ No newline at end of file + - make dist + + github_release: + image: plugins/github-release + pull: true + secrets: [ github_token ] + files: build/dist/testing.tar.gz + prerelease: true + file_exists: overwrite + checksum: sha256 + when: + event: tag \ No newline at end of file diff --git a/README.md b/README.md index 023de37..cabb56f 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,10 @@ git clone https://github.com/owncloud/testing.git php occ app:enable testing ``` + +## Publish latest version as github release + +The latest published version can be found at https://github.com/owncloud/testing/releases/tag/latest + +In order to update the latest version to be available, we need to move the github tag to a new HEAD. +Once the tag `latest` is pushed to github, drone-ci will build and publish the app to github \ No newline at end of file