|
| 1 | +# This workflow handles both automated and manual package publishing: |
| 2 | +# |
| 3 | +# AUTOMATED PUBLISHING (on push to main): |
| 4 | +# - Triggered automatically when changes are pushed to the main branch |
| 5 | +# - Uses release-please to create releases based on conventional commits |
| 6 | +# - Publishes packages to npm automatically when release PRs are merged |
| 7 | +# - All release-* jobs run in dependency order based on package dependencies |
| 8 | +# |
| 9 | +# MANUAL PUBLISHING (via workflow_dispatch): |
| 10 | +# - Can be triggered manually from the Actions tab |
| 11 | +# - Allows publishing a specific package to npm or jsr |
| 12 | +# - Supports prerelease and dry-run modes |
| 13 | +# - Runs the manual-publish job which builds, tests, and publishes the selected package |
| 14 | +# - Primarily used for pre-release jobs, or to correct publishing errors during the automated process |
| 15 | +# |
| 16 | +# The workflow uses conditional logic to ensure only the appropriate jobs run: |
| 17 | +# - release-please job: only runs on push events |
| 18 | +# - release-* jobs: only run on push events when their package has a new release |
| 19 | +# - manual-publish job: only runs on workflow_dispatch events |
1 | 20 | on: |
2 | 21 | push: |
3 | 22 | branches: |
4 | 23 | - main |
| 24 | + workflow_dispatch: |
| 25 | + inputs: |
| 26 | + package_registry: |
| 27 | + description: 'Publish to' |
| 28 | + required: true |
| 29 | + default: 'npm' |
| 30 | + type: choice |
| 31 | + options: |
| 32 | + - npm |
| 33 | + - jsr |
| 34 | + workspace_path: |
| 35 | + description: 'The workspace to publish' |
| 36 | + required: true |
| 37 | + default: 'packages/shared/common' |
| 38 | + type: choice |
| 39 | + options: |
| 40 | + - packages/shared/common |
| 41 | + - packages/shared/sdk-client |
| 42 | + - packages/shared/sdk-server |
| 43 | + - packages/shared/sdk-server-edge |
| 44 | + - packages/shared/akamai-edgeworker-sdk |
| 45 | + - packages/sdk/cloudflare |
| 46 | + - packages/sdk/fastly |
| 47 | + - packages/sdk/react-native |
| 48 | + - packages/sdk/server-node |
| 49 | + - packages/sdk/react-universal |
| 50 | + - packages/sdk/vercel |
| 51 | + - packages/sdk/akamai-base |
| 52 | + - packages/sdk/akamai-edgekv |
| 53 | + - packages/store/node-server-sdk-redis |
| 54 | + - packages/store/node-server-sdk-dynamodb |
| 55 | + - packages/telemetry/node-server-sdk-otel |
| 56 | + - packages/tooling/jest |
| 57 | + - packages/sdk/browser |
| 58 | + - packages/sdk/server-ai |
| 59 | + - packages/ai-providers/server-ai-openai |
| 60 | + - packages/ai-providers/server-ai-vercel |
| 61 | + - packages/ai-providers/server-ai-langchain |
| 62 | + - packages/telemetry/browser-telemetry |
| 63 | + - packages/sdk/combined-browser |
| 64 | + - packages/sdk/shopify-oxygen |
| 65 | + prerelease: |
| 66 | + description: 'Is this a prerelease. If so, then the latest tag will not be updated in npm.' |
| 67 | + type: boolean |
| 68 | + required: true |
| 69 | + dry_run: |
| 70 | + description: 'Is this a dry run. If so no package will be published.' |
| 71 | + type: boolean |
| 72 | + required: true |
5 | 73 | name: release-please |
6 | 74 |
|
7 | 75 | jobs: |
8 | 76 | release-please: |
9 | 77 | runs-on: ubuntu-latest |
| 78 | + if: github.event_name == 'push' |
10 | 79 | outputs: |
11 | 80 | package-common-released: ${{ steps.release.outputs['packages/shared/common--release_created'] }} |
12 | 81 | package-sdk-client-released: ${{ steps.release.outputs['packages/shared/sdk-client--release_created'] }} |
@@ -544,3 +613,56 @@ jobs: |
544 | 613 | with: |
545 | 614 | workspace_path: packages/sdk/shopify-oxygen |
546 | 615 | aws_assume_role: ${{ vars.AWS_ROLE_ARN }} |
| 616 | + |
| 617 | + manual-publish: |
| 618 | + runs-on: ubuntu-latest |
| 619 | + if: github.event_name == 'workflow_dispatch' |
| 620 | + permissions: |
| 621 | + id-token: write |
| 622 | + contents: read |
| 623 | + steps: |
| 624 | + - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 |
| 625 | + - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6 |
| 626 | + with: |
| 627 | + node-version: 24.x |
| 628 | + registry-url: 'https://registry.npmjs.org' |
| 629 | + - name: 'Setup Redis' |
| 630 | + if: ${{ inputs.workspace_path == 'packages/store/node-server-sdk-redis' }} |
| 631 | + run: | |
| 632 | + sudo apt-get update |
| 633 | + sudo apt-get install redis-server |
| 634 | + sudo service redis-server start |
| 635 | +
|
| 636 | + - name: 'Setup DynamoDB' |
| 637 | + if: ${{ inputs.workspace_path == 'packages/store/node-server-sdk-dynamodb' }} |
| 638 | + run: | |
| 639 | + sudo docker run -d -p 8000:8000 amazon/dynamodb-local |
| 640 | +
|
| 641 | + - name: 'Set WORKSPACE_NAME variable' |
| 642 | + run: | |
| 643 | + WORKSPACE_NAME=$(./scripts/package-name.sh ${{ inputs.workspace_path }}) |
| 644 | + echo "WORKSPACE_NAME=$WORKSPACE_NAME" >> $GITHUB_ENV |
| 645 | + - id: build-and-test |
| 646 | + name: Build and Test |
| 647 | + uses: ./actions/ci |
| 648 | + with: |
| 649 | + workspace_name: ${{ env.WORKSPACE_NAME }} |
| 650 | + workspace_path: ${{ inputs.workspace_path }} |
| 651 | + - id: publish-jsr |
| 652 | + name: Publish Package to jsr |
| 653 | + if: ${{ inputs.package_registry == 'jsr' }} |
| 654 | + uses: ./actions/publish-jsr |
| 655 | + with: |
| 656 | + workspace_name: ${{ env.WORKSPACE_NAME }} |
| 657 | + workspace_path: ${{ inputs.workspace_path }} |
| 658 | + dry_run: ${{ inputs.dry_run }} |
| 659 | + # Publishing credentials for NPM come from OIDC. |
| 660 | + - id: publish-npm |
| 661 | + name: Publish Package to npm |
| 662 | + if: ${{ inputs.package_registry == 'npm' }} |
| 663 | + uses: ./actions/publish |
| 664 | + with: |
| 665 | + workspace_name: ${{ env.WORKSPACE_NAME }} |
| 666 | + workspace_path: ${{ inputs.workspace_path }} |
| 667 | + prerelease: ${{ inputs.prerelease }} |
| 668 | + dry_run: ${{ inputs.dry_run }} |
0 commit comments