Skip to content

Commit

Permalink
Makefile improvements (#841)
Browse files Browse the repository at this point in the history
* Add encrypted certificates

* Test Makefile to exclusively use electron-builder

* Add appveyor configuration

* Trigger CI

* Fix yaml error

* Try `openssl` instead of path

* we're on windows 🤦‍♂️

* Enable debug mode

* Add blockRdp

* More testing

* more testing 2

* debugging

* switch to bash

* remove -a

* Retry build

* Install make

* Enable electron-builder debug

* Test paths

* debugging

* Force codesigning

* Update electron-builder

* disable forceCodesigning

* Add appx target

* Add appx to artifacts list

* Fix electron-builder config

* Test appx parameters

* enable asar

* Add build-if-changed to packaging

* Replace / with OS path separator

* Add cache & use npm ci

* Remove debugging output

* Fix appx build

* Fix config check

* WIP: Add macOS and Linux builds on CircleCI  (#810)

* Remove install step

* First circleci config test

* Fix xcode version

* Test with xcode 9

* Test with xcode 9.4.1

* clean up caches

* Update package-lock.json

* use node 10.4.1

* Fix linux paths

* Fix linux paths

* Paths, again...

* paths, paths, paths

* Fix cache

* Fix first build job

* Set xcode version to 9.4.1

* Add production secrets

* add sudo

* apt debugging

[skip appveyor]

* testing

* Fix packages

* Try npm install

* wrong npm install job 🤦‍♂️

* fix artifact upload

* add config.json to cached files

* Fix cert path

* Cypher test

* Revert "Cypher test"

This reverts commit 0c2a40f.

* Test

* rdp debugging

* move rdp init to on_finish

* Debugging PR env key issue

* move config env vars to admin panel

* env debugging

* Trigger CI

* finalize test

* Re-enable build

* Trigger CI Test

* remove ./

* switch to npm install

* Add customized electron-spellchecker

* Install linux deps in build job

* Test with additional linux deps

* Test linux deps

* More linux dependency testing

* more linux deps tests

* add 32bit deps for keyboard-layout-manager

* Remove all linux deps (ssh debugging)

* Add complete set of linux dependencies

* Add option to skip build to avoid multiple webpack builds

* Fix SKIP_BUILD flag

* Add customized electron-spellchecker

* Remove all linux deps (ssh debugging)

* Remove not longer needed imports

* Re-enable linux deps install

* Add GH Token

* Fix require casing

* Use spinal casing

* Add rebuild for native dependencies on start

* Fix typo 🤦‍♂️

* Disable spellchecker for some inputs

* Merge master into chore/build-improvements

* Update package-lock

* Merge chore/build-improvements

* Apply simplenote naming convention for artifacts

* Apply simplenote naming convention for artifacts

* Move npm scripts to Makefile

* Keep targets consistent betweeen npm and make

* Run npm audit fix

* Only build appx when build host is Windows

* Fix appx build on Windows
  • Loading branch information
adlk committed Sep 13, 2018
1 parent a6ab0f2 commit caba6ee
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 72 deletions.
137 changes: 86 additions & 51 deletions Makefile
@@ -1,9 +1,8 @@
ifeq ($(OS),Windows_NT)
FILE_PATH_SEP := \
# leave this line here. make is make... ¯\_(ツ)_/¯
FILE_PATH_SEP := \\
IS_WINDOWS := true
else
FILE_PATH_SEP := /
# leave this line here. make is make... ¯\_(ツ)_/¯
endif

/ = $(FILE_PATH_SEP)
Expand All @@ -17,92 +16,104 @@ NPM_BIN = $(shell npm bin)
RED=`tput setaf 1`
RESET=`tput sgr0`

START_APP := @$(NPM_BIN)/electron .
ELECTRON_TEST := ELECTRON_PATH=$(NPM_BIN)/electron $(NPM_BIN)/electron-mocha
CONFIG := $(THIS_DIR)/config.json
DESKTOP_BUILD_DIR := $(THIS_DIR)/desktop-build
BUILDER := $(THIS_DIR)/builder.js
BUILD_CONFIG := $(THIS_DIR)/resources/build-scripts/build-config-file.js
PACKAGE_DMG := $(THIS_DIR)/resources/build-scripts/package-dmg.js
PACKAGE_WIN32 := @$(NPM_BIN)/electron-builder
CERT_SPC := $(THIS_DIR)/resources/secrets/automattic-code.spc
CERT_PVK := $(THIS_DIR)/resources/secrets/automattic-code.pvk
SIMPLENOTE_JS := $(THIS_DIR)/dist/app.js
SIMPLENOTE_CHANGES_STD := `find "$(THIS_DIR)" -newer "$(SIMPLENOTE_JS)" \( -name "*.js" -o -name "*.jsx" -o -name "*.json" -o -name "*.scss" \) -type f -print -quit | grep -v .min. | wc -l`
SIMPLENOTE_BRANCH = $(shell git --git-dir .git branch | sed -n -e 's/^\* \(.*\)/\1/p')


# Build configurations
NODE_ENV = production
# Defines if we should compile web app via `build` target
SKIP_BUILD = false


# Main targets
.PHONY: start
start: rebuild-deps
@npx electron .

.PHONY: rebuild-deps
rebuild-deps:
@npx electron-rebuild
@NODE_ENV=$(NODE_ENV) npx electron .

# TODO: move npm scripts to makefile
.PHONY: dev
dev: NODE_ENV = development
dev:
@npm start
@$(MAKE) build NODE_ENV=$(NODE_ENV)

# check for config
config.json:
ifeq (,$(wildcard $(THIS_DIR)$/config.json))
$(error config.json not found. Required file, see docs)
endif
@NODE_ENV=$(NODE_ENV) npx webpack-dev-server --config ./webpack.config.js --content-base dist --host 0.0.0.0 --port 4000 --hot --inline

# Builds Calypso (desktop)
.PHONY: test
test:
@npx jest


# Build web app
.PHONY: build
build:
ifeq ($(SKIP_BUILD),false)
@echo building...
@echo "Building Simplenote Desktop on branch $(RED)$(SIMPLENOTE_BRANCH)$(RESET)"
NODE_ENV=production npx webpack -p --config webpack.config.dll.js && npx webpack -p --config webpack.config.js
ifeq ($(NODE_ENV),production)
$(eval IS_PRODUCTION = true)
endif

@$(MAKE) build-dll build-app IS_PRODUCTION=$(IS_PRODUCTION)
endif


# Build utils
.PHONY: build-app
build-app:
@npx webpack $(if $(IS_PRODUCTION),-p) --config ./webpack.config.js

.PHONY: build-dll
build-dll:
@npx webpack $(if $(IS_PRODUCTION),-p) --config ./webpack.config.dll.js

.PHONY: build-if-not-exists
build-if-not-exists: config.json
@if [ -f $(SIMPLENOTE_JS) ]; then true; else make build; fi

.PHONY: build-if-changed
build-if-changed: build-if-not-exists
@if [ $(SIMPLENOTE_CHANGES_STD) -eq 0 ]; then true; else make build; fi;

# Build packages
osx: config-release
@node $(BUILDER) darwin

linux: config-release
@node $(BUILDER) linux
# Build binaries only
.PHONY: osx
osx: config-release build-if-changed
@npx electron-builder -m --dir

.PHONY: linux
linux: config-release build-if-changed
@npx electron-builder -l --dir

.PHONY: win32
win32: config-release build-if-changed
@npx electron-builder --win --dir

win32: config-release
@node $(BUILDER) win32

# Packagers
# Build installers
.PHONY: package
package: build-if-changed
# @rm -rf $(DESKTOP_BUILD_DIR)/node_modules $(DESKTOP_BUILD_DIR)/desktop $(DESKTOP_BUILD_DIR)/dist
# @mkdir -p $(DESKTOP_BUILD_DIR)
# @cp -rf $(THIS_DIR)/package.json $(DESKTOP_BUILD_DIR)
# @cp -R $(THIS_DIR)/node_modules $(DESKTOP_BUILD_DIR)
# @cp -R $(THIS_DIR)/desktop $(DESKTOP_BUILD_DIR)
# @cp -R $(THIS_DIR)/dist $(DESKTOP_BUILD_DIR)

package-win32: build-if-changed

.PHONY: package-win32
package-win32:
ifeq ($(IS_WINDOWS),true)
@echo Building .appx as well
@npx electron-builder --win --config=./electron-builder-appx.json
else
@echo Skipping .appx as we are not on a Windows host
@npx electron-builder --win
# @$(PACKAGE_WIN32) ./release/Simplenote-win32-ia32 --win --ia32 --config=./resources/build-config/win32.json
# @node $(THIS_DIR)/resources/build-scripts/rename-with-version-win.js
# @node $(THIS_DIR)/resources/build-scripts/code-sign-win.js --spc=$(CERT_SPC) --pvk=$(CERT_PVK)
endif

.PHONY: package-osx
package-osx: build-if-changed
@npx electron-builder --mac
# @node $(PACKAGE_DMG)
# @ditto -c -k --sequesterRsrc --keepParent --zlibCompressionLevel 9 ./release/Simplenote-darwin-x64/Simplenote.app ./release/Simplenote.app.zip
# @node $(THIS_DIR)/resources/build-scripts/rename-with-version-osx.js

.PHONY: package-linux
package-linux: build-if-changed
@npx electron-builder --linux

config-release: config.json install

# NPM
.PHONY:
install: node_modules

node_modules/%:
Expand All @@ -112,3 +123,27 @@ node_modules: package.json
@npm prune
@npm install
@touch node_modules


# Checks
config.json:
ifeq (,$(wildcard $(THIS_DIR)$/config.json))
$(error config.json not found. Required file, see docs)
endif


# Utils
.PHONY: config-release
config-release: config.json install

.PHONY: rebuild-deps
rebuild-deps:
@npx electron-rebuild

.PHONY: format
format:
@npx prettier --write {desktop,lib,sass}/{**/,*}.{js,json,jsx,sass}

.PHONY: lint
lint:
@npx eslint --ext .js --ext .jsx lib
24 changes: 24 additions & 0 deletions electron-builder-appx.json
@@ -0,0 +1,24 @@
{
"win": {
"target": [{
"target": "nsis",
"arch": [
"ia32",
"x64"
]
},
{
"target": "appx"
}
]
},
"appx": {
"applicationId": "Simplenote",
"identityName": "22490Automattic.Simplenote",
"publisher": "CN=E2E5A157-746D-4B04-9116-ABE5CB928306",
"publisherDisplayName": "Automattic",
"backgroundColor": "transparent",
"artifactName": "Simplenote-win-${version}-${arch}.${ext}"
},
"extends": "./electron-builder.json"
}
11 changes: 0 additions & 11 deletions electron-builder.json
Expand Up @@ -42,20 +42,9 @@
"ia32",
"x64"
]
},
{
"target": "appx"
}
]
},
"appx": {
"applicationId": "Simplenote",
"identityName": "22490Automattic.Simplenote",
"publisher": "CN=E2E5A157-746D-4B04-9116-ABE5CB928306",
"publisherDisplayName": "Automattic",
"backgroundColor": "transparent",
"artifactName": "Simplenote-win-${version}-${arch}.${ext}"
},
"nsis": {
"perMachine": true,
"artifactName": "Simplenote-win-${version}-${arch}.${ext}"
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 6 additions & 9 deletions package.json
Expand Up @@ -11,15 +11,12 @@
"license": "GPL-2.0",
"homepage": "https://simplenote.com",
"scripts": {
"test": "jest",
"build": "NODE_ENV=development npm run build:dll && npm run build:app",
"build:app": "webpack --config ./webpack.config.js",
"build:dll": "webpack --config ./webpack.config.dll.js",
"build:prod": "NODE_ENV=production webpack -p --config ./webpack.config.dll.js && webpack -p --config ./webpack.config.js",
"electron": "electron .",
"format": "prettier --write {desktop,lib,sass}/{**/,*}.{js,json,jsx,sass}",
"lint": "eslint --ext .js --ext .jsx lib",
"start": "NODE_ENV=hot npm run build && webpack-dev-server --config ./webpack.config.js --content-base dist --host 0.0.0.0 --port 4000 --hot --inline"
"dev": "make dev",
"start": "make start NODE_ENV=development",
"test": "make test",
"lint": "make lint",
"format": "make format",
"build": "make build"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit caba6ee

Please sign in to comment.