From 26b0c7321c85ed77778fa974f50b71ab710b3ec0 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Thu, 7 Dec 2023 13:13:45 -0500 Subject: [PATCH] create publish/release workflow --- .github/workflows/publish.yml | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..164fe584 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,53 @@ +name: Release + +on: + # NOTE: PR trigger is to ensure changes do not break packaging. + pull_request: + release: + types: [released] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-n-publish: + name: Build and publish Python 🐍 distributions 📦 to PyPI + runs-on: ubuntu-latest + if: github.repository == 'spacetelescope/lcviz' + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-python@v4 + with: + python-version: 3.9 + + - name: Install python-build and twine + run: python -m pip install build "twine>=3.3" + + - name: Build package + run: python -m build --sdist --wheel . + + - name: List result + run: ls -l dist + + - name: Check dist + run: python -m twine check --strict dist/* + + - name: Test package + run: | + cd .. + python -m venv testenv + testenv/bin/pip install pytest pytest-astropy pytest-tornasync lcviz/dist/*.whl + testenv/bin/python -c "import lcviz; lcviz.test(remote_data=True)" + + # NOTE: Do not run this part for PR testing. + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + if: github.event_name != 'pull_request' + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }}