cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
bin/publish-npm
25lines · modecode
| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -eux |
| 4 | |
| 5 | npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN" |
| 6 | |
| 7 | # Build the project |
| 8 | yarn build |
| 9 | |
| 10 | # Navigate to the dist directory |
| 11 | cd dist |
| 12 | |
| 13 | # Get the version from package.json |
| 14 | VERSION="$(node -p "require('./package.json').version")" |
| 15 | |
| 16 | # Extract the pre-release tag if it exists |
| 17 | if [[ "$VERSION" =~ -([a-zA-Z]+) ]]; then |
| 18 | # Extract the part before any dot in the pre-release identifier |
| 19 | TAG="${BASH_REMATCH[1]}" |
| 20 | else |
| 21 | TAG="latest" |
| 22 | fi |
| 23 | |
| 24 | # Publish with the appropriate tag |
| 25 | yarn publish --access public --tag "$TAG" |
| 26 | |