Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use GitHub Action Trusted Publisher for PyPI publishing #68

Merged
merged 3 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 27 additions & 17 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
name: Upload to PyPI and publish documentation
name: Upload package to PyPI and publish documentation

on:
release:
types: [published]
workflow_dispatch:
workflow_call:
secrets:
PYPI_USER:
required: true
PYPI_PASSWORD:
required: true

jobs:
push_to_pypi:
build:
runs-on: ubuntu-latest

steps:
Expand All @@ -26,15 +21,30 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev,cicd]"
- name: Build and publish
run: |
tox -e build
python -m twine check dist/*
python -m twine upload dist/*
env:
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
python -m pip install build==1.0.3
- name: Build distribution
run: python -m build
- name: Store distribution packages
uses: actions/upload-artifact@v4
with:
name: dist
path: ./dist

push_to_pypi:
runs-on: ubuntu-latest
needs:
- build
environment:
name: pypi
url: https://pypi.org/p/iqm-cortex-cli
permissions:
id-token: write

steps:
- name: Download distribution packages
uses: actions/download-artifact@v4
- name: Publish distribution packages to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

publish_docs:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -83,7 +93,7 @@ jobs:
pip-licenses --format=confluence --with-urls > licenses.txt
cat -n licenses.txt | sort -uk2 | sort -n | cut -f2- > tmp && mv tmp licenses.txt # remove duplicate lines
- name: Upload license information artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dependencies-licenses
path: licenses.txt
5 changes: 1 addition & 4 deletions .github/workflows/tag_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,4 @@ jobs:
# created by the above job create_tag_and_release. Here we trigger the said workflow manually.
trigger_publishing:
needs: create_tag_and_release
uses: iqm-finland/cortex-cli/.github/workflows/publish.yml@main
secrets:
PYPI_USER: ${{ secrets.PYPI_USER }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
uses: ./.github/workflows/publish.yml
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog
=========

Version 5.10
============

* Use GitHub Action as a Trusted Publisher to publish packages to PyPI. `#68 <https://github.com/iqm-finland/cortex-cli/pull/68>`_

Version 5.9
===========

Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ docs = [
"sphinx == 7.2.6",
"sphinx-book-theme == 1.1.2",
]
cicd = [
"twine == 4.0.2"
]

[project.scripts]
cortex = "iqm.cortex_cli.cortex_cli:cortex_cli"
Expand Down