Skip to content

Commit

Permalink
Prepare makefile for release
Browse files Browse the repository at this point in the history
  • Loading branch information
mickenordin committed Jan 29, 2024
1 parent 8445490 commit af5be4f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rds/build
78 changes: 47 additions & 31 deletions rds/Makefile → Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@
# "prebuild": "npm install && node_modules/bower/bin/bower install && node_modules/bower/bin/bower update",
# "build": "node node_modules/gulp-cli/bin/gulp.js"
# },

app_name=$(notdir $(CURDIR))
build_tools_directory=$(CURDIR)/build/tools
source_build_directory=$(CURDIR)/build/artifacts/source
version=0.0.1
app_name=rds
app_dir=$(CURDIR)/$(app_name)
build_tools_directory=$(CURDIR)/$(app_name)/build/tools
source_build_directory=$(CURDIR)/$(app_name)/build/artifacts/source
source_package_name=$(source_build_directory)/$(app_name)
appstore_build_directory=$(CURDIR)/build/artifacts/appstore
appstore_package_name=$(app_name)
appstore_build_directory=$(CURDIR)/$(app_name)/build/artifacts/appstore
appstore_package_name=$(app_name)-$(version)
npm=$(shell which npm 2> /dev/null)
composer=$(shell which composer 2> /dev/null)

Expand All @@ -53,14 +54,14 @@ all: build
# is present, the npm step is skipped
.PHONY: build
build:
ifneq (,$(wildcard $(CURDIR)/composer.json))
make composer
ifneq (,$(wildcard $(app_dir)/composer.json))
cd $(app_dir) && make composer
endif
ifneq (,$(wildcard $(CURDIR)/package.json))
make js
ifneq (,$(wildcard $(app_dir)/package.json))
cd $(app_dir) && make js
endif
ifneq (,$(wildcard $(CURDIR)/js/package.json))
make js
ifneq (,$(wildcard $(app_dir)/js/package.json))
cd $(app_dir) && make js
endif

# Installs and updates the composer dependencies. If composer is not installed
Expand All @@ -74,7 +75,7 @@ ifeq (, $(composer))
mv composer.phar $(build_tools_directory)
php $(build_tools_directory)/composer.phar install --prefer-dist
else
composer install --prefer-dist
cd $(app_dir) && composer install --prefer-dist
endif

# Installs npm dependencies
Expand All @@ -83,37 +84,37 @@ js: jsinstall npm

.PHONY: jsinstall
jsinstall:
cd js && $(npm) install
cd $(app_dir)/js && $(npm) install

.PHONY: npm
npm: npmbuild npminstall

.PHONY: npmbuild
npmbuild:
cd js && $(npm) run build
cd $(app_dir)/js && $(npm) run build

.PHONY: npminstall
npminstall:
mv js/dist/js/app.js js/ && mv js/dist/css/app.css css/
mv $(app_dir)/js/dist/js/app.js $(app_dir)js/ && mv $(app_dir)/js/dist/css/app.css $(app_dir)/css/

# Removes the appstore build
.PHONY: clean
clean:
rm -rf ./build
rm -rf ./js/dist
rm -rf $(app_dir)/build
rm -rf $(app_dir)/js/dist

# Same as clean but also removes dependencies installed by composer, bower and
# npm
.PHONY: distclean
distclean: clean
rm -rf vendor
rm -rf node_modules
rm -rf js/vendor
rm -rf js/node_modules
rm js/app.js
rm css/app.css

# Builds the source and appstore package
rm -rf $(app_dir)/vendor
rm -rf $(app_dir)/node_modules
rm -rf $(app_dir)/js/vendor
rm -rf $(app_dir)/js/node_modules
rm $(app_dir)/js/app.js
rm $(app_dir)/css/app.css

# Bui$(app_dir)/lds the source and appstore package
.PHONY: dist
dist:
make source
Expand All @@ -124,18 +125,20 @@ dist:
source:
rm -rf $(source_build_directory)
mkdir -p $(source_build_directory)
tar cvzf $(source_package_name).tar.gz ../$(app_name) \
cd $(app_dir) && tar cvzf $(source_package_name).tar.gz ../$(app_name) \
--exclude-vcs \
--exclude="../$(app_name)/build" \
--exclude="../$(app_name)/js/node_modules" \
--exclude="../$(app_name)/node_modules" \
--exclude="../$(app_name)/*.log" \
--exclude="../$(app_name)/js/*.log" \
--exclude="../$(app_name)/js/*.log"

# Builds the source package for the app store, ignores php and js tests
.PHONY: appstore
appstore:
tar cvzf ../$(appstore_package_name).tar.gz \
.PHONY: package
package: build
rm -rf $(appstore_build_directory)
mkdir -p $(appstore_build_directory)
cd $(app_dir) && tar cvzf $(appstore_build_directory)/$(appstore_package_name).tar.gz \
--exclude-vcs \
--exclude="./build" \
--exclude="./*.tar.gz" \
Expand All @@ -160,3 +163,16 @@ appstore:
--exclude="./js/.*" \
--transform 's,^\.,rds,' \
.

sign: package
docker run --rm --volume $(cert_dir):/certificates --detach --name nextcloud nextcloud:latest
sleep 5
docker cp $(appstore_build_directory)/$(app_name)-$(version).tar.gz nextcloud:/var/www/html/custom_apps
docker exec -u www-data nextcloud /bin/bash -c "cd /var/www/html/custom_apps && tar -xzf $(app_name)-$(version).tar.gz && rm $(app_name)-$(version).tar.gz"
docker exec -u www-data nextcloud /bin/bash -c "php /var/www/html/occ integrity:sign-app --certificate /certificates/$(app_name).crt --privateKey /certificates/$(app_name).key --path /var/www/html/custom_apps/$(app_name)"
docker exec -u www-data nextcloud /bin/bash -c "cd /var/www/html/custom_apps && tar pzcf $(app_name)-$(version).tar.gz $(app_name)"
docker cp nextcloud:/var/www/html/custom_apps/$(app_name)-$(version).tar.gz $(appstore_build_directory)/$(app_name)-$(version).tar.gz
sleep 3
docker kill nextcloud

appstore: sign

0 comments on commit af5be4f

Please sign in to comment.