publish.sh 763 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. PACKAGE_JSON_NAME="$(tar xfO "$TARBALL" package/package.json | jq -r .name)"
  4. PACKAGE_JSON_VERSION="$(tar xfO "$TARBALL" package/package.json | jq -r .version)"
  5. # Intentionally escape $ to avoid interpolation and writing the token to disk
  6. echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
  7. # Actual publish
  8. npm publish "$TARBALL" --tag "$TAG"
  9. # Clean up tags
  10. delete_tag() {
  11. npm dist-tag rm "$PACKAGE_JSON_NAME" "$1"
  12. }
  13. if [ "$TAG" = tmp ]; then
  14. delete_tag "$TAG"
  15. elif [ "$TAG" = latest ]; then
  16. # Delete the next tag if it exists and is a prerelease for what is currently being published
  17. if npm dist-tag ls "$PACKAGE_JSON_NAME" | grep -q "next: $PACKAGE_JSON_VERSION"; then
  18. delete_tag next
  19. fi
  20. fi