Skip to content

Commit

Permalink
Add script to automatically publish new releases to PyPI (#114)
Browse files Browse the repository at this point in the history
* Add script to automatically publish new releases to PyPI

* Fix formatting

* Incorporate review comments

* Remove instructions to upload to PyPI
  • Loading branch information
RemiLehe authored Jul 19, 2024
1 parent 856923c commit 5a2594a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish package to PyPI

on:
release:
types: [created]

jobs:
build-n-publish:
name: Build and publish package to PyPI
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python3 -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish package distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
11 changes: 0 additions & 11 deletions PICMI_Python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,3 @@ Change the tag number as needed to match the version number.

Now, go to the [GitHub releases page](https://github.com/picmi-standard/picmi/releases) and create a release matching the pushed tag.
If you are not signing your tags with GPG keys, the tagging and GitHub release can also be done in one step on this page.

The final step is to update the version on PyPI. It is recommended to use the twine command. Here are the commands (run from the main directory since this uses the pyproject.toml file):

```
python -m build --sdist --wheel
twine upload dist/*
```

The first builds the distribution, the second uploads it. Note that it is good practice to delete the dist directory
afterwards so that each time uploads only the most recent version.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The goal of the standard is to propose a set (or dictionary) of names and defini

Just as two persons do generally not use the exact same set of words from a dictionary (whatever the language), each code will use syntax (associated with unique functionalities of the code) that others will not. However, it is expected that, just like two persons will use and understand the same words and syntax for the most common topics, codes will share the same language for common definitions and tasks.

For example, it is expected that most PIC codes can share the same syntax to define a grid, a commonly-used field solver, a set of particles, etc. On the other hand, only a subset of the codes will offer, e.g. mesh refinement, field ionization, or code steering by the user. In this case, it is up to the implementation with each code to decide whether to ignore, raise a warning or an error, when an undefined statement is encountered. For more flexibility and robustness, conditional statements are available to the user to execute or read lines of the input script, based on the targeted code.
For example, it is expected that most PIC codes can share the same syntax to define a grid, a commonly-used field solver, a set of particles, etc. On the other hand, only a subset of the codes will offer, e.g. mesh refinement, field ionization, or code steering by the user. In this case, it is up to the implementation with each code to decide whether to ignore, raise a warning or an error, when an undefined statement is encountered. For more flexibility and robustness, conditional statements are available to the user to execute or read lines of the input script, based on the targeted code.

The intent is for the standard to be agnostic of the language of implementation, which can then potentially be performed using JSON, Python, FORTRAN or other means.

Expand All @@ -27,6 +27,7 @@ This repository contains:
```
python -m pip install .
```
(The code will be automatically uploaded to PyPI upon creation of a new release on Github.)

- The sources to generate the **Sphinx documentation** for the PICMI standard (in the directory `Docs`). In order to generate the Sphinx documentation, first install [Sphinx](http://www.sphinx-doc.org/en/master/), as well as the version of the PICMI standard that you would like to document (e.g. via `python setup.py`). Then type:
```
Expand Down

0 comments on commit 5a2594a

Please sign in to comment.