зеркало из
https://github.com/VIGINUM-FR/D3lta.git
synced 2025-10-29 13:06:10 +02:00
87 строки
2.4 KiB
YAML
87 строки
2.4 KiB
YAML
# derived from https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#the-whole-ci-cd-workflow
|
|
name: Publish Python distribution to PyPI
|
|
|
|
on:
|
|
release:
|
|
types: [published]
|
|
|
|
jobs:
|
|
build:
|
|
name: Build distribution
|
|
# based on https://stackoverflow.com/a/74318141
|
|
if: ${{ github.event.release.target_commitish == 'main'}}
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
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: Store the distribution packages
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: distfiles
|
|
path: dist/
|
|
if-no-files-found: error
|
|
|
|
# taken from https://github.com/python-poetry/poetry/blob/b580e8aa4fbce53569420e7b42568dfd9e73519f/.github/workflows/release.yaml
|
|
upload-built-distribution-to-github-release:
|
|
name: Upload (GitHub)
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
needs: build
|
|
steps:
|
|
# Checking-out the project since the gh CLI expects to be called in the context of a git repository.
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Retrieve built distribution
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: distfiles
|
|
path: dist/
|
|
|
|
- run: gh release upload "${TAG_NAME}" dist/*.{tar.gz,whl}
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
TAG_NAME: ${{ github.event.release.tag_name }}
|
|
|
|
publish-to-pypi:
|
|
name: Publish Python distribution to PyPI
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: pypi
|
|
url: https://pypi.org/p/d3lta # pypi is case insensitive so d3lta == D3lta
|
|
permissions:
|
|
id-token: write # IMPORTANT: mandatory for trusted publishing
|
|
|
|
steps:
|
|
- name: Retrieve built distribution
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: distfiles
|
|
path: dist/
|
|
|
|
- name: Publish distribution to PyPI
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
with:
|
|
print-hash: true
|