-
Notifications
You must be signed in to change notification settings - Fork 68
639 lines (557 loc) · 20.8 KB
/
create-release-marketing.yml
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
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
name: 📦 Create Marketing Release
on:
push:
paths:
- 'spec/marketing.json'
- 'swagger-config/marketing/**.*'
- '.github/workflows/create-release-marketing.yml'
branches:
- main
env:
PUBLISH_INTERNAL: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} # push to git repos?
PUBLISH_EXTERNAL: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} # push to package managers?
jobs:
validate:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set-version.outputs.version }}
steps:
- uses: actions/checkout@v2
- name: Cache node_modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: NPM Install
run: npm install
- name: Validate Marketing Spec
run: npx @apidevtools/swagger-cli validate spec/marketing.json
- name: Set Version
id: set-version
run: node utils/actions/setVersionVar.js --api=marketing
setup-cache:
runs-on: ubuntu-latest
needs: [validate]
steps:
- uses: actions/checkout@v2
- name: Initialize Cache
id: init-cache-mc
uses: actions/cache@v1
with:
path: .cache
key: cache-dir
- name: Install Codegen CLI
if: steps.init-cache-mc.outputs.cache-hit != 'true'
run: |
mkdir .cache
wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.7/swagger-codegen-cli-2.4.7.jar -O .cache/swagger-codegen-cli.jar
java -jar .cache/swagger-codegen-cli.jar help
generate-node:
runs-on: ubuntu-latest
needs: [validate, setup-cache]
steps:
- uses: actions/checkout@v2
- name: Initialize Marketing Cache
id: init-cache-mc
uses: actions/cache@v1
with:
path: .cache
key: cache-dir
- name: Cache node_modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
scope: '@mailchimp'
- name: Generate → marketing-javascript
run: |
npm install
node utils/actions/updateLangConfig.js --api=marketing --lang=javascript --specVersion=${{ env.SPEC_VERSION }}
npm run generate:javascript:marketing
env:
SPEC_VERSION: ${{ needs.validate.outputs.version }}
- name: Rename marketing-javascript → marketing-node
working-directory: swagger-out
run: |
mv marketing-javascript marketing-node
- name: Zip build artifact → marketing-node
working-directory: swagger-out/marketing-node
run: zip -r mailchimp-marketing-node.zip .
- name: Upload build artifact → marketing-node
uses: actions/upload-artifact@v1
with:
name: mailchimp-marketing-node.zip
path: swagger-out/marketing-node/mailchimp-marketing-node.zip
generate-php:
runs-on: ubuntu-latest
needs: [validate, setup-cache]
steps:
- uses: actions/checkout@v2
- name: Initialize Marketing Cache
id: init-cache-mc
uses: actions/cache@v1
with:
path: .cache
key: cache-dir
- name: Cache node_modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Generate → marketing-php
run: |
npm install
node utils/actions/updateLangConfig.js --api=marketing --lang=php --specVersion=${{ env.SPEC_VERSION }}
npm run generate:php:marketing
env:
SPEC_VERSION: ${{ needs.validate.outputs.version }}
- name: Zip build artifact → marketing-php
working-directory: swagger-out/marketing-php
run: zip -r mailchimp-marketing-php.zip .
- name: Upload build artifact → marketing-php
uses: actions/upload-artifact@v1
with:
name: mailchimp-marketing-php.zip
path: swagger-out/marketing-php/mailchimp-marketing-php.zip
generate-ruby:
runs-on: ubuntu-latest
needs: [validate, setup-cache]
steps:
- uses: actions/checkout@v2
- name: Initialize Marketing Cache
id: init-cache-mc
uses: actions/cache@v1
with:
path: .cache
key: cache-dir
- name: Cache node_modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Generate → marketing-ruby
run: |
npm install
node utils/actions/updateLangConfig.js --api=marketing --lang=ruby --specVersion=${{ env.SPEC_VERSION }}
npm run generate:ruby:marketing
env:
SPEC_VERSION: ${{ needs.validate.outputs.version }}
- name: Zip build artifact → marketing-ruby
working-directory: swagger-out/marketing-ruby
run: zip -r mailchimp-marketing-ruby.zip .
- name: Upload build artifact → marketing-ruby
uses: actions/upload-artifact@v1
with:
name: mailchimp-marketing-ruby.zip
path: swagger-out/marketing-ruby/mailchimp-marketing-ruby.zip
generate-python:
runs-on: ubuntu-latest
needs: [validate, setup-cache]
steps:
- uses: actions/checkout@v2
- name: Initialize Marketing Cache
id: init-cache-mc
uses: actions/cache@v1
with:
path: .cache
key: cache-dir
- name: Cache node_modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Generate → marketing-python
run: |
npm install
node utils/actions/updateLangConfig.js --api=marketing --lang=python --specVersion=${{ env.SPEC_VERSION }}
npm run generate:python:marketing
env:
SPEC_VERSION: ${{ needs.validate.outputs.version }}
- name: Zip build artifact → marketing-python
working-directory: swagger-out/marketing-python
run: zip -r mailchimp-marketing-python.zip .
- name: Upload build artifact → marketing-python
uses: actions/upload-artifact@v1
with:
name: mailchimp-marketing-python.zip
path: swagger-out/marketing-python/mailchimp-marketing-python.zip
test-node:
runs-on: ubuntu-latest
needs: [generate-node]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
scope: '@mailchimp'
- name: Prepare Build & Publishing Tools
run: npm install
- uses: actions/download-artifact@v4.1.7
with:
name: mailchimp-marketing-node.zip
path: zip
- name: Unzip build artifact
run: |
mkdir -p swagger-out/marketing-javascript
unzip zip/mailchimp-marketing-node.zip -d swagger-out/marketing-javascript
- name: Install client
working-directory: swagger-out/marketing-javascript
run: npm install
- name: Run test suite
run: npm run test -- MarketingTest.test.js
env:
MARKETING_API_KEY: ${{ secrets.MARKETING_API_KEY }}
MARKETING_ACCESS_TOKEN: ${{ secrets.MARKETING_ACCESS_TOKEN }}
MARKETING_SERVER: ${{ secrets.MARKETING_SERVER }}
test-php:
runs-on: ubuntu-latest
needs: [generate-php]
steps:
- uses: actions/checkout@v2
- name: Initialize Marketing Cache
id: init-cache-mc
uses: actions/cache@v1
with:
path: .cache
key: cache-dir
- uses: actions/download-artifact@v4.1.7
with:
name: mailchimp-marketing-php.zip
path: zip
- name: Unzip build artifact
run: |
mkdir -p swagger-out/marketing-php
unzip zip/mailchimp-marketing-php.zip -d swagger-out/marketing-php
- uses: php-actions/composer@v5
with:
php_version: 7.4
command: install -d swagger-out/marketing-php/MailchimpMarketing
- name: Install client dependencies
run: |
wget -O phpunit https://phar.phpunit.de/phpunit-9.phar
chmod +x phpunit
./phpunit --version
- name: Run test suite
working-directory: tests/marketing-php
run: |
MARKETING_API_KEY=${{ secrets.MARKETING_API_KEY }} \
MARKETING_SERVER=${{ secrets.MARKETING_SERVER }} \
MARKETING_ACCESS_TOKEN=${{ secrets.MARKETING_ACCESS_TOKEN }} \
phpunit MarketingTest.php
env:
MARKETING_API_KEY: ${{ secrets.MARKETING_API_KEY }}
MARKETING_ACCESS_TOKEN: ${{ secrets.MARKETING_ACCESS_TOKEN }}
MARKETING_SERVER: ${{ secrets.MARKETING_SERVER }}
test-ruby:
runs-on: ubuntu-latest
needs: [generate-ruby]
steps:
- uses: actions/checkout@v2
- name: Initialize Marketing Cache
id: init-cache-mc
uses: actions/cache@v1
with:
path: .cache
key: cache-dir
- uses: actions/download-artifact@v4.1.7
with:
name: mailchimp-marketing-ruby.zip
path: zip
- name: Unzip build artifact
run: |
mkdir -p swagger-out/marketing-ruby
unzip zip/mailchimp-marketing-ruby.zip -d swagger-out/marketing-ruby
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'
- name: Install client dependencies
run: gem install rspec
- name: Install client
working-directory: swagger-out/marketing-ruby
run: |
gem build MailchimpMarketing.gemspec --output=MailchimpMarketing-test.gem
gem install ./MailchimpMarketing-test.gem
- name: Run test suite
run: |
cd tests/marketing-ruby
MARKETING_API_KEY=${{ secrets.MARKETING_API_KEY }} \
MARKETING_SERVER=${{ secrets.MARKETING_SERVER }} \
MARKETING_ACCESS_TOKEN=${{ secrets.MARKETING_ACCESS_TOKEN }} \
rspec MarketingTest_spec.rb
env:
MARKETING_API_KEY: ${{ secrets.MARKETING_API_KEY }}
MARKETING_ACCESS_TOKEN: ${{ secrets.MARKETING_ACCESS_TOKEN }}
MARKETING_SERVER: ${{ secrets.MARKETING_SERVER }}
test-python:
runs-on: ubuntu-latest
needs: [generate-python]
steps:
- uses: actions/checkout@v2
- name: Initialize Marketing Cache
id: init-cache-mc
uses: actions/cache@v1
with:
path: .cache
key: cache-dir
- name: Install Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- uses: actions/download-artifact@v4.1.7
with:
name: mailchimp-marketing-python.zip
path: zip
- name: Unzip build artifact
run: |
mkdir -p swagger-out/marketing-python
unzip zip/mailchimp-marketing-python.zip -d swagger-out/marketing-python
- name: Install client dependencies
run: pip install -U python-dotenv
- name: Install client
working-directory: swagger-out/marketing-python
run: python3 setup.py install --user
- name: Run test suite
run: |
cd tests/marketing-python
MARKETING_API_KEY=${{ secrets.MARKETING_API_KEY }} \
MARKETING_SERVER=${{ secrets.MARKETING_SERVER }} \
MARKETING_ACCESS_TOKEN=${{ secrets.MARKETING_ACCESS_TOKEN }} \
python3 MarketingTest.py
env:
MARKETING_API_KEY: ${{ secrets.MARKETING_API_KEY }}
MARKETING_ACCESS_TOKEN: ${{ secrets.MARKETING_ACCESS_TOKEN }}
MARKETING_SERVER: ${{ secrets.MARKETING_SERVER }}
create-release:
runs-on: ubuntu-latest
needs: [validate, test-node, test-php, test-ruby, test-python]
steps:
- name: Create Release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GIT_HUB_TOKEN }}
SPEC_VERSION: ${{ needs.validate.outputs.version }}
with:
tag_name: ${{ github.ref }}
release_name: Mailchimp Marketing v${{ env.SPEC_VERSION }}
draft: true
prerelease: false
publish-node:
runs-on: ubuntu-latest
needs: [validate, create-release]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
scope: '@mailchimp'
- name: Prepare Build & Publishing Tools
run: npm install
- uses: actions/download-artifact@v4.1.7
with:
name: mailchimp-marketing-node.zip
path: zip
- name: Unzip build artifact
run: |
unzip zip/mailchimp-marketing-node.zip -d marketing-node
- name: Publish → internal → marketing-node
if: env.PUBLISH_INTERNAL == 'true'
working-directory: marketing-node
run: |
rm -rf .git # remove any existing .git directory
git clone https://github:"$GITHUB_TOKEN"@github.com/mailchimp/mailchimp-marketing-node.git repo # clone repo to track history
mv repo/.git . # move cloned git history to root
rm -rf repo
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add --force .
git commit -m "Update mailchimp-marketing-node to v${{ env.SPEC_VERSION }}"
git push origin master --force
env:
GITHUB_TOKEN: ${{ secrets.GIT_HUB_TOKEN }}
SPEC_VERSION: ${{ needs.validate.outputs.version }}
- name: Publish → npm → marketing-node
if: env.PUBLISH_EXTERNAL == 'true'
working-directory: marketing-node
run: |
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-php:
runs-on: ubuntu-latest
needs: [validate, create-release]
steps:
- uses: actions/checkout@v2
- name: Initialize Marketing Cache
id: init-cache-mc
uses: actions/cache@v1
with:
path: .cache
key: cache-dir
- uses: actions/download-artifact@v4.1.7
with:
name: mailchimp-marketing-php.zip
path: zip
- name: Unzip build artifact
run: |
unzip zip/mailchimp-marketing-php.zip -d marketing-php
- name: Publish → internal → marketing-php
if: env.PUBLISH_INTERNAL == 'true'
working-directory: marketing-php/MailchimpMarketing
run: |
rm -rf .git # remove any existing .git directory
git clone https://github:"$GITHUB_TOKEN"@github.com/mailchimp/mailchimp-marketing-php.git repo # clone repo to track history
mv repo/.git . # move cloned git history to root
rm -rf repo
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add --force .
git commit -m "Update mailchimp-marketing-php to v${{ env.SPEC_VERSION }}"
git tag -a v${{ env.SPEC_VERSION }} -m "Update v${{ env.SPEC_VERSION }}"
git push origin master --follow-tags --force
env:
GITHUB_TOKEN: ${{ secrets.GIT_HUB_TOKEN }}
SPEC_VERSION: ${{ needs.validate.outputs.version }}
publish-ruby:
runs-on: ubuntu-latest
needs: [validate, create-release]
steps:
- uses: actions/checkout@v2
- name: Initialize Marketing Cache
id: init-cache-mc
uses: actions/cache@v1
with:
path: .cache
key: cache-dir
- name: Install Ruby 2.6.x
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Prepare Build & Publishing Tools
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${RUBYGEMS_TOKEN}\n" > $HOME/.gem/credentials
env:
RUBYGEMS_TOKEN: ${{ secrets.RUBYGEMS_TOKEN }}
- uses: actions/download-artifact@v4.1.7
with:
name: mailchimp-marketing-ruby.zip
path: zip
- name: Unzip build artifact
run: |
unzip zip/mailchimp-marketing-ruby.zip -d marketing-ruby
- name: Publish → internal → marketing-ruby
if: env.PUBLISH_INTERNAL == 'true'
working-directory: marketing-ruby
run: |
rm -rf .git # remove any existing .git directory
git clone https://github:"$GITHUB_TOKEN"@github.com/mailchimp/mailchimp-marketing-ruby.git repo # clone repo to track history
mv repo/.git . # move cloned git history to root
rm -rf repo
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add --force .
git commit -m "Update mailchimp-marketing-ruby to v${{ env.SPEC_VERSION }}"
git push origin master --force
env:
GITHUB_TOKEN: ${{ secrets.GIT_HUB_TOKEN }}
SPEC_VERSION: ${{ needs.validate.outputs.version }}
- name: Publish → RubyGems → marketing-ruby
if: env.PUBLISH_EXTERNAL == 'true'
run: |
gem build marketing-ruby/*.gemspec
gem push marketing-ruby/*.gem -k rubygems
publish-python:
runs-on: ubuntu-latest
needs: [validate, create-release]
steps:
- uses: actions/checkout@v2
- name: Initialize Marketing Cache
id: init-cache-mc
uses: actions/cache@v1
with:
path: .cache
key: cache-dir
- name: Install Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- uses: actions/download-artifact@v4.1.7
with:
name: mailchimp-marketing-python.zip
path: zip
- name: Unzip build artifact
run: |
unzip zip/mailchimp-marketing-python.zip -d marketing-python
- name: Prepare Build & Publishing Tools
working-directory: marketing-python
run: |
python -m pip install --user setuptools wheel --no-warn-script-location
python setup.py bdist_wheel
- name: Publish → internal → marketing-python
if: env.PUBLISH_INTERNAL == 'true'
working-directory: marketing-python
run: |
rm -rf .git # remove any existing .git directory
git clone https://github:"$GITHUB_TOKEN"@github.com/mailchimp/mailchimp-marketing-python.git repo # clone repo to track history
mv repo/.git . # move cloned git history to root
rm -rf repo
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add --force .
git commit -m "Update mailchimp-marketing-python to v${{ env.SPEC_VERSION }}"
git push origin master --force
env:
GITHUB_TOKEN: ${{ secrets.GIT_HUB_TOKEN }}
SPEC_VERSION: ${{ needs.validate.outputs.version }}
- name: Publish → PyPI → marketing-python (test)
if: env.PUBLISH_EXTERNAL == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN_TEST }}
repository_url: https://test.pypi.org/legacy/
packages_dir: marketing-python/dist
- name: Publish → PyPI → marketing-python (dist)
if: env.PUBLISH_EXTERNAL == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
packages_dir: marketing-python/dist