Skip to content

Commit

Permalink
fix: update publishing script for releases (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbadan committed Jan 23, 2019
1 parent 1e31e18 commit 5c7edc8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ jobs:
- stage: "Fundamental-react: Test & Lint"
script: npm run lint && npm run test:coveralls && npm run size
- stage: Deploy
if: branch = master AND type != pull_request
if: (branch = master OR branch = tmp_branch_for_automated_release_do_not_use) AND type = push
before_deploy:
- bash ./ci-scripts/setup_npm.sh
deploy:
- provider: script
script: bash ./ci-scripts/publish.sh $TRAVIS_BRANCH $TRAVIS_BUILD_NUMBER
skip_cleanup: true
on:
all_branches: true
notifications:
email:
on_failure: always
Expand Down
28 changes: 20 additions & 8 deletions ci-scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
#! /bin/bash

# publish releases (already tagged by publish_release.sh)
if [[ "$TRAVIS_COMMIT_MESSAGE" =~ chore\(release\):[[:space:]]version[[:space:]][0-9]+\.[0-9]+\.[0-9]+$.* ]]; then
git config --global user.email "fundamental@sap.com"
git config --global user.name "fundamental-bot"

git checkout master
npm install

# publish releases
if [[ "$TRAVIS_BRANCH" = "tmp_branch_for_automated_release_do_not_use" ]]; then
# delete tmp_branch_for_automated_release_do_not_use branch from remote
git push "https://$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG" :tmp_branch_for_automated_release_do_not_use > /dev/null 2>&1;

# update the package version and commit to the git repository
npm run std-version

# pushes changes to master
git push --follow-tags "https://$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG" master > /dev/null 2>&1;

npm publish

# bump and publish rc
else
git config --global user.email "fundamental@sap.com"
git config --global user.name "fundamental-bot"

git checkout master
# update the package verion and commit to the git repository
# update the package rc version and commit to the git repository
npm run std-version -- --prerelease rc --no-verify

# pushes changes to master
git push --verbose --follow-tags "https://$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG" "$TRAVIS_BRANCH" > /dev/null 2>&1;

npm publish --tag prerelease
fi
fi
16 changes: 7 additions & 9 deletions ci-scripts/publish_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ hash_upstream=$(git rev-parse $git_branch@{upstream})

set -o errexit

githubEmail=`git config --get user.email`
githubName=`git config --get user.name`
git checkout -b tmp_branch_for_automated_release_do_not_use
git commit --allow-empty -m "chore(release): create new release via script"

git config --global user.email "fundamental@sap.com"
git config --global user.name "fundamental-bot"
# push new branch to trigger travis build
git push --set-upstream origin tmp_branch_for_automated_release_do_not_use

npm run std-version:release
git push --follow-tags origin

git config --global user.email "$githubEmail"
git config --global user.name "$githubName"
# delete branch on local machine
git checkout master
git branch -D tmp_branch_for_automated_release_do_not_use
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"size:debug": "npm run build && size-limit --why",
"start-js": "node scripts/start.js",
"start": "node scripts/start.js",
"std-version:release": "standard-version -m \"chore(release): version %s\"",
"std-version": "standard-version -m \"chore(release): version %s build ${TRAVIS_BUILD_NUMBER} [ci skip]\"",
"test:coverage": "jest --coverage",
"test:coveralls": "jest --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
Expand Down

0 comments on commit 5c7edc8

Please sign in to comment.