This repository has been archived by the owner on Feb 21, 2024. It is now read-only.
forked from speakeasy-api/sdk-generation-action
-
Notifications
You must be signed in to change notification settings - Fork 0
510 lines (509 loc) · 21.8 KB
/
workflow-executor.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
name: Speakeasy SDK Generation Workflow
on:
workflow_call:
inputs:
speakeasy_version:
description: The version of the Speakeasy CLI to use or "latest"
default: latest
required: false
type: string
use_sonatype_central:
description: "When publishing the Java SDK, use the Sonatype central portal"
default: "false"
required: false
type: string
mode:
description: |-
The mode to run the workflow in, valid options are 'direct' or 'pr', defaults to 'direct'.
- 'direct' will create a commit with the changes to the SDKs and push them directly to the branch the workflow is configure to run on (normally 'main' or 'master').
If publishing and creating a release are configured this will happen immediately after the commit is created on the branch.
- 'pr' will instead create a new branch to commit the changes to the SDKs to and then create a PR from this branch.
The sdk-publish workflow will then need to be configured to run when the PR is merged to publish the SDKs and create a release.
See documentation for more details.
default: "direct"
required: false
type: string
force:
description: "Force the generation of the SDKs"
default: "false"
required: false
type: string
speakeasy_server_url:
required: false
description: "Internal use only"
type: string
working_directory:
description: "The working directory for running Speakeasy CLI commands in the action"
required: false
type: string
secrets:
github_access_token:
description: A GitHub access token with write access to the repo
required: true
pypi_token:
description: A PyPi access token for publishing the package to PyPi, include the `pypi-` prefix
required: false
npm_token:
description: An NPM access token for publishing the package to NPM, include the `npm_` prefix
required: false
packagist_username:
description: A Packagist username for publishing the package to Packagist
required: false
packagist_token:
description: A Packagist API token for publishing the package to Packagist
required: false
openapi_doc_auth_token:
description: The auth token to use when fetching the OpenAPI document if it is not publicly hosted. For example `Bearer <token>` or `<token>`.
required: false
speakeasy_api_key:
description: The API key to use to authenticate the Speakeasy CLI
required: true
ossrh_username:
description: A username for publishing the Java package to the OSSRH URL provided in gen.yml
required: false
ossrh_password:
description: The corresponding password for publishing the Java package to the OSSRH URL provided in gen.yml
required: false
java_gpg_secret_key:
description: The GPG secret key to use for signing the Java package
required: false
java_gpg_passphrase:
description: The passphrase for the GPG secret key
required: false
slack_webhook_url:
description: A Slack webhook URL that pipeline failures will be posted to
required: false
terraform_gpg_secret_key:
description: The GPG secret key to use for signing the Terraform provider
required: false
terraform_gpg_passphrase:
description: The passphrase for the Terraform GPG secret key
required: false
rubygems_auth_token:
description: The auth token (api key) for publishing to RubyGems
required: false
nuget_api_key:
description: The api key for publishing to the Nuget registry
required: false
jobs:
run-workflow:
name: Generate Target
runs-on: ubuntu-latest
outputs:
publish_python: ${{ steps.run-workflow.outputs.publish_python }}
publish_typescript: ${{ steps.run-workflow.outputs.publish_typescript }}
publish_terraform: ${{ steps.run-workflow.outputs.publish_terraform }}
publish_java: ${{ steps.run-workflow.outputs.publish_java }}
publish_php: ${{ steps.run-workflow.outputs.publish_php }}
publish_ruby: ${{ steps.run-workflow.outputs.publish_ruby }}
publish_csharp: ${{ steps.run-workflow.outputs.publish_csharp }}
python_regenerated: ${{ steps.run-workflow.outputs.python_regenerated }}
python_directory: ${{ steps.run-workflow.outputs.python_directory }}
typescript_regenerated: ${{ steps.run-workflow.outputs.typescript_regenerated }}
typescript_directory: ${{ steps.run-workflow.outputs.typescript_directory }}
go_regenerated: ${{ steps.run-workflow.outputs.go_regenerated }}
go_directory: ${{ steps.run-workflow.outputs.go_directory }}
terraform_regenerated: ${{ steps.run-workflow.outputs.terraform_regenerated }}
terraform_directory: ${{ steps.run-workflow.outputs.terraform_directory }}
java_regenerated: ${{ steps.run-workflow.outputs.java_regenerated }}
java_directory: ${{ steps.run-workflow.outputs.java_directory }}
php_regenerated: ${{ steps.run-workflow.outputs.php_regenerated }}
php_directory: ${{ steps.run-workflow.outputs.php_directory }}
ruby_regenerated: ${{ steps.run-workflow.outputs.ruby_regenerated }}
ruby_directory: ${{ steps.run-workflow.outputs.ruby_directory }}
csharp_regenerated: ${{ steps.run-workflow.outputs.csharp_regenerated }}
csharp_directory: ${{ steps.run-workflow.outputs.csharp_directory }}
swift_regenerated: ${{ steps.run-workflow.outputs.swift_regenerated }}
swift_directory: ${{ steps.run-workflow.outputs.swift_directory }}
unity_regenerated: ${{ steps.run-workflow.outputs.unity_regenerated }}
unity_directory: ${{ steps.run-workflow.outputs.unity_directory }}
docs_regenerated: ${{ steps.run-workflow.outputs.docs_regenerated }}
docs_directory: ${{ steps.run-workflow.outputs.docs_directory }}
branch_name: ${{ steps.run-workflow.outputs.branch_name }}
previous_gen_version: ${{ steps.run-workflow.outputs.previous_gen_version }}
resolved_speakeasy_version: ${{ steps.run-workflow.outputs.resolved_speakeasy_version }}
steps:
- name: Tune GitHub-hosted runner network
uses: smorimoto/tune-github-hosted-runner-network@v1
- id: run-workflow
name: Run Generation Workflow
uses: speakeasy-api/sdk-generation-action-v15@v15
with:
speakeasy_version: ${{ inputs.speakeasy_version }}
github_access_token: ${{ secrets.github_access_token }}
create_release: ${{ inputs.create_release }}
mode: ${{ inputs.mode }}
force: ${{ inputs.force }}
speakeasy_api_key: ${{ secrets.speakeasy_api_key }}
output_tests: ${{ inputs.output_tests }}
speakeasy_server_url: ${{ inputs.speakeasy_server_url }}
working_directory: ${{ inputs.working_directory }}
- uses: ravsamhq/notify-slack-action@v2
if: always() && env.SLACK_WEBHOOK_URL != ''
with:
status: ${{ job.status }}
token: ${{ secrets.github_access_token }}
notify_when: "failure"
notification_title: "SDK Generation Failed"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Run>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- id: log-result
name: Log Generation Output
uses: speakeasy-api/sdk-generation-action-v15@v15
if: always()
with:
speakeasy_version: ${{ inputs.speakeasy_version }}
github_access_token: ${{ secrets.github_access_token }}
action: log-result
speakeasy_api_key: ${{ secrets.speakeasy_api_key }}
speakeasy_server_url: ${{ inputs.speakeasy_server_url }}
env:
GH_ACTION_RESULT: ${{ job.status }}
RESOLVED_SPEAKEASY_VERSION: ${{ steps.run-workflow.outputs.resolved_speakeasy_version }}
GH_ACTION_VERSION: "v14"
GH_ACTION_STEP: ${{ github.job }}
publish-pypi:
if: ${{ always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.run-workflow.outputs.python_regenerated == 'true' &&
needs.run-workflow.outputs.publish_python == 'true'
&& inputs.mode != 'pr' }}
name: Publish Python SDK
runs-on: ubuntu-latest
needs: [ run-workflow ]
defaults:
run:
working-directory: ${{ needs.run-workflow.outputs.python_directory }}
steps:
- name: Tune GitHub-hosted runner network
uses: smorimoto/tune-github-hosted-runner-network@v1
- uses: actions/checkout@v3
with:
ref: ${{ needs.run-workflow.outputs.commit_hash }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_token }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- uses: ravsamhq/notify-slack-action@v2
if: always() && env.SLACK_WEBHOOK_URL != ''
with:
status: ${{ job.status }}
token: ${{ secrets.github_access_token }}
notify_when: "failure"
notification_title: "Publishing of Python SDK Failed"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Run>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- id: log-result
uses: speakeasy-api/sdk-generation-action-v15@v15
if: always()
with:
speakeasy_version: ${{ inputs.speakeasy_version }}
github_access_token: ${{ secrets.github_access_token }}
action: log-result
speakeasy_api_key: ${{ secrets.speakeasy_api_key }}
speakeasy_server_url: ${{ inputs.speakeasy_server_url }}
env:
GH_ACTION_RESULT: ${{ job.status }}
GH_ACTION_VERSION: "v14"
GH_ACTION_STEP: ${{ github.job }}
TARGET_TYPE: "sdk"
publish-npm:
if: ${{ always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.run-workflow.outputs.typescript_regenerated == 'true' &&
needs.run-workflow.outputs.publish_typescript == 'true'
&& inputs.mode != 'pr' }}
name: Publish Typescript SDK
runs-on: ubuntu-latest
needs: [ run-workflow ]
defaults:
run:
working-directory: ${{ needs.run-workflow.outputs.typescript_directory }}
steps:
- name: Tune GitHub-hosted runner network
uses: smorimoto/tune-github-hosted-runner-network@v1
- uses: actions/checkout@v3
with:
ref: ${{ needs.run-workflow.outputs.commit_hash }}
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm install
- name: Publish
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
run: npm publish --access public
- uses: ravsamhq/notify-slack-action@v2
if: always() && env.SLACK_WEBHOOK_URL != ''
with:
status: ${{ job.status }}
token: ${{ secrets.github_access_token }}
notify_when: "failure"
notification_title: "Publishing of Typescript SDK Failed"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Run>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- id: log-result
uses: speakeasy-api/sdk-generation-action-v15@v15
if: always()
with:
speakeasy_version: ${{ inputs.speakeasy_version }}
github_access_token: ${{ secrets.github_access_token }}
action: log-result
speakeasy_api_key: ${{ secrets.speakeasy_api_key }}
speakeasy_server_url: ${{ inputs.speakeasy_server_url }}
env:
GH_ACTION_RESULT: ${{ job.status }}
GH_ACTION_VERSION: "v14"
GH_ACTION_STEP: ${{ github.job }}
TARGET_TYPE: "sdk"
publish-java:
if: ${{ always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.run-workflow.outputs.java_regenerated == 'true' &&
needs.run-workflow.outputs.publish_java == 'true'
&& inputs.mode != 'pr' }}
name: Publish Java SDK
runs-on: ubuntu-latest
needs: [ run-workflow ]
defaults:
run:
working-directory: ${{ needs.run-workflow.outputs.java_directory }}
steps:
- name: Tune GitHub-hosted runner network
uses: smorimoto/tune-github-hosted-runner-network@v1
- uses: actions/checkout@v3
with:
ref: ${{ needs.run-workflow.outputs.commit_hash }}
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: "11"
distribution: "corretto"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Publish to Sonatype (legacy)
if: ${{ inputs.use_sonatype_central != 'true' }}
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: publish
env:
MAVEN_USERNAME: ${{ secrets.ossrh_username }}
MAVEN_PASSWORD: ${{ secrets.ossrh_password }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.java_gpg_secret_key }}
ORG_GRADLE_PROJECT_signingPassphrase: ${{ secrets.java_gpg_passphrase }}
- name: Publish to Sonatype Central
if: ${{ inputs.use_sonatype_central == 'true' }}
run: |-
pwd
./gradlew build sonatypeCentralUpload --no-daemon
env:
SONATYPE_USERNAME: ${{ secrets.ossrh_username }}
SONATYPE_PASSWORD: ${{ secrets.ossrh_password }}
SONATYPE_SIGNING_KEY: ${{ secrets.java_gpg_secret_key }}
SIGNING_KEY_PASSPHRASE: ${{ secrets.java_gpg_passphrase }}
- uses: ravsamhq/notify-slack-action@v2
if: always() && env.SLACK_WEBHOOK_URL != ''
with:
status: ${{ job.status }}
token: ${{ secrets.github_access_token }}
notify_when: "failure"
notification_title: "Publishing of Java SDK Failed"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Run>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- id: log-result
uses: speakeasy-api/sdk-generation-action-v15@v15
if: always()
with:
speakeasy_version: ${{ inputs.speakeasy_version }}
github_access_token: ${{ secrets.github_access_token }}
action: log-result
speakeasy_api_key: ${{ secrets.speakeasy_api_key }}
speakeasy_server_url: ${{ inputs.speakeasy_server_url }}
env:
GH_ACTION_RESULT: ${{ job.status }}
GH_ACTION_VERSION: "v14"
GH_ACTION_STEP: ${{ github.job }}
TARGET_TYPE: "sdk"
publish-gems:
if: ${{ always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.run-workflow.outputs.ruby_regenerated == 'true' &&
needs.run-workflow.outputs.publish_ruby == 'true'
&& inputs.mode != 'pr' }}
name: Publish Ruby SDK
runs-on: ubuntu-latest
needs: [ run-workflow ]
defaults:
run:
working-directory: ${{ needs.run-workflow.outputs.ruby_directory }}
steps:
- name: Tune GitHub-hosted runner network
uses: smorimoto/tune-github-hosted-runner-network@v1
- uses: actions/checkout@v3
with:
ref: ${{ needs.run-workflow.outputs.commit_hash }}
- name: Set up Ruby
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1
with:
ruby-version: "3.1"
- name: Install dependencies
run: gem build && bundle install && rake rubocop
- name: Publish
env:
GEM_HOST_API_KEY: ${{ secrets.rubygems_auth_token }}
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push *.gem
- uses: ravsamhq/notify-slack-action@v2
if: always() && env.SLACK_WEBHOOK_URL != ''
with:
status: ${{ job.status }}
token: ${{ secrets.github_access_token }}
notify_when: "failure"
notification_title: "Publishing of Ruby SDK Failed"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Run>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- id: log-result
uses: speakeasy-api/sdk-generation-action-v15@v15
if: always()
with:
speakeasy_version: ${{ inputs.speakeasy_version }}
github_access_token: ${{ secrets.github_access_token }}
action: log-result
speakeasy_api_key: ${{ secrets.speakeasy_api_key }}
speakeasy_server_url: ${{ inputs.speakeasy_server_url }}
env:
GH_ACTION_RESULT: ${{ job.status }}
GH_ACTION_VERSION: "v14"
GH_ACTION_STEP: ${{ github.job }}
TARGET_TYPE: "sdk"
publish-nuget:
if: ${{ always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.run-workflow.outputs.csharp_regenerated == 'true' &&
needs.run-workflow.outputs.publish_csharp == 'true'
&& inputs.mode != 'pr' }}
name: Publish C# SDK
runs-on: ubuntu-latest
needs: [ run-workflow ]
defaults:
run:
working-directory: ${{ needs.run-workflow.outputs.csharp_directory }}
steps:
- name: Tune GitHub-hosted runner network
uses: smorimoto/tune-github-hosted-runner-network@v1
- uses: actions/checkout@v3
with:
ref: ${{ needs.run-workflow.outputs.commit_hash }}
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ inputs.dotnet_version }}
- name: Publish
run: dotnet pack -o . && dotnet nuget push *.nupkg --api-key ${{ secrets.nuget_api_key }} --source https://api.nuget.org/v3/index.json
- uses: ravsamhq/notify-slack-action@v2
if: always() && env.SLACK_WEBHOOK_URL != ''
with:
status: ${{ job.status }}
token: ${{ secrets.github_access_token }}
notify_when: "failure"
notification_title: "Publishing of C# SDK Failed"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Run>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- id: log-result
uses: speakeasy-api/sdk-generation-action-v15@v15
if: always()
with:
speakeasy_version: ${{ inputs.speakeasy_version }}
github_access_token: ${{ secrets.github_access_token }}
action: log-result
speakeasy_api_key: ${{ secrets.speakeasy_api_key }}
speakeasy_server_url: ${{ inputs.speakeasy_server_url }}
env:
GH_ACTION_RESULT: ${{ job.status }}
GH_ACTION_VERSION: "v14"
GH_ACTION_STEP: ${{ github.job }}
TARGET_TYPE: "sdk"
publish-packagist:
if: ${{ always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.run-workflow.outputs.php_regenerated == 'true' &&
needs.run-workflow.outputs.publish_php == 'true'
&& inputs.mode != 'pr' }}
name: Publish PHP SDK
runs-on: ubuntu-latest
needs: [ run-workflow ]
defaults:
run:
working-directory: ${{ needs.run-workflow.outputs.php_directory }}
steps:
- name: Tune GitHub-hosted runner network
uses: smorimoto/tune-github-hosted-runner-network@v1
- name: Publish
uses: speakeasy-api/packagist-update@support-github-creation
with:
username: ${{ secrets.packagist_username }}
api_token: ${{ secrets.packagist_token }}
package_name: ${{ github.repository }}
package_base_url: ${{ github.server_url }}
- uses: ravsamhq/notify-slack-action@v2
if: always() && env.SLACK_WEBHOOK_URL != ''
with:
status: ${{ job.status }}
token: ${{ secrets.github_access_token }}
notify_when: "failure"
notification_title: "Publishing of PHP SDK Failed"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Run>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- id: log-result
uses: speakeasy-api/sdk-generation-action-v15@v15
if: always()
with:
speakeasy_version: ${{ inputs.speakeasy_version }}
github_access_token: ${{ secrets.github_access_token }}
action: log-result
speakeasy_api_key: ${{ secrets.speakeasy_api_key }}
speakeasy_server_url: ${{ inputs.speakeasy_server_url }}
env:
GH_ACTION_RESULT: ${{ job.status }}
GH_ACTION_VERSION: "v14"
GH_ACTION_STEP: ${{ github.job }}
TARGET_TYPE: "sdk"