Skip to content

Commit

Permalink
Add a GitHub Actions workflow for automatic PyPi publishing whenever …
Browse files Browse the repository at this point in the history
…creating a new release
  • Loading branch information
dormrod committed Oct 9, 2024
1 parent a4d1d79 commit d0b9339
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 42 deletions.
42 changes: 0 additions & 42 deletions .github/workflows/main.yml

This file was deleted.

94 changes: 94 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Publish to PyPi

on:
release:
types: [published]

jobs:
build-package:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build package
run: python setup.py sdist bdist_wheel

- name: Upload package artifact
uses: actions/upload-artifact@v4
with:
name: package
path: dist

test-package:
needs: build-package

strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ "3.8", "3.9", "3.10", "3.11" ]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set Up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Download package artifact
uses: actions/download-artifact@v4
with:
name: package
path: dist

- name: Install package and dependencies
run: |
python -m pip install --upgrade pip
pip install dist/plams-*.whl
pip install ".[chem_tools,results]"
pip install pytest
- name: Run Unit Tests
run: |
pytest unit_tests
publish-package:
runs-on: ubuntu-latest

needs: test-package

environment: release

permissions:
id-token: write

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Download package artifact
uses: actions/download-artifact@v4
with:
name: package
path: dist

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1

0 comments on commit d0b9339

Please sign in to comment.