Skip to content

Commit 9c29d46

Browse files
jaymedinafalkben
andauthored
Use GitHub Actions for publishing new releases to PyPI (#97)
* Initial commit: Template PyPI publishing workflow YML * Changing repository_owner name * . * Updating owner name * Adding long_description and long_description_type to setup.py * README ext typo * Upload to test-pypi on every commit * Removing github repo owner conditional for test-pypi publication * Removing repository URL * Changing event to pull_request for test pypi release * Adding repository-url back into test job, and github.repo_owner * Adding a tag * . * . * Adding skip_existing=True for test-pypi release because I dont care about duplicate releases on test-pypi as I troubleshoot * using kebab-case * . * . * Adding conditional to test-pypi job to only release after merge to main * Removing unnecessary string manipulation on setup.py * Renaming for clarity * . * . * changing event_name * typo in tags name * Reverting test-pypi job to trigger on merge to main * Changing long_description_content_type * Rewritten workflow incorporating OpenAstronomy publishing github action * Removing upload_to_pypi arg and moving over a set of comments * Adding permissions * . * Testing make_tag job * Adding a delete_tag job; renaming jobs; adding comments; etc * Testing make_and_push_tag * . * Adding checkout option * changing actions/checkout version * . * . * Attempting to push tag with another gh action * Changing fetch depth * . * Updating permissions * if: always() for delete_tag * Updating comments. Fixing delete_tag * Removing local deletion of * . * fetching tags before deletion * . * publish_pure_python * Add github token * Modifying upload_to_pypi for both major jobs * Removing upload_to_pypi since default is refs/tags/v * Editing upload_to_pypi for test.pypi job * . * Just forcing an upload to test-pypi * . * . * adding secrets * echo * . * reverting to only release to test.pypi when merge to main * Reverted to a simple workflow to build, test, and publish to pypi * Making the job get triggered for tags created and pushed that start with v * Updates test_extras and test_command. removed trigger to run when branch is pushed. * Ignore tags with dev, pre, post in the name * typo * Removing ignore-tags lines * adding secrets credentials * Removing id-token write perm * Updating test_command * adding pyargs * Changing secret to PYPI_TOKEN, the API Token I generated on PyPI * Updated readme * Ben readme suggestions Co-authored-by: Ben Falk <653031+falkben@users.noreply.github.com> --------- Co-authored-by: Ben Falk <653031+falkben@users.noreply.github.com>
1 parent ff133b4 commit 9c29d46

File tree

3 files changed

+47
-6
lines changed

3 files changed

+47
-6
lines changed

.github/workflows/pypi-package.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Building & Publishing
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
13+
# Release to PyPI after a RELEASE gets PUBLISHED in @spacetelescope/astrocut/main
14+
publish-to-pypi:
15+
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@v1
16+
name: Publish to PyPI
17+
18+
# We only want to upload to PyPI after a new release has been published on the @spacetelescope/astrocut repo
19+
if: github.repository_owner == 'spacetelescope' && github.event_name == 'push'
20+
with:
21+
test_extras: test
22+
test_command: pytest --pyargs astrocut
23+
secrets:
24+
pypi_token: ${{ secrets.PYPI_TOKEN }}

README.rst

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Developer Documentation
3838
-----------------------
3939

4040
Installation
41-
^^^^^^^^^^^^
41+
============
4242

4343
.. code-block:: bash
4444
@@ -53,7 +53,7 @@ For active developement intall in develop mode
5353
$ pip install -e .
5454
5555
Testing
56-
^^^^^^^
56+
=======
5757
Testing is now run with `tox <https://tox.readthedocs.io>`_ (``pip install tox``).
5858
Tests can be found in ``astrocut/tests/``.
5959

@@ -69,7 +69,7 @@ Tests can also be run directly with pytest:
6969
$ pytest
7070
7171
Documentation
72-
^^^^^^^^^^^^^
72+
=============
7373
Documentation files are found in ``docs/``.
7474

7575
We now build the documentation with `tox <https://tox.readthedocs.io>`_ (``pip install tox``):
@@ -90,9 +90,18 @@ The built docs will be in ``docs/_build/html/``, to view them go to ``file:///pa
9090

9191

9292
Release Protocol
93-
^^^^^^^^^^^^^^^^
93+
================
9494

95-
Follow the `Astropy template release instructions <https://docs.astropy.org/en/latest/development/astropy-package-template.html>`_.
95+
GitHub Action Releases
96+
^^^^^^^^^^^^^^^^^^
97+
98+
The `pypi-package.yml <.github/workflows/pypi-package.yml>`_ GitHub workflow creates a PyPI release. The job in this workflow is triggered when a tag is pushed or a GH release (+tag) is created, and uses `OpenAstronomy`'s `GitHub action workflow <https://github.com/OpenAstronomy/github-actions-workflows>`_
99+
for publishing pure Python packages (`see here <https://github-actions-workflows.openastronomy.org/en/stable/publish_pure_python.html>`_ for documentation).
100+
101+
Manual Releases
102+
^^^^^^^^^^^^^^^
103+
104+
For making releases manually, follow the `Astropy template release instructions <https://docs.astropy.org/en/latest/development/astropy-package-template.html>`_.
96105

97106
*Requirements:*
98107

setup.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,13 @@
7474
version = '{version}'
7575
""".lstrip()
7676

77+
current_path = os.path.abspath(os.path.dirname(__file__))
78+
79+
def read_file(*parts):
80+
with open(os.path.join(current_path, *parts), encoding='utf-8') as reader:
81+
return reader.read()
82+
7783
setup(use_scm_version={'write_to': os.path.join('astrocut', 'version.py'),
78-
'write_to_template': VERSION_TEMPLATE})
84+
'write_to_template': VERSION_TEMPLATE},
85+
long_description=read_file('README.rst'),
86+
long_description_content_type='text/x-rst')

0 commit comments

Comments
 (0)