Skip to content

Commit 9b1a089

Browse files
committed
Add version script
1 parent f85faef commit 9b1a089

File tree

4 files changed

+75
-45
lines changed

4 files changed

+75
-45
lines changed

publish/pack.sh

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,35 @@
11
#!/bin/bash
22

3-
SOURCE_DIR=../src;
4-
TO_SOURCE_DIR=src;
5-
PACK_DIR=package;
6-
ROOT_DIR=..;
7-
PUBLISH=--publish
8-
9-
install(){
10-
npm i
11-
}
12-
13-
pack() {
14-
echo 'Clearing /src and /package...'
15-
node_modules/.bin/rimraf "$TO_SOURCE_DIR"
16-
node_modules/.bin/rimraf "$PACK_DIR"
17-
18-
echo 'Copying src...'
19-
node_modules/.bin/ncp "$SOURCE_DIR" "$TO_SOURCE_DIR"
20-
21-
echo 'Copying README and LICENSE to /src...'
22-
node_modules/.bin/ncp "$ROOT_DIR"/LICENSE "$TO_SOURCE_DIR"/LICENSE
23-
node_modules/.bin/ncp "$ROOT_DIR"/README.md "$TO_SOURCE_DIR"/README.md
24-
25-
echo 'Building /src...'
26-
cd "$TO_SOURCE_DIR"
27-
npm run compile
28-
cd ..
29-
30-
echo 'Creating package...'
31-
mkdir "$PACK_DIR"
32-
cd "$PACK_DIR"
33-
npm pack ../"$TO_SOURCE_DIR"
34-
35-
cd ..
36-
node_modules/.bin/rimraf "$TO_SOURCE_DIR"
37-
}
38-
39-
install && pack
3+
CURRENT_DIR=`dirname $0`
4+
SOURCE_DIR="$CURRENT_DIR"/../src
5+
TO_SOURCE_DIR="$CURRENT_DIR"/src
6+
PACK_DIR="$CURRENT_DIR"/package
7+
ROOT_DIR="$CURRENT_DIR"/..
8+
9+
echo 'Installing npm dependencies...'
10+
npm i
11+
12+
echo 'Clearing /src and /package...'
13+
node_modules/.bin/rimraf "$TO_SOURCE_DIR"
14+
node_modules/.bin/rimraf "$PACK_DIR"
15+
16+
echo 'Copying src...'
17+
node_modules/.bin/ncp "$SOURCE_DIR" "$TO_SOURCE_DIR"
18+
19+
echo 'Copying README and LICENSE to /src...'
20+
node_modules/.bin/ncp "$ROOT_DIR"/LICENSE "$TO_SOURCE_DIR"/LICENSE
21+
node_modules/.bin/ncp "$ROOT_DIR"/README.md "$TO_SOURCE_DIR"/README.md
22+
23+
echo 'Building /src...'
24+
cd "$TO_SOURCE_DIR"
25+
npm run compile
26+
cd ..
27+
28+
echo 'Creating package...'
29+
mkdir "$PACK_DIR"
30+
cd "$PACK_DIR"
31+
npm pack ../"$TO_SOURCE_DIR"
32+
33+
echo 'Cleaning...'
34+
cd ..
35+
node_modules/.bin/rimraf "$TO_SOURCE_DIR"

publish/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "nativescript-publish",
3-
"version": "1.0.0",
43
"description": "Publish helper",
4+
"version": "1.0.0",
5+
"private": true,
56
"devDependencies": {
67
"ncp": "^2.0.0",
78
"rimraf": "^2.5.0"

publish/publish.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/bin/bash
22

3-
PACK_DIR=package;
3+
CURRENT_DIR=`dirname $0`
4+
PACK_DIR="$CURRENT_DIR"/package
45

5-
publish() {
6-
cd $PACK_DIR
7-
echo 'Publishing to npm...'
8-
npm publish *.tgz
9-
}
6+
"$CURRENT_DIR"/pack.sh
107

11-
./pack.sh && publish
8+
echo 'Publishing to npm...'
9+
cd $PACK_DIR
10+
npm publish *.tgz

publish/version.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
CURRENT_DIR=`dirname $0`
4+
5+
cd "$CURRENT_DIR/.."
6+
7+
if [[ $# -eq 0 || ! $1 =~ ^major|minor|patch$ ]]; then
8+
echo "Invalid argument. Failing..."
9+
exit 1
10+
fi
11+
12+
if [ ! -z "$(git status --porcelain)" ]; then
13+
echo "Uncommited changes. Failing..."
14+
exit 1;
15+
fi
16+
17+
echo 'Bumping version...'
18+
cd "$CURRENT_DIR/../src"
19+
VERSION=`npm --no-git-tag-version version "$1"`
20+
#git add "package.json"
21+
#git commit -m "Bump version to $VERSION",
22+
23+
echo 'Updating CHANGELOG...'
24+
cd "$CURRENT_DIR/.."
25+
github_changelog_generator --future-release "$VERSION"
26+
#git add CHANGELOG.md
27+
#git commit -m "Update CHANGELOG.md"
28+
29+
echo 'Pushing changes to remote'
30+
#git push origin
31+
32+
echo 'Tagging...'
33+
#git tag "$VERSION"
34+
#git push origin --tags

0 commit comments

Comments
 (0)