From abaa47458bcb3aa78b3ec3e381fb23e8fdb2fcb4 Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Wed, 29 Mar 2017 15:20:07 +0000 Subject: [PATCH] Switch from commit message publishing to tag-based publishing --- .travis.yml | 6 ++++ package.json | 2 +- scripts/travis/publish.sh | 67 ++++++++++++--------------------------- 3 files changed, 28 insertions(+), 47 deletions(-) diff --git a/.travis.yml b/.travis.yml index b1d30b6dd..29eeef292 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,8 @@ notifications: branches: only: - master + # enable building tags + - /^v\d+\.\d+(\.\d+)?(-\S*)?$/ cache: yarn: true @@ -146,6 +148,10 @@ before_install: sudo mdutil -i off / npm install -g yarn fi + # enanble publishing for all tags that match the package version + - export PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)") + - export PUBLISH=$([[ "${TRAVIS_TAG:-}" == "v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") + - echo "Node binary publishing: ${PUBLISH}" - echo "Using ${JOBS} jobs" - yarn install --ignore-scripts # Bootstrap cmake to be able to run mason diff --git a/package.json b/package.json index 6f579d21d..701681a08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "osrm", - "version": "5.7.0-alpha.2", + "version": "5.7.0-latest.1", "private": false, "description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.", "dependencies": { diff --git a/scripts/travis/publish.sh b/scripts/travis/publish.sh index bf304196d..5352bd97c 100755 --- a/scripts/travis/publish.sh +++ b/scripts/travis/publish.sh @@ -3,56 +3,31 @@ set -eu set -o pipefail -# should be set for debug builds -export NPM_FLAGS=${NPM_FLAGS:-} +if [[ ${PUBLISH} == 'On' ]]; then + echo "PUBLISH is set to '${PUBLISH}', publishing!" -echo "node version is:" -which node -node -v + echo "node version is:" + which node + node -v -echo "dumping binary meta..." -./node_modules/.bin/node-pre-gyp reveal ${NPM_FLAGS} + echo "dumping binary meta..." + ./node_modules/.bin/node-pre-gyp reveal -# enforce that binary has proper ORIGIN flags so that -# it can portably find libtbb.so in the same directory -if [[ $(uname -s) == 'Linux' ]]; then - readelf -d ./lib/binding/node-osrm.node > readelf-output.txt - if grep -q 'Flags: ORIGIN' readelf-output.txt; then - echo "Found ORIGIN flag in readelf output" - cat readelf-output.txt - else - echo "*** Error: Could not found ORIGIN flag in readelf output" - cat readelf-output.txt - exit 1 + # enforce that binary has proper ORIGIN flags so that + # it can portably find libtbb.so in the same directory + if [[ $(uname -s) == 'Linux' ]]; then + readelf -d ./lib/binding/node-osrm.node > readelf-output.txt + if grep -q 'Flags: ORIGIN' readelf-output.txt; then + echo "Found ORIGIN flag in readelf output" + cat readelf-output.txt + else + echo "*** Error: Could not found ORIGIN flag in readelf output" + cat readelf-output.txt + exit 1 + fi fi -fi -echo "determining publishing status..." - -export COMMIT_MESSAGE=$(git log --format=%B --no-merges | head -n 1 | tr -d '\n') -echo "Commit message: ${COMMIT_MESSAGE}" - -if [[ $(./scripts/travis/is_pr_merge.sh) ]]; then - if [[ ${COMMIT_MESSAGE} =~ "[force publish binary]" ]]; then - echo "Publishing because it's forced" - ./node_modules/.bin/node-pre-gyp package ${NPM_FLAGS} - ./node_modules/.bin/node-pre-gyp publish ${NPM_FLAGS} - else - echo "Skipping publishing because this is a PR merge commit" - fi + ./node_modules/.bin/node-pre-gyp package publish info else - echo "This is a push commit, continuing to package..." - ./node_modules/.bin/node-pre-gyp package ${NPM_FLAGS} - - if [[ ${COMMIT_MESSAGE} =~ "[publish binary]" ]]; then - echo "Publishing" - ./node_modules/.bin/node-pre-gyp package ${NPM_FLAGS} - ./node_modules/.bin/node-pre-gyp publish ${NPM_FLAGS} - elif [[ ${COMMIT_MESSAGE} =~ "[republish binary]" ]]; then - echo "*** Error: Republishing is disallowed for this repository" - exit 1 - #./node_modules/.bin/node-pre-gyp unpublish publish ${NPM_FLAGS} - else - echo "Skipping publishing" - fi; + echo "PUBLISH is set to '${PUBLISH}', skipping." fi