Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #449 from masaka3620/master-releases
Browse files Browse the repository at this point in the history
publish latest and beta releases on tag from master
  • Loading branch information
masaka3620 authored Dec 4, 2018
2 parents 336bd5d + 1576e6c commit 8b096ed
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 52 deletions.
16 changes: 14 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
env:
global:
PUBLISH_NPM_LATEST_FROM="master"
sudo: false
language: node_js
node_js:
Expand All @@ -6,13 +9,22 @@ before_install:
- npm i -g npm@6.4.1
- yarn global add typescript
- yarn global add webpack
before_script:
- source ./scripts/is_latest.sh
script:
- yarn run lint
- yarn run test
deploy:
- provider: script
skip_cleanup: true
script:
- ./scripts/publish.sh
- ./scripts/publish-edge.sh
on:
branch: develop
branch: develop
- provider: script
skip_cleanup: true
script:
- ./scripts/publish-tag.sh $PUBLISH_NPM_LATEST_FROM
on:
tags: true
condition: $TRAVIS_IS_LATEST_TAG = true # sourced from ./scripts/is_latest.sh
2 changes: 1 addition & 1 deletion scripts/is_latest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if [ "$latest_tag" == "" ]; then
latest_tag="v0.0.0";
else
tag_commit="$(git rev-list -n 1 ${latest_tag})";
if [ "$tag_commit" = "$current_commit" ]; then
if [ "$tag_commit" == "$current_commit" ]; then
is_latest=true;
fi
fi
Expand Down
26 changes: 26 additions & 0 deletions scripts/publish-edge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

. "${TRAVIS_BUILD_DIR}/scripts/publish-utils.sh";

echo "Running on branch/tag ${TRAVIS_BRANCH}":

echo "Setting up git"
setup_git

echo "Creating new version"
git checkout -- .

git status

# get the short commit hash to include in the npm package
current_commit="$(git rev-parse --short HEAD)";

npm version prerelease -preid "${current_commit}" -no-git-tag-version

git commit -a -m "Updating version [skip ci]"

echo "Publish to NPM"

cp .npmrc.template $HOME/.npmrc

npm publish --tag edge
37 changes: 37 additions & 0 deletions scripts/publish-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

. "${TRAVIS_BUILD_DIR}/scripts/publish-utils.sh";

if [[ "$TRAVIS_TAG" == "" ]]; then
echo "No tag specified, skipping...";
else
echo "Running on branch/tag ${TRAVIS_TAG}":

echo "Setting up git"
setup_git

echo "Creating new version"
git checkout -- .

git status

npm version -no-git-tag-version $TRAVIS_TAG

echo "Pushing to git"
git commit -a -m "Publishing version ${TRAVIS_TAG} [skip ci]"

git push origin HEAD:${1}

echo "Build and Publish to NPM"

cp .npmrc.template $HOME/.npmrc

if [[ "$TRAVIS_TAG" == *"-beta"* ]]; then
echo "Publishing with beta tag to npm"
npm publish --tag beta
else
echo "Publishing with latest tag to npm"
npm publish
fi
fi

16 changes: 16 additions & 0 deletions scripts/publish-utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

setup_git() {
# Set the user name and email to match the API token holder
# This will make sure the git commits will have the correct photo
# and the user gets the credit for a checkin
git config --global user.email "devops@block.one"
git config --global user.name "blockone-devops"
git config --global push.default matching

# Get the credentials from a file
git config credential.helper "store --file=.git/credentials"

# This associates the API Key with the account
echo "https://${GITHUB_API_KEY}:@github.com" > .git/credentials
}
49 changes: 0 additions & 49 deletions scripts/publish.sh

This file was deleted.

0 comments on commit 8b096ed

Please sign in to comment.