From 9c7c7fdbaa3ce1c79cdb11a82061ea96e7e1f059 Mon Sep 17 00:00:00 2001 From: AJ Rice <53190766+ajrice6713@users.noreply.github.com> Date: Fri, 18 Nov 2022 11:33:44 -0500 Subject: [PATCH 1/2] Add beta deployment logic Remove docker action Setup workflow to grab release version from release tag Enforce regex pattern on release tags --- .github/actions/deploy/Dockerfile | 11 -- .github/actions/deploy/action.yml | 6 -- .github/actions/deploy/entrypoint.sh | 6 -- .github/workflows/deploy.yml | 149 +++++++++++++++++++++------ setup.py | 5 +- 5 files changed, 123 insertions(+), 54 deletions(-) delete mode 100644 .github/actions/deploy/Dockerfile delete mode 100644 .github/actions/deploy/action.yml delete mode 100644 .github/actions/deploy/entrypoint.sh diff --git a/.github/actions/deploy/Dockerfile b/.github/actions/deploy/Dockerfile deleted file mode 100644 index 6977b083..00000000 --- a/.github/actions/deploy/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -# Container image that runs your code -FROM python:3 - -# Copies your code file from your action repository to the filesystem path `/` of the container -COPY entrypoint.sh /entrypoint.sh - -#Make entrypoint.sh exacutable -RUN chmod +x /entrypoint.sh - -# Code file to execute when the docker container starts up (`entrypoint.sh`) -ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/deploy/action.yml b/.github/actions/deploy/action.yml deleted file mode 100644 index 38f99b06..00000000 --- a/.github/actions/deploy/action.yml +++ /dev/null @@ -1,6 +0,0 @@ -# action.yml -name: 'Deploy' -description: 'Deploys the python sdk to PYPI' -runs: - using: 'docker' - image: 'Dockerfile' diff --git a/.github/actions/deploy/entrypoint.sh b/.github/actions/deploy/entrypoint.sh deleted file mode 100644 index bc79cf66..00000000 --- a/.github/actions/deploy/entrypoint.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -pip install twine -pip install wheel -python setup.py sdist bdist_wheel -twine upload dist/* -u $PYPI_USERNAME -p $PYPI_PASSWORD diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 52516855..e42a7b26 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,38 +4,127 @@ on: release: types: - published + jobs: + deploy_pre_release: + name: Deploy OpenAPI Generator Client Pre-Release to PYPI + if: ${{ github.event.release.prerelease && github.event.release.target_commitish == 'feature/openapi-generator-sdk' }} + runs-on: ubuntu-latest + env: + BW_ACCOUNT_ID: ${{ secrets.BW_ACCOUNT_ID }} + BW_USERNAME: ${{ secrets.BW_USERNAME }} + BW_PASSWORD: ${{ secrets.BW_PASSWORD }} + BW_USERNAME_FORBIDDEN: ${{ secrets.BW_USERNAME_FORBIDDEN }} + BW_PASSWORD_FORBIDDEN: ${{ secrets.BW_PASSWORD_FORBIDDEN }} + BW_VOICE_APPLICATION_ID: ${{ secrets.BW_VOICE_APPLICATION_ID }} + BW_MESSAGING_APPLICATION_ID: ${{ secrets.BW_MESSAGING_APPLICATION_ID }} + BW_NUMBER: ${{ secrets.BW_NUMBER }} + USER_NUMBER: ${{ secrets.USER_NUMBER }} + VZW_NUMBER: ${{ secrets.VZW_NUMBER }} + ATT_NUMBER: ${{ secrets.ATT_NUMBER }} + T_MOBILE_NUMBER: ${{ secrets.T_MOBILE_NUMBER }} + BASE_CALLBACK_URL: ${{ secrets.BASE_CALLBACK_URL }} + PYTHON_VERSION: ${{ matrix.python-version }} + OPERATING_SYSTEM: ${{ matrix.os }} + MANTECA_ACTIVE_NUMBER: ${{ secrets.MANTECA_ACTIVE_NUMBER }} + MANTECA_IDLE_NUMBER: ${{ secrets.MANTECA_IDLE_NUMBER }} + MANTECA_BASE_URL: ${{ secrets.MANTECA_BASE_URL }} + MANTECA_APPLICATION_ID: ${{ secrets.MANTECA_APPLICATION_ID }} + BW_NUMBER_PROVIDER: ${{ secrets.BW_NUMBER_PROVIDER }} + steps: + - name: Set Release Version + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV + + - name: Check Release Tag Format + run: | + re=[0-9]+\.[0-9]+\.[0-9]+b[0-9]+ + if ! [[ $RELEASE_VERSION =~ $re ]]; then + echo 'Tag does not match expected regex pattern for beta releases (v[0-9]+.[0-9]+.[0-9]+b[0-9]+)' + echo $RELEASE_VERSION + echo 'Please update your tag to match the expected regex pattern' + exit 1 + fi + + - name: Checkout + uses: actions/checkout@v3 + with: + ref: feature/openapi-generator-sdk + + - name: Install Packages + run: | + pip install -r requirements.txt + pip install -r test-requirements.txt + + - name: Test + run: | + pytest -v + + - name: Deploy to PYPI + run: | + pip install twine + pip install wheel + python setup.py sdist bdist_wheel + twine upload dist/* -u $PYPI_USERNAME -p $PYPI_PASSWORD + env: + PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + + - uses: Bandwidth/build-notify-slack-action@v1.0.0 + if: always() + with: + job-status: ${{ job.status }} + slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} + slack-channel: ${{ secrets.SLACK_CHANNEL }} + deploy: - name: Deploy to PYPI + name: Deploy `main` to PYPI if: ${{ !github.event.release.prerelease && github.event.release.target_commitish == 'main' }} runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install Packages - run: pip install -r requirements_dev.txt - - - name: Test - env: - BW_ACCOUNT_ID: ${{ secrets.BW_ACCOUNT_ID }} - BW_USERNAME: ${{ secrets.BW_USERNAME }} - BW_PASSWORD: ${{ secrets.BW_PASSWORD }} - BW_VOICE_APPLICATION_ID: ${{ secrets.BW_VOICE_APPLICATION_ID }} - BW_MESSAGING_APPLICATION_ID: ${{ secrets.BW_MESSAGING_APPLICATION_ID }} - BW_NUMBER: ${{ secrets.BW_NUMBER }} - USER_NUMBER: ${{ secrets.USER_NUMBER }} - BASE_CALLBACK_URL: ${{ secrets.BASE_CALLBACK_URL }} - run: python -m pytest --pyargs bandwidth - - - name: Deploy to PYPI - uses: ./.github/actions/deploy - env: - PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} - PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - - uses: Bandwidth/build-notify-slack-action@v1.0.0 - if: always() - with: - job-status: ${{ job.status }} - slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} - slack-channel: ${{ secrets.SLACK_CHANNEL }} + - name: Set Release Version + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV + + - name: Check Release Tag Format + run: | + re=[0-9]+\.[0-9]+\.[0-9]+ + if ! [[ $RELEASE_VERSION =~ $re ]]; then + echo 'Tag does not match expected regex pattern for beta releases (v[0-9]+.[0-9]+.[0-9]+b[0-9]+)' + echo $RELEASE_VERSION + echo 'Please update your tag to match the expected regex pattern' + exit 1 + fi + + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Packages + run: pip install -r requirements_dev.txt + + - name: Test + env: + BW_ACCOUNT_ID: ${{ secrets.BW_ACCOUNT_ID }} + BW_USERNAME: ${{ secrets.BW_USERNAME }} + BW_PASSWORD: ${{ secrets.BW_PASSWORD }} + BW_VOICE_APPLICATION_ID: ${{ secrets.BW_VOICE_APPLICATION_ID }} + BW_MESSAGING_APPLICATION_ID: ${{ secrets.BW_MESSAGING_APPLICATION_ID }} + BW_NUMBER: ${{ secrets.BW_NUMBER }} + USER_NUMBER: ${{ secrets.USER_NUMBER }} + BASE_CALLBACK_URL: ${{ secrets.BASE_CALLBACK_URL }} + run: python -m pytest --pyargs bandwidth + + - name: Deploy to PYPI + run: | + pip install twine + pip install wheel + python setup.py sdist bdist_wheel + twine upload dist/* -u $PYPI_USERNAME -p $PYPI_PASSWORD + env: + PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + + - uses: Bandwidth/build-notify-slack-action@v1.0.0 + if: always() + with: + job-status: ${{ job.status }} + slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} + slack-channel: ${{ secrets.SLACK_CHANNEL }} diff --git a/setup.py b/setup.py index ffbccfb6..51ae8e51 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,11 @@ # -*- coding: utf-8 -*- +import os import sys from setuptools import setup, find_packages +VERSION = os.environ['RELEASE_VERSION'] + if sys.version_info[0] < 3: with open('README.md', 'r') as fh: long_description = fh.read() @@ -15,7 +18,7 @@ setup( name='bandwidth-sdk', - version='14.3.0', + version=VERSION, description='Bandwidth\'s set of APIs', long_description=long_description, long_description_content_type="text/markdown", From 25a2e22913f9bfb010b46f58f7972fd58270313d Mon Sep 17 00:00:00 2001 From: AJ Rice <53190766+ajrice6713@users.noreply.github.com> Date: Fri, 18 Nov 2022 15:13:30 -0500 Subject: [PATCH 2/2] Use `tags` instead of wildcard rename `test.yaml` to 'test.yml' --- .github/workflows/deploy.yml | 4 ++-- .github/workflows/{test.yaml => test.yml} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{test.yaml => test.yml} (100%) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e42a7b26..ef532fe1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -33,7 +33,7 @@ jobs: BW_NUMBER_PROVIDER: ${{ secrets.BW_NUMBER_PROVIDER }} steps: - name: Set Release Version - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV - name: Check Release Tag Format run: | @@ -82,7 +82,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Set Release Version - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV - name: Check Release Tag Format run: | diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yml similarity index 100% rename from .github/workflows/test.yaml rename to .github/workflows/test.yml