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 9b81590 commit 103a954
Showing 1 changed file with 51 additions and 34 deletions.
85 changes: 51 additions & 34 deletions .github/workflows/publication_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
types: [published]

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

steps:
Expand All @@ -26,47 +26,64 @@ jobs:
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
if: github.repository_owner == 'ctlab'

- name: Build sdist
shell: bash
run: |
python -m pip install --upgrade pip build
python -m build -s .
- name: Install pypa/build
run: python3 -m pip install build --user

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

- name: Upload sdist
- name: Build a binary wheel and a source tarball
run: python3 -m build

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

manylinux2_28_test:
name: Build package from source dist
publish-to-pypi:
name: Publish distribution 📦 to PyPI
if: github.repository_owner == 'ctlab' && github.event.release
needs:
- build
runs-on: ubuntu-latest
needs: ['build_sdist']
strategy:
matrix:
python: [3.8, 3.9, "3.10"]
environment:
name: publish-pypi
url: https://pypi.org/p/gadma
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
pypi-publish:
name: Upload to TestPyPI
- 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

publish-to-testpypi:
name: Publish distribution 📦 to TestPyPI
if: github.repository_owner == 'ctlab'
needs:
- build
runs-on: ubuntu-latest
needs: ['manylinux2_28_test']

environment:
name: publish-testpypi
url: https://test.pypi.org/p/gadma

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

steps:
- name: Download all
uses: actions/[email protected]

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

0 comments on commit 103a954

Please sign in to comment.