2025-02-16 10:07:22 +01:00
|
|
|
---
|
|
|
|
name: release python
|
2025-02-15 08:44:15 +01:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2025-02-16 10:07:22 +01:00
|
|
|
branches: [master]
|
2025-02-16 10:03:28 +01:00
|
|
|
tags:
|
|
|
|
- '**'
|
2025-02-15 08:44:15 +01:00
|
|
|
pull_request:
|
2025-02-16 10:07:22 +01:00
|
|
|
branches: [master]
|
|
|
|
|
2025-02-15 08:44:15 +01:00
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build_sdist:
|
|
|
|
name: Build source distribution
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2025-02-16 10:03:28 +01:00
|
|
|
- uses: actions/checkout@v3
|
2025-02-15 08:44:15 +01:00
|
|
|
|
|
|
|
- name: Build sdist
|
|
|
|
run: pipx run build --sdist
|
|
|
|
|
2025-02-16 10:03:28 +01:00
|
|
|
- uses: actions/upload-artifact@v3
|
2025-02-15 08:44:15 +01:00
|
|
|
with:
|
|
|
|
path: dist/*.tar.gz
|
|
|
|
retention-days: 5
|
|
|
|
|
2025-02-16 10:03:28 +01:00
|
|
|
upload_test_pypi:
|
|
|
|
needs: [build_sdist]
|
2025-02-15 08:44:15 +01:00
|
|
|
runs-on: ubuntu-latest
|
2025-02-16 10:03:28 +01:00
|
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
2025-02-15 08:44:15 +01:00
|
|
|
steps:
|
2025-02-16 10:03:28 +01:00
|
|
|
- uses: actions/download-artifact@v3
|
2025-02-15 08:44:15 +01:00
|
|
|
with:
|
|
|
|
name: artifact
|
|
|
|
path: dist
|
|
|
|
|
|
|
|
- name: Publish package to TestPyPI
|
2025-02-16 10:03:28 +01:00
|
|
|
uses: pypa/gh-action-pypi-publish@release/v1.5
|
2025-02-15 08:44:15 +01:00
|
|
|
with:
|
|
|
|
user: __token__
|
|
|
|
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
|
|
|
|
repository_url: https://test.pypi.org/legacy/
|
2025-02-16 10:03:28 +01:00
|
|
|
|
|
|
|
upload_pypi:
|
|
|
|
needs: [build_sdist]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
|
|
steps:
|
2025-02-16 10:05:45 +01:00
|
|
|
- name: Check if it is a release tag
|
|
|
|
id: check-tag
|
|
|
|
run: |
|
|
|
|
if [[ ${{ github.event.ref }} =~ ^refs/tags/v([0-9]+\.[0-9]+)(-rc[0-9]+)?$ ]]; then
|
|
|
|
echo ::set-output name=match::true
|
|
|
|
fi
|
|
|
|
- name: Download artifiact
|
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
if: steps.check-tag.outputs.match == 'true'
|
2025-02-16 10:03:28 +01:00
|
|
|
with:
|
|
|
|
name: artifact
|
|
|
|
path: dist
|
|
|
|
- name: Publish package to PyPI
|
|
|
|
uses: pypa/gh-action-pypi-publish@release/v1.5
|
2025-02-16 10:05:45 +01:00
|
|
|
if: steps.check-tag.outputs.match == 'true'
|
2025-02-16 10:03:28 +01:00
|
|
|
with:
|
|
|
|
user: __token__
|
|
|
|
password: ${{ secrets.PYPI_API_TOKEN }}
|