Skip to content

Conversation

@devin-ai-integration
Copy link

Multi-Version Publishing Script with Dist-Tags

This PR implements a comprehensive publishing script that solves the workspace naming conflict issue outlined in the TODO.md. The script allows publishing all version-specific packages under the unified "libpg-query" name using dist-tags.

🎯 Problem Solved

The repository has multiple packages:

  • @libpg-query/v13 (version 13.0.0)
  • @libpg-query/v14 (version 14.0.0)
  • @libpg-query/v15 (version 15.0.0)
  • @libpg-query/v16 (version 16.0.0)
  • @libpg-query/v17 (version 17.0.0)

These need unique names in the workspace but should all be published as libpg-query with different dist-tags for easy installation.

🚀 Solution

Created scripts/publish-versions.js that:

  1. Handles Workspace Naming Conflicts: Temporarily modifies package.json files during publishing, then restores them
  2. Uses Dist-Tags: Publishes with tags pg13, pg14, pg15, pg16, pg17
  3. Maintains Version Consistency: Each package keeps its major version (13.0.0, 14.0.0, etc.)
  4. Safety Features: Includes dry-run mode, backup/restore, and error handling
  5. Selective Publishing: Can publish all versions or specific ones

📋 Features

Core Functionality

  • Dynamic Package Discovery: Automatically finds all version packages using the same pattern as analyze-sizes.js
  • Temporary Package.json Modification: Changes name to "libpg-query" only during publishing
  • Automatic Backup/Restore: Ensures original package.json files are never permanently modified
  • Build Integration: Runs pnpm build before publishing each package
  • Dist-Tag Publishing: Uses pnpm publish --tag pgXX for each version

Safety & Testing

  • Dry-Run Mode: Test the entire workflow without actual publishing
  • Error Handling: Graceful failure handling with cleanup
  • Progress Reporting: Clear console output showing what's happening
  • Publishing Summary: Final report of successes and failures

CLI Interface

# Test all versions
pnpm publish:dry-run

# Publish all versions
pnpm publish:versions

# Publish specific versions
pnpm publish:specific 16,17

# Direct script usage
node scripts/publish-versions.js --dry-run --versions "17"

🧪 Testing Results

Dry-run testing shows the script correctly identifies and processes all packages:

🚀 libpg-query Multi-Version Publisher
=====================================
🔍 DRY RUN MODE - No actual publishing will occur

Found 5 packages to publish:
  - @libpg-query/v13 (v13) -> libpg-query@pg13
  - @libpg-query/v14 (v14) -> libpg-query@pg14
  - @libpg-query/v15 (v15) -> libpg-query@pg15
  - @libpg-query/v16 (v16) -> libpg-query@pg16
  - @libpg-query/v17 (v17) -> libpg-query@pg17

📦 Installation After Publishing

Once published, users can install specific PostgreSQL versions:

npm install libpg-query@pg17  # PostgreSQL 17 parser
npm install libpg-query@pg16  # PostgreSQL 16 parser
npm install libpg-query@pg15  # PostgreSQL 15 parser
npm install libpg-query@pg14  # PostgreSQL 14 parser
npm install libpg-query@pg13  # PostgreSQL 13 parser

🔧 Changes Made

  1. Created scripts/publish-versions.js - Main publishing script with full functionality
  2. Updated package.json - Added convenient npm scripts:
    • publish:dry-run - Test publishing workflow
    • publish:versions - Publish all versions
    • publish:specific - Publish specific versions
  3. Updated TODO.md - Marked "publish setup with name proxy" as completed

🏗️ Implementation Details

The script follows the exact approach outlined in the TODO.md:

  • Dynamically generates appropriate package.json during publishing
  • Uses pnpm publish --tag <dist-tag> for each version
  • Maintains workspace compatibility by restoring original names

The implementation reuses proven patterns from the existing analyze-sizes.js script for package discovery and follows the same code style and structure.

✅ Verification

  • Dry-run testing passes for all versions
  • Dry-run testing passes for specific versions
  • Help documentation is clear and comprehensive
  • Error handling and cleanup work correctly
  • Package.json backup/restore functionality verified
  • All changes committed and pushed to feature branch

Link to Devin run: https://app.devin.ai/sessions/01f8ae7005974e279e7da7345d75ec7f

Requested by: Dan Lynch ([email protected])

- Creates publish-versions.js script to handle workspace naming conflicts
- Publishes all versions under 'libpg-query' name with dist-tags pg13, pg14, pg15, pg16, pg17
- Includes dry-run mode for testing
- Handles backup/restore of package.json files
- Follows existing patterns from analyze-sizes.js
- Adds convenient npm scripts for publishing

Co-Authored-By: Dan Lynch <[email protected]>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration bot and others added 5 commits June 22, 2025 09:15
- Add --set-version option to specify custom versions when publishing
- Add --skip-build option to skip build step for pre-built packages
- Enhance help documentation with detailed examples and workflow explanation
- Create comprehensive PUBLISHING.md guide with step-by-step examples
- Update package.json scripts for better usability
- Add version management capabilities as requested by user
- Include practical examples for publishing individual versions

Co-Authored-By: Dan Lynch <[email protected]>
- Add --disable-thread-safety flag to fix PostgreSQL configure in Emscripten
- Add publishMainPackage function to support @pgsql/parser publishing
- Add CLI options --main and --publish-as for main package publishing
- Add npm scripts for convenient main package publishing
- Update documentation with dual publishing strategy examples
- Support independent versioning for main package vs version packages

Co-Authored-By: Dan Lynch <[email protected]>
The --disable-thread-safety flag was causing 'unknown type name slock_t'
compilation errors throughout PostgreSQL codebase. The original
--disable-spinlocks flag alone is sufficient for Emscripten builds.

Co-Authored-By: Dan Lynch <[email protected]>
This reverts the patch to the exact state that was working before,
removing the problematic --disable-thread-safety flag that was
causing 'unknown type name slock_t' compilation errors.

Co-Authored-By: Dan Lynch <[email protected]>
@pyramation pyramation closed this Jun 22, 2025
@pyramation pyramation deleted the devin/1750583173-publishing-script branch June 22, 2025 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants