Skip to content

Publish to PyPI

Publish to PyPI #54

name: Publish to PyPI
on:
workflow_dispatch:
inputs:
dryRun:
description: 'Do a dry run to preview instead of a real release'
required: true
default: 'true'
jobs:
authorize:
name: Authorize
runs-on: ubuntu-latest
steps:
- name: ${{ github.actor }} permission check to do a release
uses: "lannonbr/[email protected]"
with:
permission: "write"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-n-publish:
environment: Unit Test
name: Build and publish to PyPI
runs-on: ubuntu-latest
needs: [authorize]
steps:
- name: Checkout for release to PyPI
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.7
uses: actions/setup-python@v3
with:
python-version: 3.7
- name: Install dependencies
run: python -m pip install build setuptools wheel twine amplitude_analytics parameterized python-dotenv~=0.21.1 python-semantic-release==7.34.6
- name: Run Test
env:
API_KEY: ${{ secrets.API_KEY }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
EU_API_KEY: ${{ secrets.EU_API_KEY }}
EU_SECRET_KEY: ${{ secrets.EU_SECRET_KEY }}
run: python -m unittest discover -s ./tests -p '*_test.py'
- name: Publish distribution PyPI --dry-run
if: ${{ github.event.inputs.dryRun == 'true'}}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
semantic-release publish --noop
- name: Publish distribution PyPI
if: ${{ github.event.inputs.dryRun == 'false'}}
run: |
git config user.name amplitude-sdk-bot
git config user.email [email protected]
semantic-release publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY_USERNAME: __token__
REPOSITORY_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}