Skip to content

Commit

Permalink
Merge pull request #317 from tovrstra/pypi
Browse files Browse the repository at this point in the history
Add PyPI release workflow
  • Loading branch information
tovrstra authored Jun 4, 2024
2 parents a9e209d + c56a117 commit d82917a
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 60 deletions.
128 changes: 128 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# This workflow is adapted from:
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
# Changed made:
# - Remove emoticons
# - Update some actions to more recent versions

name: release

on: push

env:
# This is not critical
# It is used only for showing URLs in GitHub Actions web interface.
PYPI_NAME: qc-iodata

jobs:
build:
name: Build distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install pypa/build
run: >-
python -m pip install build
- name: Build package
run: >-
python -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: Publish Python distribution to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/${{ env.PYPI_NAME }}
permissions:
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 PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: >-
Sign the Python distribution with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest

permissions:
contents: write
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v2.1.1
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
publish-to-testpypi:
name: Publish Python distribution to TestPyPI
if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'reproducible-reporting'}}
needs:
- build
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/${{ env.PYPI_NAME }}

permissions:
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/
30 changes: 13 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
IOData
======
|GithubActions|
|Conda|
|Pypi|
|Codecov|
|pytest|
|release|
|CodeFactor|
|PyPI|
|Version|
|CondaVersion|
|License|


Expand Down Expand Up @@ -85,17 +84,14 @@ environment. Note that there may be API changes between subsequent revisions.

See https://iodata.readthedocs.io/en/latest/install.html for full details.


.. |GithubActions| image:: https://github.com/theochem/iodata/actions/workflows/ci.yml/badge.svg?branch=master
:target: https://github.com/theochem/iodata/actions/workflows/ci.yml
.. |Version| image:: https://img.shields.io/pypi/pyversions/iodata.svg
.. |pytest| image:: https://github.com/theochem/iodata/actions/workflows/pytest.yml/badge.svg
:target: https://github.com/theochem/iodata/actions/workflows/pytest.yml
.. |release| image:: https://github.com/theochem/iodata/actions/workflows/release.yml/badge.svg
:target: https://github.com/theochem/iodata/actions/workflows/release.yml
.. |CodeFactor| image:: https://www.codefactor.io/repository/github/tovrstra/stepup-core/badge
:target: https://www.codefactor.io/repository/github/tovrstra/stepup-core
.. |Version| image:: https://img.shields.io/pypi/pyversions/qc-iodata.svg
.. |License| image:: https://img.shields.io/github/license/theochem/iodata
.. |Pypi| image:: https://img.shields.io/pypi/v/iodata.svg
:target: https://pypi.python.org/pypi/iodata/0.1.3
.. |Codecov| image:: https://img.shields.io/codecov/c/github/theochem/iodata/master.svg
:target: https://codecov.io/gh/theochem/iodata
.. |Conda| image:: https://img.shields.io/conda/v/theochem/iodata.svg
:target: https://anaconda.org/theochem/iodata
.. |CondaVersion| image:: https://img.shields.io/conda/pn/theochem/iodata.svg
:target: https://anaconda.org/theochem/iodata
.. |PyPI| image:: https://img.shields.io/pypi/v/qc-iodata.svg
:target: https://pypi.python.org/pypi/qc-iodata/
.. _virtual environment: https://docs.python.org/3/tutorial/venv.html
43 changes: 0 additions & 43 deletions tools/conda.recipe/meta.yaml

This file was deleted.

0 comments on commit d82917a

Please sign in to comment.