From 3f74711f64dacb4154e3a3429b7d16634c145284 Mon Sep 17 00:00:00 2001 From: Steven Wu Date: Wed, 11 Dec 2024 11:59:25 -0500 Subject: [PATCH 1/3] ci: update workflows --- .github/workflows/publish.yml | 50 ++++++++++++++++++++++++++++++++ .github/workflows/unit-tests.yml | 3 +- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..2ed9e24 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,50 @@ +name: Publish to PyPI + +on: + push: + branches: + - main + tags: + - "*" + + +jobs: + build: + name: Build package + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: 3.12 + + - name: Install dependencies + run: | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Build package + run: python3 -m build + + - name: Upload build + uses: actions/upload-artifact@v4 + with: + path: dist/* + + pypi-publish: + name: Upload release to PyPI + needs: [ "build" ] + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write + + steps: + - uses: actions/download-artifact@v4 + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages_dir: artifact/* \ No newline at end of file diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 556245c..b678a90 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -8,7 +8,6 @@ on: jobs: build: - runs-on: ubuntu-latest strategy: fail-fast: false @@ -19,7 +18,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} From 33f5f1d322affc88178a0cc8c9cb034c9b3ca557 Mon Sep 17 00:00:00 2001 From: Steven Wu Date: Wed, 11 Dec 2024 12:02:23 -0500 Subject: [PATCH 2/3] style: clean --- .github/workflows/publish.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2ed9e24..82ac533 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,7 +7,6 @@ on: tags: - "*" - jobs: build: name: Build package From 42f4b76960ce9fbd992f09d2a890f09f79f9ae79 Mon Sep 17 00:00:00 2001 From: Steven Wu Date: Fri, 13 Dec 2024 09:20:08 -0500 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Mike Bender --- .github/workflows/publish.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 82ac533..7ba98ec 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,10 +2,8 @@ name: Publish to PyPI on: push: - branches: - - main tags: - - "*" + - '[0-9]+.[0-9]+.[0-9]+' jobs: build: @@ -31,6 +29,7 @@ jobs: uses: actions/upload-artifact@v4 with: path: dist/* + if-no-files-found: error pypi-publish: name: Upload release to PyPI