Skip to content

Bump actions/upload-artifact from 5 to 7 (#45) #34

Bump actions/upload-artifact from 5 to 7 (#45)

Bump actions/upload-artifact from 5 to 7 (#45) #34

name: Build and publish Python package on PyPI for releases
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
release:
types:
- published
jobs:
build:
name: Build distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Upload the distribution packages as artifacts
uses: actions/upload-artifact@v7
with:
name: python-package-distributions
path: dist/
test-pypi-publish:
name: Upload release to Test PyPI
needs: [build]
runs-on: ubuntu-latest
environment:
name: test-pypi
url: https://test.pypi.org/p/mici
permissions:
id-token: write
if: |
(github.event_name == 'release' && github.event.action == 'published') ||
(github.event_name == 'push' && github.ref == 'refs/heads/main')
steps:
- name: Download distribution packages
uses: actions/download-artifact@v8
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
pypi-publish:
name: Upload release to PyPI
needs: [build, test-pypi-publish]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/mici
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Download distribution packages
uses: actions/download-artifact@v8
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1