Skip to content

Commit

Permalink
Publish hyper-sublette to NPM
Browse files Browse the repository at this point in the history
  • Loading branch information
sublee committed Jun 19, 2019
1 parent 54a1afc commit d7b0d2a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 deletions.
17 changes: 12 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ python:

install:
- pip install -r factory/requirements.txt
- apt-get install nodejs
- sudo apt-get install nodejs
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc

before_script:
Expand All @@ -22,17 +22,24 @@ script:
- python factory/configs.py

after_success:
# deploy assets
# stage assets
- git add -A 'plates/*'
- git add -A 'showcase/*'
- git add -A 'configs/*'

# publish configs
- >
find configs -name 'publish.sh' |
xargs -I{} bash -c
'cd $(dirname {}); git diff --cached --quiet . || (echo {}; bash publish.sh)'
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^
# └─ Check if this directory has been changed.

# deploy assets
- git commit -m 'Generate assets in Travis CI [ci skip]'
- git remote add deploy "https://$GITHUB_TOKEN@github.com/sublee/sublette.git"
- git push deploy "$TRAVIS_BRANCH"

# deploy configs
- find configs -name 'deploy.sh' | xargs -I{} bash -c 'cd $(dirname {}) && bash deploy.sh'

branches:
only:
- master
Expand Down
3 changes: 2 additions & 1 deletion configs/Hyper/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "hyper-sublette",
"name": "hyper-sublette-test",
"version": "#VERSION#",
"description": "Sublette for Hyper",
"author": "Heungsub Lee <sub@subl.ee> (https://subl.ee/)",
"license": "MIT",
Expand Down
10 changes: 10 additions & 0 deletions configs/Hyper/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PREV_VERSION="$(npm show hyper-sublette-test version 2>/dev/null || echo 0.0.0)"

MAJOR="$(echo "$PREV_VERSION" | awk -F. '{ print $1 }')"
MINOR="$(echo "$PREV_VERSION" | awk -F. '{ print $2 }')"
PATCH="$(echo "$PREV_VERSION" | awk -F. '{ print $3 }')"

VERSION="$MAJOR.$MINOR.$((PATCH+1))"
sed -i "s/#VERSION#/$VERSION/g" package.json

npm publish
13 changes: 0 additions & 13 deletions factory/configs/Hyper/deploy.sh

This file was deleted.

11 changes: 11 additions & 0 deletions factory/configs/Hyper/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Publish hyper-sublette to NPM.
PREV_VERSION="$(npm show hyper-sublette version 2>/dev/null || echo 0.0.0)"

MAJOR="$(echo "$PREV_VERSION" | awk -F. '{ print $1 }')"
MINOR="$(echo "$PREV_VERSION" | awk -F. '{ print $2 }')"
PATCH="$(echo "$PREV_VERSION" | awk -F. '{ print $3 }')"

VERSION="$MAJOR.$MINOR.$((PATCH+1))"
sed -i "s/#VERSION#/$VERSION/g" package.json

npm publish

0 comments on commit d7b0d2a

Please sign in to comment.