Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add continuous deployment workflow for PyPI publication #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Publish to PyPI

on:
release:
types: [published]

jobs:
run-tests:
name: Run tests to avoid a broken release
uses: BIMAU/transiflow/.github/workflows/ci.yml@master

build:
name: Build packages
runs-on: ubuntu-latest
needs:
- run-tests

steps:
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: '>=3.8,<4'

- name: Check out the source code
uses: actions/checkout@v3

- name: Build a source package and a wheel
run: python -m build .

- name: Upload packages as artifact
uses: actions/upload-artifact@v4
with:
name: packages-for-pypi
path: dist/

publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs:
- build

environment:
name: pypi
url: https://pypi.org/p/transiflow

permissions:
id-token: write

steps:
- name: Download artifact with packages
uses: actions/download-artifact@v4
with:
name: packages-for-pypi
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_call:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just to support uses: above?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you need to add that apparently to make it so that you can call the workflow from another one. It's called a reusable workflow: https://docs.github.com/en/actions/using-workflows/reusing-workflows


jobs:
build:
Expand Down
Loading