From 98af41cbd40184d9b50e480c7707c170494189fc Mon Sep 17 00:00:00 2001 From: Mostapha Date: Wed, 3 Feb 2021 20:32:02 -0500 Subject: [PATCH] build(ci): add semantic versioning and deployment to PYPI --- .github/workflows/ci.yaml | 31 +++++++++++++++++++++++++++++++ .releaserc.json | 13 +++++++++++++ deploy.sh | 6 ++++++ 3 files changed, 50 insertions(+) create mode 100644 .releaserc.json create mode 100644 deploy.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9854ddd..9277383 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,3 +24,34 @@ jobs: pip install -r dev-requirements.txt - name: run tests run: python -m pytest tests/ + + deploy: + name: Deploy to GitHub and PyPI + runs-on: ubuntu-latest + needs: test + if: github.ref == 'refs/heads/master' && github.repository_owner == 'pollination' + steps: + - uses: actions/checkout@v2 + - name: set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: set up node # we need node for for semantic release + uses: actions/setup-node@v2.1.2 + with: + node-version: 14.2.0 + - name: install python dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install -r dev-requirements.txt + - name: install semantic-release + run: + npm install @semantic-release/exec + - name: run semantic release + run: + npx semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PYPI_USERNAME: ${{ secrets.POLLINATION_PYPI_USERNAME }} + PYPI_PASSWORD: ${{ secrets.POLLINATION_PYPI_PASSWORD }} diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..0459b65 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,13 @@ +{ + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/github", + [ + "@semantic-release/exec", + { + "publishCmd": "bash deploy.sh" + } + ] + ] +} diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..057a123 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +echo "Building distribution" +python setup.py sdist bdist_wheel +echo "Pushing new version to PyPi" +twine upload dist/* -u $PYPI_USERNAME -p $PYPI_PASSWORD