Skip to content

Commit

Permalink
create publish/release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Dec 7, 2023
1 parent a9ab11d commit 26b0c73
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit 26b0c73

Please sign in to comment.