|
| 1 | +#!/bin/bash |
| 2 | +# Publish package on Meteor's Atmosphere.js |
| 3 | + |
| 4 | +# Make sure Meteor is installed, per https://www.meteor.com/install. The curl'ed script is totally safe; takes 2 minutes to read its source and check. |
| 5 | +type meteor >/dev/null 2>&1 || { curl https://install.meteor.com/ | sh; } |
| 6 | + |
| 7 | +# sanity check: make sure we're in the root directory of the checkout |
| 8 | +cd "$( dirname "$0" )/.." |
| 9 | + |
| 10 | + |
| 11 | +function cleanup() { |
| 12 | + # we copied the file as package.js, regardless of its original name |
| 13 | + rm package.js |
| 14 | + |
| 15 | + # temporary build files |
| 16 | + rm -rf ".build.$PACKAGE_NAME" versions.json |
| 17 | +} |
| 18 | + |
| 19 | + |
| 20 | +# publish separately any package*.js files we have, e.g. package.js, package-compat.js |
| 21 | +for PACKAGE_FILE in meteor/package*.js; do |
| 22 | + |
| 23 | + # Meteor expects package.js to be in the root directory of the checkout, so copy there our package file under that name, temporarily |
| 24 | + cp $PACKAGE_FILE ./package.js |
| 25 | + |
| 26 | + # publish package, creating it if it's the first time we're publishing |
| 27 | + PACKAGE_NAME=$(grep -i name $PACKAGE_FILE | head -1 | cut -d "'" -f 2) |
| 28 | + ATMOSPHERE_NAME=${PACKAGE_NAME/://} |
| 29 | + |
| 30 | + echo "Publishing $PACKAGE_NAME..." |
| 31 | + |
| 32 | + # attempt to re-publish the package - the most common operation once the initial release has been made |
| 33 | + OUTPUT=$( meteor publish 2>&1 ) |
| 34 | + |
| 35 | + if (( $? > 0 )); then |
| 36 | + # there was an error |
| 37 | + |
| 38 | + if [[ $OUTPUT =~ "There is no package named" ]]; then |
| 39 | + # actually this is the first time the package is created, so pass the special --create flag and congratulate the maintainer |
| 40 | + echo "Thank you for creating the official Meteor package for this library!" |
| 41 | + if meteor publish --create; then |
| 42 | + echo "Please post the following to https://github.com/raix/Meteor-community-discussions/issues/14: |
| 43 | +
|
| 44 | +--------------------------------------------- 8< -------------------------------------------------------- |
| 45 | +
|
| 46 | +Happy to announce that I've published the official $PACKAGE_NAME to Atmosphere. Please star! |
| 47 | +https://atmospherejs.com/$ATMOSPHERE_NAME |
| 48 | +
|
| 49 | +--------------------------------------------- >8 -------------------------------------------------------- |
| 50 | +
|
| 51 | +" |
| 52 | + else |
| 53 | + echo "We got an error. Please post it at https://github.com/raix/Meteor-community-discussions/issues/14" |
| 54 | + cleanup |
| 55 | + exit 1 |
| 56 | + fi |
| 57 | + else |
| 58 | + # the error wasn't that the package didn't exist, so we need to ask for help |
| 59 | + echo "We got an error. Please post it at https://github.com/raix/Meteor-community-discussions/issues/14: |
| 60 | +--------------------------------------------- 8< -------------------------------------------------------- |
| 61 | +$OUTPUT |
| 62 | +--------------------------------------------- >8 -------------------------------------------------------- |
| 63 | +" |
| 64 | + cleanup |
| 65 | + exit 1 |
| 66 | + fi |
| 67 | + else |
| 68 | + # no error on the first `meteor publish` attempt |
| 69 | + echo "$OUTPUT" # just in case meteor said something interesting |
| 70 | + echo "Thanks for releasing a new version of $PACKAGE_NAME! You can see it at |
| 71 | +https://atmospherejs.com/$ATMOSPHERE_NAME" |
| 72 | + fi |
| 73 | + |
| 74 | + cleanup |
| 75 | + |
| 76 | +done |
0 commit comments