Merge pull request #367 from zenpaul/paul/upgrade-axios #144
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 📦 Create Transactional Release | |
on: | |
push: | |
paths: | |
- 'spec/transactional.json' | |
- 'swagger-config/transactional/**.*' | |
- '.github/workflows/create-release-transactional.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@v4 | |
- name: Cache node_modules | |
uses: actions/cache@v4 | |
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 Transactional Spec | |
run: npx @apidevtools/swagger-cli validate spec/transactional.json | |
- name: Set Version | |
id: set-version | |
run: node utils/actions/setVersionVar.js --api=transactional | |
setup-cache: | |
runs-on: ubuntu-latest | |
needs: [validate] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Initialize Cache | |
id: init-cache-md | |
uses: actions/cache@v4 | |
with: | |
path: .cache | |
key: cache-dir | |
- name: Install Codegen CLI | |
if: steps.init-cache-md.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@v4 | |
- name: Initialize Transactional Cache | |
id: init-cache-md | |
uses: actions/cache@v4 | |
with: | |
path: .cache | |
key: cache-dir | |
- name: Cache node_modules | |
uses: actions/cache@v4 | |
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 → transactional-javascript | |
run: | | |
npm install | |
node utils/actions/updateLangConfig.js --api=transactional --lang=javascript --specVersion=${{ env.SPEC_VERSION }} | |
npm run generate:javascript:transactional | |
env: | |
SPEC_VERSION: ${{ needs.validate.outputs.version }} | |
- name: Rename transactional-javascript → transactional-node | |
working-directory: swagger-out | |
run: | | |
mv transactional-javascript transactional-node | |
- name: Zip build artifact → transactional-node | |
working-directory: swagger-out/transactional-node | |
run: zip -r mailchimp-transactional-node.zip . | |
- name: Upload build artifact → transactional-node | |
uses: actions/upload-artifact@v1 | |
with: | |
name: mailchimp-transactional-node.zip | |
path: swagger-out/transactional-node/mailchimp-transactional-node.zip | |
generate-php: | |
runs-on: ubuntu-latest | |
needs: [validate, setup-cache] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Initialize Transactional Cache | |
id: init-cache-md | |
uses: actions/cache@v4 | |
with: | |
path: .cache | |
key: cache-dir | |
- name: Cache node_modules | |
uses: actions/cache@v4 | |
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 → transactional-php | |
run: | | |
npm install | |
node utils/actions/updateLangConfig.js --api=transactional --lang=php --specVersion=${{ env.SPEC_VERSION }} | |
npm run generate:php:transactional | |
env: | |
SPEC_VERSION: ${{ needs.validate.outputs.version }} | |
- name: Zip build artifact → transactional-php | |
working-directory: swagger-out/transactional-php | |
run: zip -r mailchimp-transactional-php.zip . | |
- name: Upload build artifact → transactional-php | |
uses: actions/upload-artifact@v1 | |
with: | |
name: mailchimp-transactional-php.zip | |
path: swagger-out/transactional-php/mailchimp-transactional-php.zip | |
generate-ruby: | |
runs-on: ubuntu-latest | |
needs: [validate, setup-cache] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Initialize Transactional Cache | |
id: init-cache-md | |
uses: actions/cache@v4 | |
with: | |
path: .cache | |
key: cache-dir | |
- name: Cache node_modules | |
uses: actions/cache@v4 | |
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 → transactional-ruby | |
run: | | |
npm install | |
node utils/actions/updateLangConfig.js --api=transactional --lang=ruby --specVersion=${{ env.SPEC_VERSION }} | |
npm run generate:ruby:transactional | |
env: | |
SPEC_VERSION: ${{ needs.validate.outputs.version }} | |
- name: Zip build artifact → transactional-ruby | |
working-directory: swagger-out/transactional-ruby | |
run: zip -r mailchimp-transactional-ruby.zip . | |
- name: Upload build artifact → transactional-ruby | |
uses: actions/upload-artifact@v1 | |
with: | |
name: mailchimp-transactional-ruby.zip | |
path: swagger-out/transactional-ruby/mailchimp-transactional-ruby.zip | |
generate-python: | |
runs-on: ubuntu-latest | |
needs: [validate, setup-cache] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Initialize Transactional Cache | |
id: init-cache-md | |
uses: actions/cache@v4 | |
with: | |
path: .cache | |
key: cache-dir | |
- name: Cache node_modules | |
uses: actions/cache@v4 | |
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 → transactional-python | |
run: | | |
npm install | |
node utils/actions/updateLangConfig.js --api=transactional --lang=python --specVersion=${{ env.SPEC_VERSION }} | |
npm run generate:python:transactional | |
env: | |
SPEC_VERSION: ${{ needs.validate.outputs.version }} | |
- name: Zip build artifact → transactional-python | |
working-directory: swagger-out/transactional-python | |
run: zip -r mailchimp-transactional-python.zip . | |
- name: Upload build artifact → transactional-python | |
uses: actions/upload-artifact@v1 | |
with: | |
name: mailchimp-transactional-python.zip | |
path: swagger-out/transactional-python/mailchimp-transactional-python.zip | |
test-node: | |
runs-on: ubuntu-latest | |
needs: [generate-node] | |
steps: | |
- uses: actions/checkout@v4 | |
- 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@v1 | |
with: | |
name: mailchimp-transactional-node.zip | |
path: zip | |
- name: Unzip build artifact | |
run: | | |
mkdir -p swagger-out/transactional-javascript | |
unzip zip/mailchimp-transactional-node.zip -d swagger-out/transactional-javascript | |
- name: Install client | |
working-directory: swagger-out/transactional-javascript | |
run: npm install | |
- name: Run test suite | |
run: npm run test -- TransactionalTest.test.js | |
env: | |
TRANSACTIONAL_API_KEY: ${{ secrets.TRANSACTIONAL_API_KEY }} | |
test-php: | |
runs-on: ubuntu-latest | |
needs: [generate-php] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Initialize Transactional Cache | |
id: init-cache-mc | |
uses: actions/cache@v4 | |
with: | |
path: .cache | |
key: cache-dir | |
- uses: actions/download-artifact@v1 | |
with: | |
name: mailchimp-transactional-php.zip | |
path: zip | |
- name: Unzip build artifact | |
run: | | |
mkdir -p swagger-out/transactional-php | |
unzip zip/mailchimp-transactional-php.zip -d swagger-out/transactional-php | |
- uses: php-actions/composer@v5 | |
with: | |
php_version: 7.4 | |
command: install -d swagger-out/transactional-php/MailchimpTransactional | |
- 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/transactional-php | |
run: | | |
TRANSACTIONAL_API_KEY=${{ secrets.TRANSACTIONAL_API_KEY }} \ | |
phpunit TransactionalTest.php | |
env: | |
TRANSACTIONAL_API_KEY: ${{ secrets.TRANSACTIONAL_API_KEY }} | |
test-ruby: | |
runs-on: ubuntu-latest | |
needs: [generate-ruby] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Initialize Transactional Cache | |
id: init-cache-mc | |
uses: actions/cache@v4 | |
with: | |
path: .cache | |
key: cache-dir | |
- uses: actions/download-artifact@v1 | |
with: | |
name: mailchimp-transactional-ruby.zip | |
path: zip | |
- name: Unzip build artifact | |
run: | | |
mkdir -p swagger-out/transactional-ruby | |
unzip zip/mailchimp-transactional-ruby.zip -d swagger-out/transactional-ruby | |
- name: Set up Ruby 2.6 | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '2.6' | |
- name: Install client dependencies | |
run: gem install rspec | |
- name: Install client | |
working-directory: swagger-out/transactional-ruby | |
run: | | |
gem build MailchimpTransactional.gemspec --output=MailchimpTransactional-test.gem | |
gem install ./MailchimpTransactional-test.gem | |
- name: Run test suite | |
run: | | |
cd tests/transactional-ruby | |
TRANSACTIONAL_API_KEY=${{ secrets.TRANSACTIONAL_API_KEY }} \ | |
rspec TransactionalTest_spec.rb | |
env: | |
TRANSACTIONAL_API_KEY: ${{ secrets.TRANSACTIONAL_API_KEY }} | |
test-python: | |
runs-on: ubuntu-latest | |
needs: [generate-python] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Initialize Transactional Cache | |
id: init-cache-mc | |
uses: actions/cache@v4 | |
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@v1 | |
with: | |
name: mailchimp-transactional-python.zip | |
path: zip | |
- name: Unzip build artifact | |
run: | | |
mkdir -p swagger-out/transactional-python | |
unzip zip/mailchimp-transactional-python.zip -d swagger-out/transactional-python | |
- name: Install client dependencies | |
run: pip install -U python-dotenv | |
- name: Install client | |
working-directory: swagger-out/transactional-python | |
run: python3 setup.py install --user | |
- name: Run test suite | |
run: | | |
cd tests/transactional-python | |
TRANSACTIONAL_API_KEY=${{ secrets.TRANSACTIONAL_API_KEY }} \ | |
python3 TransactionalTest.py | |
env: | |
TRANSACTIONAL_API_KEY: ${{ secrets.TRANSACTIONAL_API_KEY }} | |
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_CODEGEN_TOKEN }} #use fresh token | |
SPEC_VERSION: ${{ needs.validate.outputs.version }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Mailchimp Transactional v${{ env.SPEC_VERSION }} | |
draft: true | |
prerelease: false | |
publish-node: | |
runs-on: ubuntu-latest | |
needs: [validate, create-release] | |
steps: | |
- uses: actions/checkout@v4 | |
- 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@v1 | |
with: | |
name: mailchimp-transactional-node.zip | |
path: zip | |
- name: Unzip build artifact | |
run: | | |
unzip zip/mailchimp-transactional-node.zip -d transactional-node | |
- name: Publish → internal → transactional-node | |
if: env.PUBLISH_INTERNAL == 'true' | |
working-directory: transactional-node | |
run: | | |
rm -rf .git # remove any existing .git directory | |
git clone https://github:"$GITHUB_TOKEN"@github.com/mailchimp/mailchimp-transactional-node repo # clone repo to track history | |
mv repo/.git . # move cloned git history to root | |
rm -rf repo | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add --force . | |
git commit -m "Update mailchimp-transactional-node to v${{ env.SPEC_VERSION }}" | |
git push origin master --force | |
env: | |
GITHUB_TOKEN: ${{ secrets.GIT_CODEGEN_TOKEN }} | |
SPEC_VERSION: ${{ needs.validate.outputs.version }} | |
- name: Publish → npm → transactional-node | |
if: env.PUBLISH_EXTERNAL == 'true' | |
working-directory: transactional-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@v4 | |
- name: Initialize Transactional Cache | |
id: init-cache-md | |
uses: actions/cache@v4 | |
with: | |
path: .cache | |
key: cache-dir | |
- uses: actions/download-artifact@v1 | |
with: | |
name: mailchimp-transactional-php.zip | |
path: zip | |
- name: Unzip build artifact | |
run: | | |
unzip zip/mailchimp-transactional-php.zip -d transactional-php | |
- name: Publish → internal → transactional-php | |
if: env.PUBLISH_INTERNAL == 'true' | |
working-directory: transactional-php/MailchimpTransactional | |
run: | | |
rm -rf .git # remove any existing .git directory | |
git clone https://github:"$GITHUB_TOKEN"@github.com/mailchimp/mailchimp-transactional-php repo # clone repo to track history | |
mv repo/.git . # move cloned git history to root | |
rm -rf repo | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add --force . | |
git commit -m "Update mailchimp-transactional-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_CODEGEN_TOKEN }} | |
SPEC_VERSION: ${{ needs.validate.outputs.version }} | |
publish-ruby: | |
runs-on: ubuntu-latest | |
needs: [validate, create-release] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Initialize Transactional Cache | |
id: init-cache-md | |
uses: actions/cache@v4 | |
with: | |
path: .cache | |
key: cache-dir | |
- name: Install Ruby 2.6.x | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 2.6.10 | |
- 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@v1 | |
with: | |
name: mailchimp-transactional-ruby.zip | |
path: zip | |
- name: Unzip build artifact | |
run: | | |
unzip zip/mailchimp-transactional-ruby.zip -d transactional-ruby | |
- name: Publish → internal → transactional-ruby | |
if: env.PUBLISH_INTERNAL == 'true' | |
working-directory: transactional-ruby | |
run: | | |
rm -rf .git # remove any existing .git directory | |
git clone https://github:"$GITHUB_TOKEN"@github.com/mailchimp/mailchimp-transactional-ruby repo # clone repo to track history | |
mv repo/.git . # move cloned git history to root | |
rm -rf repo | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add --force . | |
git commit -m "Update mailchimp-transactional-ruby to v${{ env.SPEC_VERSION }}" | |
git push origin master --force | |
env: | |
GITHUB_TOKEN: ${{ secrets.GIT_CODEGEN_TOKEN }} | |
SPEC_VERSION: ${{ needs.validate.outputs.version }} | |
- name: Publish → RubyGems → transactional-ruby | |
if: env.PUBLISH_EXTERNAL == 'true' | |
run: | | |
gem build transactional-ruby/*.gemspec | |
gem push transactional-ruby/*.gem -k rubygems | |
publish-python: | |
runs-on: ubuntu-latest | |
needs: [validate, create-release] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Initialize Transactional Cache | |
id: init-cache-md | |
uses: actions/cache@v4 | |
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@v1 | |
with: | |
name: mailchimp-transactional-python.zip | |
path: zip | |
- name: Unzip build artifact | |
run: | | |
unzip zip/mailchimp-transactional-python.zip -d transactional-python | |
- name: Prepare Build & Publishing Tools | |
working-directory: transactional-python | |
run: | | |
python -m pip install --user setuptools wheel --no-warn-script-location | |
python setup.py bdist_wheel | |
- name: Publish → internal → transactional-python | |
if: env.PUBLISH_INTERNAL == 'true' | |
working-directory: transactional-python | |
run: | | |
rm -rf .git # remove any existing .git directory | |
git clone https://github:"$GITHUB_TOKEN"@github.com/mailchimp/mailchimp-transactional-python repo # clone repo to track history | |
mv repo/.git . # move cloned git history to root | |
rm -rf repo | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add --force . | |
git commit -m "Update mailchimp-transactional-python to v${{ env.SPEC_VERSION }}" | |
git push origin master --force | |
env: | |
GITHUB_TOKEN: ${{ secrets.GIT_CODEGEN_TOKEN }} | |
SPEC_VERSION: ${{ needs.validate.outputs.version }} | |
- name: Publish → PyPI → transactional-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: transactional-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: transactional-python/dist |