1- name : Auto Version and Publish
1+ name : Auto Version and Publish SDK
22
33on :
44 push :
55 branches :
6- - main
7- # - rm/workflow # for testing , will remove before merge
6+ - rm/workflow # for testing , will remove before merge
87 workflow_dispatch :
9- inputs :
10- version_type :
11- description : ' Version bump type'
12- required : true
13- default : ' patch'
14- type : choice
15- options :
16- - patch
17- - minor
18- - major
19- - prerelease
20- prerelease_tag :
21- description : ' Prerelease tag (beta, rc)'
22- required : false
23- default : ' beta'
24- force_cli_publish :
25- description : ' Force publish CLI even without changes'
26- required : false
27- default : false
28- type : boolean
298
309permissions :
31- contents : read
10+ contents : write
11+ packages : write
12+ id-token : write
3213
3314jobs :
34- # Detect changes
35- changes :
15+ publish-sdk :
3616 runs-on : ubuntu-latest
37- permissions :
38- contents : read
39- outputs :
40- cli : ${{ steps.filter.outputs.cli }}
41- sdk : ${{ steps.filter.outputs.sdk }}
4217 steps :
43- - uses : actions/checkout@v4
18+ - name : Checkout
19+ uses : actions/checkout@v4
4420 with :
4521 fetch-depth : 0
46-
47- - uses : dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v3.0.1
48- id : filter
49- with :
50- filters : |
51- cli:
52- - 'packages/cli/src/**'
53- - 'packages/cli/package.json'
54- - 'packages/cli/tsconfig.json'
55- sdk:
56- - 'src/**'
57- - 'package.json'
58- - 'tsconfig.json'
59-
60- # Build all packages
61- build :
62- needs : changes
63- uses : ./.github/workflows/build.yml
64- with :
65- upload_artifacts : true
66- permissions :
67- contents : read
68-
69- # Version and publish SDK
70- publish-sdk :
71- needs : [changes, build]
72- if : needs.changes.outputs.sdk == 'true'
73- uses : ./.github/workflows/version-and-publish-package.yml
74- with :
75- package_name : sdk
76- package_path : .
77- artifact_name : sdk-dist
78- npm_package_name : ' @uipath/uipath-typescript'
79- version_type : ${{ github.event_name == 'workflow_dispatch' && inputs.version_type || 'auto' }}
80- permissions :
81- contents : write
82- packages : write
83-
84- # Version and publish CLI
85- publish-cli :
86- needs : [changes, build]
87- if : needs.changes.outputs.cli == 'true' || inputs.force_cli_publish
88- uses : ./.github/workflows/version-and-publish-package.yml
89- with :
90- package_name : cli
91- package_path : packages/cli
92- artifact_name : cli-dist
93- npm_package_name : ' @uipath/cli'
94- version_type : ${{ github.event_name == 'workflow_dispatch' && inputs.version_type || 'auto' }}
95- prerelease_tag : ${{ inputs.prerelease_tag || 'beta' }}
96- permissions :
97- contents : write
98- packages : write
9922
100- # Push all changes
101- push-changes :
102- runs-on : ubuntu-latest
103- needs : [publish-sdk, publish-cli]
104- if : always() && (needs.publish-sdk.outputs.published == 'true' || needs.publish-cli.outputs.published == 'true')
105- permissions :
106- contents : write
107- steps :
108- - uses : actions/checkout@v4
23+ - name : Setup Node.js
24+ uses : actions/setup-node@v4
10925 with :
110- token : ${{ secrets.GITHUB_TOKEN }}
111- fetch-depth : 0
112- ref : main
113-
26+ node-version : ' 18'
27+ registry-url : ' https://registry.npmjs.org'
28+
11429 - name : Configure Git
11530 run : |
11631 git config --global user.name "github-actions[bot]"
11732 git config --global user.email "github-actions[bot]@users.noreply.github.com"
118-
119- - name : Pull and push changes
120- run : |
121- git pull origin main --rebase
122- git push origin main --follow-tags
12333
124- # Summary
125- summary :
126- runs-on : ubuntu-latest
127- permissions : {}
128- needs : [changes, build, publish-sdk, publish-cli]
129- if : always()
130- steps :
131- - name : Generate Summary
34+ - name : Install Dependencies
35+ run : npm install
36+
37+ - name : Update Telemetry Constants
13238 run : |
133- echo "## Build and Publish Summary" >> $GITHUB_STEP_SUMMARY
134- echo "" >> $GITHUB_STEP_SUMMARY
39+ # Get current version from package.json for SDK_VERSION
40+ CURRENT_VERSION=$(node -p "require('./package.json').version")
13541
136- echo "### Changes Detected" >> $GITHUB_STEP_SUMMARY
137- echo "- SDK: ${{ needs.changes.outputs.sdk == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
138- echo "- CLI: ${{ needs.changes.outputs.cli == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
139- echo "" >> $GITHUB_STEP_SUMMARY
42+ # Replace placeholders in telemetry constants
43+ sed -i 's/\$CONNECTION_STRING/${{ secrets.CONNECTION_STRING }}/g' packages/cli/src/telemetry/constants.ts
44+ sed -i "s/\$SDK_VERSION/$CURRENT_VERSION/g" packages/cli/src/telemetry/constants.ts
14045
141- echo "### Build Status" >> $GITHUB_STEP_SUMMARY
142- echo "- Build: ${{ needs.build.result == 'success' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
143- echo "" >> $GITHUB_STEP_SUMMARY
46+ echo "Updated telemetry constants with:"
47+ echo "- CONNECTION_STRING: [REDACTED]"
48+ echo "- SDK_VERSION: $CURRENT_VERSION"
14449
145- echo "### Publishing" >> $GITHUB_STEP_SUMMARY
146- if [ "${{ needs.publish-sdk.outputs.published }}" == "true" ]; then
147- echo "- SDK: ✅ Published ${{ needs.publish-sdk.outputs.version }}" >> $GITHUB_STEP_SUMMARY
148- elif [ "${{ needs.changes.outputs.sdk }}" == "true" ]; then
149- echo "- SDK: ❌ Failed to publish" >> $GITHUB_STEP_SUMMARY
50+ echo ""
51+ echo "=== Constants file content after replacement ==="
52+ cat packages/cli/src/telemetry/constants.ts
53+
54+
55+ - name : Build
56+ run : npm run build
57+
58+ - name : Auto-increment Beta Version
59+ run : |
60+ # Get current version from package.json
61+ CURRENT_VERSION=$(node -p "require('./package.json').version")
62+ echo "Current version: $CURRENT_VERSION"
63+
64+ # Extract beta number and increment it
65+ if [[ $CURRENT_VERSION =~ ([0-9]+\.[0-9]+\.[0-9]+)-beta\.([0-9]+) ]]; then
66+ BASE_VERSION="${BASH_REMATCH[1]}"
67+ BETA_NUM="${BASH_REMATCH[2]}"
68+ NEW_BETA_NUM=$((BETA_NUM + 1))
69+ NEW_VERSION="${BASE_VERSION}-beta.${NEW_BETA_NUM}"
15070 else
151- echo "- SDK: ⏭️ No changes" >> $GITHUB_STEP_SUMMARY
71+ # If not a beta version, start with beta.1
72+ NEW_VERSION="${CURRENT_VERSION}-beta.1"
15273 fi
15374
154- if [ "${{ needs.publish-cli.outputs.published }}" == "true" ]; then
155- echo "- CLI: ✅ Published ${{ needs.publish-cli.outputs.version }}" >> $GITHUB_STEP_SUMMARY
156- elif [ "${{ needs.changes.outputs.cli }}" == "true" ] || [ "${{ inputs.force_cli_publish }}" == "true" ]; then
157- echo "- CLI: ❌ Failed to publish" >> $GITHUB_STEP_SUMMARY
158- else
159- echo "- CLI: ⏭️ No changes" >> $GITHUB_STEP_SUMMARY
160- fi
75+ echo "New version: $NEW_VERSION"
76+ echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
77+
78+ # Update package.json version
79+ npm version $NEW_VERSION --no-git-tag-version
80+
81+ - name : Pack
82+ run : npm pack
83+
84+ - name : Publish to npm
85+ run : npm publish --access public
86+ env :
87+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
88+
89+ - name : Setup Node.js for GitHub Packages
90+ uses : actions/setup-node@v4
91+ with :
92+ node-version : ' 18'
93+ registry-url : ' https://npm.pkg.github.com'
94+
95+ - name : Publish to GitHub Packages
96+ run : npm publish --access public
97+ env :
98+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
99+
100+ - name : Create Git Tag and Commit
101+ run : |
102+ git add package.json package-lock.json
103+ git commit -m "chore: bump version to $NEW_VERSION"
104+ git tag -a "v$NEW_VERSION" -m "Release version $NEW_VERSION"
105+ git push origin main --follow-tags
106+
107+ - name : Generate Summary
108+ run : |
109+ echo "## SDK Published Successfully" >> $GITHUB_STEP_SUMMARY
110+ echo "" >> $GITHUB_STEP_SUMMARY
111+ echo "### Version: $NEW_VERSION" >> $GITHUB_STEP_SUMMARY
112+ echo "Published to npm registry" >> $GITHUB_STEP_SUMMARY
113+ echo "Published to GitHub Packages" >> $GITHUB_STEP_SUMMARY
114+ echo "Git tag created and pushed" >> $GITHUB_STEP_SUMMARY
0 commit comments