Skip to content

Commit

Permalink
Merge pull request #632 from macs3-project/feat/macs3/pypi_trusted_pu…
Browse files Browse the repository at this point in the history
…blishing

Use trusted publishing to upload package to pypi
  • Loading branch information
taoliu authored Mar 2, 2024
2 parents 34f9a81 + ec8f2c5 commit cf0a344
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,36 @@ on:
types: [published]

jobs:
deploy:
release:
name: Upload release to PyPI
runs-on: ubuntu-latest

environment:
name: release
url: https://pypi.org/p/macs3
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Check out MACS3 with submodules
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
if [ -f requirements.txt ]; then python3 -m pip install --upgrade -r requirements.txt; fi
# setuptools, wheel and twine are needed to upload to pypi
python3 -m pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python3 setup.py sdist
python3 -m twine upload dist/*
# retrieve your distributions here
- name: Check out MACS3 with submodules
uses: actions/checkout@v4
with:
submodules: 'true'

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

# Here we build sdist in this job. If we plan to build wheels
# and upload to PyPI, we need another job to build wheels, and
# collect artifacts in this step...
- name: Build sdist
run: |
python3 -m pip install --upgrade pip
# install build system
python3 -m pip install build
# make source distribution
python3 -m build --sdist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

0 comments on commit cf0a344

Please sign in to comment.