cloudflare/kumo
Publicmirrored from https://github.com/cloudflare/kumoAvailable
ci/versioning/publish-beta.sh
64lines · modecode
| 1 | #!/bin/bash |
| 2 | set -euo pipefail |
| 3 | |
| 4 | # Beta release script for CI |
| 5 | # Versions, builds, publishes, and outputs report artifact |
| 6 | |
| 7 | echo "Starting beta release process..." |
| 8 | |
| 9 | # Configure npm registry authentication |
| 10 | cat > ~/.npmrc << EOF |
| 11 | @cloudflare:registry=https://registry.npmjs.org |
| 12 | //registry.npmjs.org/:_authToken=${NPM_TOKEN} |
| 13 | EOF |
| 14 | |
| 15 | # Configure git for commits |
| 16 | git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 17 | git config --global user.name "GitHub Actions" |
| 18 | |
| 19 | # Run the versioning step first |
| 20 | echo "Versioning packages..." |
| 21 | pnpm run version:beta |
| 22 | |
| 23 | # Build the package before publishing |
| 24 | echo "Building package..." |
| 25 | cd packages/kumo && pnpm run build && cd ../.. |
| 26 | |
| 27 | # Run the publish step after versioning and building |
| 28 | echo "Publishing to npm..." |
| 29 | pnpm run release:beta |
| 30 | |
| 31 | # Get the published version |
| 32 | NEW_VERSION=$(node -p "require('./packages/kumo/package.json').version") |
| 33 | PACKAGE_NAME="${PACKAGE_NAME:-@cloudflare/kumo}" |
| 34 | |
| 35 | echo "Published version: $NEW_VERSION" |
| 36 | |
| 37 | # Verify the version was published successfully |
| 38 | echo "Verifying publication..." |
| 39 | sleep 45 |
| 40 | |
| 41 | AVAILABLE_VERSIONS=$(pnpm view ${PACKAGE_NAME} versions --json 2>/dev/null || echo '[]') |
| 42 | echo "Checking for version: $NEW_VERSION" |
| 43 | |
| 44 | if echo "$AVAILABLE_VERSIONS" | grep -F "\"$NEW_VERSION\"" > /dev/null; then |
| 45 | echo "Version $NEW_VERSION successfully published and verified in npm registry" |
| 46 | elif pnpm view ${PACKAGE_NAME}@${NEW_VERSION} version > /dev/null 2>&1; then |
| 47 | echo "Version $NEW_VERSION successfully published and verified via direct lookup" |
| 48 | else |
| 49 | echo "Version $NEW_VERSION not found in npm registry after publishing" |
| 50 | echo "Searched for: $NEW_VERSION" |
| 51 | echo "Last 10 available versions:" |
| 52 | echo "$AVAILABLE_VERSIONS" | grep -o '"[^"]*"' | tail -10 |
| 53 | echo "" |
| 54 | echo "Note: The version might exist but verification failed due to registry propagation delay" |
| 55 | echo "Manual verification: pnpm view ${PACKAGE_NAME}@${NEW_VERSION}" |
| 56 | exit 1 |
| 57 | fi |
| 58 | |
| 59 | # Output report artifact for the PR reporter job |
| 60 | echo "Writing report artifact..." |
| 61 | export PACKAGE_VERSION="$NEW_VERSION" |
| 62 | pnpm tsx ci/scripts/write-npm-report.ts |
| 63 | |
| 64 | echo "Beta release complete!" |
| 65 | |