Merge pull request #13 from ButterCMS/fix/enable-publish-flow #3
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
# This workflow will publish a package to both TestPyPi and PyPi when a release is created | |
name: Test & Build & Publish to Pypi | |
on: | |
push: | |
branches: [ master ] | |
jobs: | |
build: | |
if: contains(github.event.head_commit.message, 'chore(release)') | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout code | |
uses: actions/[email protected] | |
- name: Set up Python | |
uses: actions/[email protected] | |
with: | |
python-version: '3.12' | |
- name: Install dependencies | |
run: pip install -r requirements.txt | |
- name: Install pypa/build | |
run: >- | |
python3 -m | |
pip install | |
build | |
--user | |
- name: Build a binary wheel and a source tarball | |
run: python3 -m build | |
- name: Store the distribution packages | |
uses: actions/[email protected] | |
with: | |
name: python-package-distributions | |
path: dist/ | |
publish-to-test-pypi: | |
name: >- | |
Publish to Test PyPI | |
needs: | |
- build | |
if: contains(github.event.head_commit.message, 'chore(release)') | |
runs-on: ubuntu-22.04 | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/p/buttercms-python | |
permissions: | |
id-token: write | |
steps: | |
- name: Download all the dists | |
uses: actions/[email protected] | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution 📦 to Test PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1.8 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
publish-to-pypi: | |
name: >- | |
Publish to PyPI | |
needs: | |
- publish-to-test-pypi | |
if: contains(github.event.head_commit.message, 'chore(release)') | |
runs-on: ubuntu-22.04 | |
environment: | |
name: pypi | |
url: https://pypi.org/p/buttercms-python | |
permissions: | |
id-token: write | |
steps: | |
- name: Download all the dists | |
uses: actions/[email protected] | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution 📦 to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1.8 |