Skip to content

Commit

Permalink
Add an action to publish wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
peytondmurray committed May 21, 2024
1 parent deb80f4 commit 3afa5e9
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 42 deletions.
99 changes: 58 additions & 41 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,62 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Release Package
name: Publish to PyPI

on:
push:
tags:
- '*'
pull_request:
workflow_dispatch:
release:
types: [published]

jobs:
release-tag:
name: 'Tagged Release'
runs-on: 'ubuntu-latest'
steps:
- name: Create a new GitHub release
uses: 'marvinpinto/action-automatic-releases@latest'
with:
repo_token: '${{ secrets.GITHUB_TOKEN }}'
prerelease: false

release-to-pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
build:
name: >
build ${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }}
${{ (matrix.arch) || '' }}
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows, macos]
python-version: ['cp312', 'cp311']

runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'

- uses: pypa/cibuildwheel@v2.17.0
env:
CIBW_BUILD: '${{ matrix.python-version }}-*'
CIBW_ARCHS: ${{ matrix.arch || 'auto' }}

- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.python-version }}
path: ./wheelhouse/*.whl

upload:
name: Upload wheels to PYPI
runs-on: ubuntu-latest
if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags')) || (github.event_name == 'workflow_dispatch')
needs: [build_wheels, build_sdist]
environment:
name: pypi
url: https://pypi.org/p/pyforc
permissions:
id-token: write
steps:
- name: Retrieve wheels and sdist
uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: wheels/

- name: List all built wheels
run: |
ls -lAs wheels/
- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.8
with:
packages_dir: wheels/
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,22 @@ FORC analysis in Python.

## Installation

Install by cloning this repo and running
### Install from PyPI

The easiest way to get started is by installing via `pip`:

`pip install pyforc`

This will grab the latest published release on the Python Package Index and
install it to your current python environment.

### Installation from source

Install from source by doing

`pip install git+https://github.com/peytondmurray/pyforc`

Alternatively you can clone this repo and run

`pip install .`

Expand Down

0 comments on commit 3afa5e9

Please sign in to comment.