@@ -2,7 +2,12 @@ name: Release
22
33on :
44 # Support manually pushing a new release
5- workflow_dispatch : {}
5+ workflow_dispatch :
6+ inputs :
7+ dry_run :
8+ description : ' Test workflow without publishing (dry run)'
9+ type : ' boolean'
10+ default : false
611 # Trigger when a release is published
712 release :
813 types : [published]
@@ -30,16 +35,71 @@ jobs:
3035 run : |
3136 npm run build
3237
33- - name : Push Release
38+ - name : Backup package.json
39+ run : |
40+ cp package.json package.json.original
41+
42+ # Publish to @workos-inc org (original package)
43+ - name : Push Release to @workos-inc
3444 if : ${{ !github.event.release.prerelease }}
3545 env :
3646 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
3747 run : |
38- npm publish --tag latest --access=public
48+ if [[ "${{ github.event.inputs.dry_run }}" == "true" ]]; then
49+ echo "DRY RUN: Would publish to @workos-inc org with tag latest"
50+ npm publish --dry-run --tag latest --access=public
51+ else
52+ npm publish --tag latest --access=public
53+ fi
3954
40- - name : Push Pre-Release
55+ - name : Push Pre-Release to @workos-inc
4156 if : ${{ github.event.release.prerelease }}
4257 env :
4358 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
4459 run : |
45- npm publish --tag next --access=public
60+ if [[ "${{ github.event.inputs.dry_run }}" == "true" ]]; then
61+ echo "DRY RUN: Would publish to @workos-inc org with tag next"
62+ npm publish --dry-run --tag next --access=public
63+ else
64+ npm publish --tag next --access=public
65+ fi
66+
67+ # Publish to @workos org with modified package name
68+ - name : Update package.json for @workos org
69+ run : |
70+ # Extract the package name without scope
71+ PACKAGE_NAME=$(jq -r '.name | split("/")[1]' package.json)
72+ # Update to @workos org
73+ jq --arg name "@workos/$PACKAGE_NAME" '.name = $name' package.json > temp.json && mv temp.json package.json
74+
75+ # Show the transformation for verification
76+ echo "Original package name: $(jq -r '.name' package.json.original)"
77+ echo "Updated package name: $(jq -r '.name' package.json)"
78+
79+ - name : Push Release to @workos
80+ if : ${{ !github.event.release.prerelease }}
81+ env :
82+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
83+ run : |
84+ if [[ "${{ github.event.inputs.dry_run }}" == "true" ]]; then
85+ echo "DRY RUN: Would publish to @workos org with tag latest"
86+ npm publish --dry-run --tag latest --access=public
87+ else
88+ npm publish --tag latest --access=public
89+ fi
90+
91+ - name : Push Pre-Release to @workos
92+ if : ${{ github.event.release.prerelease }}
93+ env :
94+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
95+ run : |
96+ if [[ "${{ github.event.inputs.dry_run }}" == "true" ]]; then
97+ echo "DRY RUN: Would publish to @workos org with tag next"
98+ npm publish --dry-run --tag next --access=public
99+ else
100+ npm publish --tag next --access=public
101+ fi
102+
103+ - name : Restore original package.json
104+ run : |
105+ mv package.json.original package.json
0 commit comments