Skip to content

Merge pull request #443 from alchemistry/update-deploy-workflow #176

Merge pull request #443 from alchemistry/update-deploy-workflow

Merge pull request #443 from alchemistry/update-deploy-workflow #176

Workflow file for this run

name: Build and upload to PyPI
on:
push:
branches:
- master
tags:
- "*"
release:
types:
- published
concurrency:
group: "${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }}"
cancel-in-progress: true
defaults:
run:
shell: bash -l {0}
jobs:
build:
name: Build distribution packages πŸ“¦
if: "github.repository == 'alchemistry/alchemlyb'"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install build dependencies
run: |
python -m pip install build
- name: build source and wheel distribution packages
run: |
python -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
name: "PyPI: Publish Python 🐍 distribution πŸ“¦"
# only publish to PyPi for releases
if: |
github.repository == 'alchemistry/alchemlyb' &&
(github.event_name == 'release' && github.event.action == 'published')
needs:
- build
runs-on: ubuntu-latest
environment:
name: deploy
url: https://pypi.org/p/alchemlyb
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution πŸ“¦ to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
publish-to-testpypi:
name: "TestPyPI: Publish Python 🐍 distribution πŸ“¦"
# publish to TesPyPi for tags
if: |
github.repository == 'alchemistry/alchemlyb' &&
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
needs:
- build
runs-on: ubuntu-latest
environment:
name: deploy
url: https://test.pypi.org/p/alchemlyb
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution πŸ“¦ to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
verbose: true