Skip to content

Commit

Permalink
feat: Add GitHub workflows for building and publishing Python package…
Browse files Browse the repository at this point in the history
… distributions
  • Loading branch information
Nitnelav committed Jul 26, 2024
1 parent 3b94e57 commit f51bf93
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 17 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build package

on: [workflow_call]

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- 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/upload-artifact@v3
with:
name: python-package-distributions
path: dist/
28 changes: 28 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish package to PyPi

on: [push, workflow_call]

jobs:
test:
uses: ./.github/workflows/test.yml
build:
uses: ./.github/workflows/build-dist.yml
publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs: [test, build]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/acoustic-tools
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
32 changes: 32 additions & 0 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish package to TestPyPi

on: [push, workflow_call]

jobs:
test:
uses: ./.github/workflows/test.yml
build:
uses: ./.github/workflows/build-dist.yml
publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/acoustic-tools

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Run Unit Test via Pytest
name: Test package

on: [push]
on: [push, workflow_call]

jobs:
build:
Expand Down
15 changes: 0 additions & 15 deletions setup.cfg

This file was deleted.

0 comments on commit f51bf93

Please sign in to comment.