Skip to content

Commit

Permalink
add a script to make release packages for each platform
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Nov 6, 2017
1 parent d378496 commit eba7f52
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"smoke-test": "npm run build:test && mocha --exit test/smoke",
"watch": "guard --watchdir main renderer test",
"clean": "rm -rf build bower_components node_modules",
"pack:osx": "npm run build && npm prune --production && electron-packager ./ --platform=darwin --arch=x64 --icon=./resources/icon/nyaovim-logo.icns --extendInfo=./resources/osx_plist/file_associations.plist --app-bundle-id=io.github.rhysd.nyaovim && cp README.md LICENSE.txt NyaoVim-darwin-x64/ && zip --symlinks -r NyaoVim-darwin-x64.zip NyaoVim-darwin-x64/"
"release": "./scripts/make-release.sh"
},
"repository": {
"type": "git",
Expand Down
60 changes: 60 additions & 0 deletions scripts/make-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

set -e

case $OSTYPE in
darwin*) ;;
*)
echo "This script is only for macOS: ${OSTYPE}"
exit 1
;;
esac

function prepare-app() {
if [ -d app ]; then
rm -rf app
fi
mkdir app

npm run build:release

cp -R bin main renderer resources runtime package.json bower.json app/
cd app/

npm install --production
npm uninstall electron
npm prune
../node_modules/.bin/bower install
cd -
}

function pack-app() {
local version="$(./bin/cli.js --version)"
local electron_version="$(electron --version)"
local electron_version=${electron_version#v}

electron-packager ./app --platform=darwin --arch=x64 "--app-copyright=copyright (c) 2017 rhysd" --app-version=$version --build-version=$version --icon=./resources/icon/icon.icns --electron-version=$electron_version --extend-info=./resources/osx_plist/file_associations.plist --app-bundle-id=io.github.rhysd.nyaovim
electron-packager ./app --platform=linux --arch=all "--app-copyright=copyright (c) 2017 rhysd" --app-version=$version --build-version=$version --icon=./resources/icon/icon.ico --electron-version=$electron_version
electron-packager ./app --platform=win32 --arch=all "--app-copyright=copyright (c) 2017 rhysd" --app-version=$version --build-version=$version --icon=./resources/icon/icon.ico --electron-version=$electron_version --version-string=$version
}

function make-dist() {
if [ -d dist ]; then
rm -rf dist
fi
mkdir dist
local version="$(./bin/cli.js --version | head -n 1 | cut -d ' ' -f 3)"
for dir in `ls -1 | grep '^NyaoVim-'`; do
mv "$dir/LICENSE" "$dir/LICENSE.electron"
cp -R LICENSE.txt README.md docs "$dir"
zip --symlinks "dist/${dir}-${version}.zip" -r "$dir"
done
rm -rf NyaoVim-*
open dist
}

export PATH=$(pwd)/node_modules/.bin:$PATH

prepare-app
pack-app
make-dist

0 comments on commit eba7f52

Please sign in to comment.