Manual Publish #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Manual Publish | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish (e.g., 1.0.0)' | |
| required: true | |
| publish_main: | |
| description: 'Publish main package (git-rewrite-commits)' | |
| type: boolean | |
| default: true | |
| publish_grec: | |
| description: 'Publish grec alias package' | |
| type: boolean | |
| default: true | |
| dry_run: | |
| description: 'Dry run (skip actual publish)' | |
| type: boolean | |
| default: false | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Dry Run - Show what would be published | |
| if: ${{ github.event.inputs.dry_run == 'true' }} | |
| run: | | |
| echo "🔍 DRY RUN MODE - No packages will be published" | |
| echo "" | |
| if [ "${{ github.event.inputs.publish_main }}" = "true" ]; then | |
| echo "📦 Main package (git-rewrite-commits):" | |
| npm pack --dry-run | |
| fi | |
| echo "" | |
| if [ "${{ github.event.inputs.publish_grec }}" = "true" ] && [ -d "packages/grec" ]; then | |
| echo "📦 Alias package (grec):" | |
| cd packages/grec | |
| npm pack --dry-run | |
| fi | |
| - name: Publish main package | |
| if: ${{ github.event.inputs.dry_run == 'false' && github.event.inputs.publish_main == 'true' }} | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Wait for main package availability | |
| if: ${{ github.event.inputs.dry_run == 'false' && github.event.inputs.publish_main == 'true' && github.event.inputs.publish_grec == 'true' }} | |
| run: | | |
| echo "Waiting for git-rewrite-commits@${{ github.event.inputs.version }} to be available..." | |
| for i in {1..30}; do | |
| if npm view git-rewrite-commits@${{ github.event.inputs.version }} version 2>/dev/null; then | |
| echo "✅ Package is now available!" | |
| break | |
| fi | |
| echo "⏳ Waiting... (attempt $i/30)" | |
| sleep 10 | |
| done | |
| - name: Publish grec alias package | |
| if: ${{ github.event.inputs.dry_run == 'false' && github.event.inputs.publish_grec == 'true' }} | |
| run: | | |
| if [ -d "packages/grec" ]; then | |
| cd packages/grec | |
| npm publish --access public | |
| echo "✅ Published grec package!" | |
| else | |
| echo "⚠️ grec package directory not found, skipping" | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Summary | |
| run: | | |
| echo "📊 Publishing Summary" | |
| echo "====================" | |
| echo "Version: ${{ github.event.inputs.version }}" | |
| echo "Dry Run: ${{ github.event.inputs.dry_run }}" | |
| echo "" | |
| if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then | |
| echo "🔍 DRY RUN - Nothing was published" | |
| else | |
| if [ "${{ github.event.inputs.publish_main }}" = "true" ]; then | |
| echo "✅ git-rewrite-commits@${{ github.event.inputs.version }} published" | |
| fi | |
| if [ "${{ github.event.inputs.publish_grec }}" = "true" ]; then | |
| echo "✅ grec@${{ github.event.inputs.version }} published" | |
| fi | |
| fi |