Skip to content

Merge pull request #366 from mailchimp/dependabot/github_actions/dot-… #229

Merge pull request #366 from mailchimp/dependabot/github_actions/dot-…

Merge pull request #366 from mailchimp/dependabot/github_actions/dot-… #229

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/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]
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 "[email protected]"
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/[email protected]
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 "[email protected]"
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/[email protected]
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 "[email protected]"
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/[email protected]
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 "[email protected]"
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