1+ name : Auto Version and Publish
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ workflow_dispatch :
8+ inputs :
9+ version_type :
10+ description : ' Version bump type'
11+ required : true
12+ default : ' patch'
13+ type : choice
14+ options :
15+ - patch
16+ - minor
17+ - major
18+ - prerelease
19+ prerelease_tag :
20+ description : ' Prerelease tag (beta, rc)'
21+ required : false
22+ default : ' beta'
23+ force_cli_publish :
24+ description : ' Force publish CLI even without changes'
25+ required : false
26+ default : false
27+ type : boolean
28+
29+ jobs :
30+ # Detect changes
31+ changes :
32+ runs-on : ubuntu-latest
33+ outputs :
34+ cli : ${{ steps.filter.outputs.cli }}
35+ sdk : ${{ steps.filter.outputs.sdk }}
36+ steps :
37+ - uses : actions/checkout@v4
38+ with :
39+ fetch-depth : 0
40+
41+ - uses : dorny/paths-filter@v3
42+ id : filter
43+ with :
44+ filters : |
45+ cli:
46+ - 'packages/cli/src/**'
47+ - 'packages/cli/package.json'
48+ - 'packages/cli/tsconfig.json'
49+ sdk:
50+ - 'src/**'
51+ - 'package.json'
52+ - 'tsconfig.json'
53+
54+ # Build all packages
55+ build :
56+ runs-on : ubuntu-latest
57+ needs : changes
58+ steps :
59+ - uses : actions/checkout@v4
60+
61+ - name : Setup Node.js
62+ uses : actions/setup-node@v4
63+ with :
64+ node-version : ' 20'
65+ cache : ' npm'
66+
67+ - name : Install dependencies
68+ run : npm ci
69+
70+ - name : Run linting
71+ run : npm run lint
72+
73+ - name : Build packages
74+ run : |
75+ npm run clean
76+ npm run build
77+
78+ # TODO: Add tests
79+ # - name: Run tests
80+ # run: npm test
81+
82+ - name : Upload SDK artifacts
83+ uses : actions/upload-artifact@v4
84+ with :
85+ name : sdk-dist
86+ path : dist/
87+
88+ - name : Upload CLI artifacts
89+ uses : actions/upload-artifact@v4
90+ with :
91+ name : cli-dist
92+ path : packages/cli/dist/
93+
94+ # Version and publish SDK
95+ publish-sdk :
96+ needs : [changes, build]
97+ if : needs.changes.outputs.sdk == 'true'
98+ uses : ./.github/workflows/version-and-publish-package.yml
99+ with :
100+ package_name : sdk
101+ package_path : .
102+ artifact_name : sdk-dist
103+ npm_package_name : ' @uipath/uipath-typescript'
104+ version_type : ${{ github.event_name == 'workflow_dispatch' && inputs.version_type || 'auto' }}
105+ prerelease_tag : ${{ inputs.prerelease_tag || 'beta' }}
106+ permissions :
107+ contents : write
108+ packages : write
109+
110+ # Version and publish CLI
111+ publish-cli :
112+ needs : [changes, build]
113+ if : needs.changes.outputs.cli == 'true' || inputs.force_cli_publish
114+ uses : ./.github/workflows/version-and-publish-package.yml
115+ with :
116+ package_name : cli
117+ package_path : packages/cli
118+ artifact_name : cli-dist
119+ npm_package_name : ' @uipath/cli'
120+ version_type : ${{ github.event_name == 'workflow_dispatch' && inputs.version_type || 'auto' }}
121+ prerelease_tag : ${{ inputs.prerelease_tag || 'beta' }}
122+ permissions :
123+ contents : write
124+ packages : write
125+
126+ # Push all changes
127+ push-changes :
128+ runs-on : ubuntu-latest
129+ needs : [publish-sdk, publish-cli]
130+ if : always() && (needs.publish-sdk.outputs.published == 'true' || needs.publish-cli.outputs.published == 'true')
131+ permissions :
132+ contents : write
133+ steps :
134+ - uses : actions/checkout@v4
135+ with :
136+ token : ${{ secrets.GITHUB_TOKEN }}
137+ fetch-depth : 0
138+ ref : main
139+
140+ - name : Configure Git
141+ run : |
142+ git config --global user.name "github-actions[bot]"
143+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
144+
145+ - name : Pull and push changes
146+ run : |
147+ git pull origin main --rebase
148+ git push origin main --follow-tags
149+
150+ # Summary
151+ summary :
152+ runs-on : ubuntu-latest
153+ needs : [changes, build, publish-sdk, publish-cli]
154+ if : always()
155+ steps :
156+ - name : Generate Summary
157+ run : |
158+ echo "## Build and Publish Summary" >> $GITHUB_STEP_SUMMARY
159+ echo "" >> $GITHUB_STEP_SUMMARY
160+
161+ echo "### Changes Detected" >> $GITHUB_STEP_SUMMARY
162+ echo "- SDK: ${{ needs.changes.outputs.sdk == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
163+ echo "- CLI: ${{ needs.changes.outputs.cli == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
164+ echo "" >> $GITHUB_STEP_SUMMARY
165+
166+ echo "### Build Status" >> $GITHUB_STEP_SUMMARY
167+ echo "- Build: ${{ needs.build.result == 'success' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
168+ echo "" >> $GITHUB_STEP_SUMMARY
169+
170+ echo "### Publishing" >> $GITHUB_STEP_SUMMARY
171+ if [ "${{ needs.publish-sdk.outputs.published }}" == "true" ]; then
172+ echo "- SDK: ✅ Published ${{ needs.publish-sdk.outputs.version }}" >> $GITHUB_STEP_SUMMARY
173+ elif [ "${{ needs.changes.outputs.sdk }}" == "true" ]; then
174+ echo "- SDK: ❌ Failed to publish" >> $GITHUB_STEP_SUMMARY
175+ else
176+ echo "- SDK: ⏭️ No changes" >> $GITHUB_STEP_SUMMARY
177+ fi
178+
179+ if [ "${{ needs.publish-cli.outputs.published }}" == "true" ]; then
180+ echo "- CLI: ✅ Published ${{ needs.publish-cli.outputs.version }}" >> $GITHUB_STEP_SUMMARY
181+ elif [ "${{ needs.changes.outputs.cli }}" == "true" ] || [ "${{ inputs.force_cli_publish }}" == "true" ]; then
182+ echo "- CLI: ❌ Failed to publish" >> $GITHUB_STEP_SUMMARY
183+ else
184+ echo "- CLI: ⏭️ No changes" >> $GITHUB_STEP_SUMMARY
185+ fi
0 commit comments