Skip to content

Commit

Permalink
Use GitHub Actions for publishing new releases to PyPI (#97)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

---------

Co-authored-by: Ben Falk <[email protected]>
  • Loading branch information
jaymedina and falkben authored Oct 6, 2023
1 parent ff133b4 commit 9c29d46
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/pypi-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Building & Publishing

on:
push:
tags:
- "v*"

permissions:
contents: read

jobs:

# Release to PyPI after a RELEASE gets PUBLISHED in @spacetelescope/astrocut/main
publish-to-pypi:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@v1
name: Publish to PyPI

# We only want to upload to PyPI after a new release has been published on the @spacetelescope/astrocut repo
if: github.repository_owner == 'spacetelescope' && github.event_name == 'push'
with:
test_extras: test
test_command: pytest --pyargs astrocut
secrets:
pypi_token: ${{ secrets.PYPI_TOKEN }}
19 changes: 14 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Developer Documentation
-----------------------

Installation
^^^^^^^^^^^^
============

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

Expand All @@ -69,7 +69,7 @@ Tests can also be run directly with pytest:
$ pytest
Documentation
^^^^^^^^^^^^^
=============
Documentation files are found in ``docs/``.

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


Release Protocol
^^^^^^^^^^^^^^^^
================

Follow the `Astropy template release instructions <https://docs.astropy.org/en/latest/development/astropy-package-template.html>`_.
GitHub Action Releases
^^^^^^^^^^^^^^^^^^

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>`_
for publishing pure Python packages (`see here <https://github-actions-workflows.openastronomy.org/en/stable/publish_pure_python.html>`_ for documentation).

Manual Releases
^^^^^^^^^^^^^^^

For making releases manually, follow the `Astropy template release instructions <https://docs.astropy.org/en/latest/development/astropy-package-template.html>`_.

*Requirements:*

Expand Down
10 changes: 9 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,13 @@
version = '{version}'
""".lstrip()

current_path = os.path.abspath(os.path.dirname(__file__))

def read_file(*parts):
with open(os.path.join(current_path, *parts), encoding='utf-8') as reader:
return reader.read()

setup(use_scm_version={'write_to': os.path.join('astrocut', 'version.py'),
'write_to_template': VERSION_TEMPLATE})
'write_to_template': VERSION_TEMPLATE},
long_description=read_file('README.rst'),
long_description_content_type='text/x-rst')

0 comments on commit 9c29d46

Please sign in to comment.