Skip to content

Commit

Permalink
Add release ci (#8)
Browse files Browse the repository at this point in the history
* feat: Add GitHub workflows for building and publishing Python package distributions
  • Loading branch information
Nitnelav authored Jul 26, 2024
1 parent 3b94e57 commit b087a7e
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 19 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/
30 changes: 30 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Publish package to PyPi

on:
release:
types: [published]
workflow_dispatch:

jobs:
test:
uses: ./.github/workflows/test.yml
build:
uses: ./.github/workflows/build-dist.yml
publish-to-pypi:
name: Publish 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:
# branches:
# - 'main'
workflow_dispatch:

jobs:
test:
uses: ./.github/workflows/test.yml
build:
uses: ./.github/workflows/build-dist.yml
publish-to-testpypi:
name: Publish to TestPyPI
needs: [test, 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/
8 changes: 5 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Run Unit Test via Pytest
name: Test package

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

jobs:
build:
test-pytest:
name: Test with Pytest

runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi"

[project]
name = "acoustic-toolbox"
version = "0.1.0"
version = "0.1.1"
authors = [
{ name = "Valentin LE BESCOND", email = "[email protected]" }
]
Expand Down
15 changes: 0 additions & 15 deletions setup.cfg

This file was deleted.

0 comments on commit b087a7e

Please sign in to comment.