Skip to content

Commit

Permalink
Update publishing to Pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
noscode committed Nov 6, 2024
1 parent 6d45fa9 commit 61b2fd0
Showing 1 changed file with 52 additions and 51 deletions.
103 changes: 52 additions & 51 deletions .github/workflows/publication_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ on:
types: [published]

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

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -26,64 +25,66 @@ jobs:
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
if: github.repository_owner == 'ctlab'

- name: Install pypa/build
run: python3 -m pip install build --user

- name: Install pypa/build
run: python3 -m pip install build --user
- name: Build sdist
shell: bash
run: |
python -m pip install --upgrade pip build
python -m build -s .
- name: Build a binary wheel and a source tarball
run: python3 -m build

- name: Store the distribution packages
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: Publish distribution 📦 to PyPI
if: github.repository_owner == 'ctlab' && github.event.release
needs:
- build
name: sdist
path: dist

manylinux2_28:
name: Build and test Linux wheels
runs-on: ubuntu-latest
environment:
name: publish-pypi
url: https://pypi.org/p/gadma
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

publish-to-testpypi:
name: Publish distribution 📦 to TestPyPI
if: github.repository_owner == 'ctlab'
needs:
- build
runs-on: ubuntu-latest
- name: Build wheels
uses: pypa/cibuildwheel@v2.17.0

- name: Upload Wheels
uses: actions/upload-artifact@v4
with:
name: linux-wheels
path: wheelhouse

manylinux2_28_test:
name: Build package from source dist
runs-on: ubuntu-latest
needs: ['build_sdist']
strategy:
matrix:
python: [3.8, 3.9, "3.10"]
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
pypi-publish:
name: Upload to TestPyPI
runs-on: ubuntu-latest
needs: ['manylinux2_28', 'manylinux2_28_test']
environment:
name: publish-testpypi
url: https://test.pypi.org/p/gadma

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

id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
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/
- name: Download all
uses: actions/download-artifact@v4.1.4

- name: Move to dist
run: |
mkdir dist
cp */*.{whl,gz} dist/.
- name: Publish distribution to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1

0 comments on commit 61b2fd0

Please sign in to comment.