generated from childmindresearch/template-python-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (41 loc) · 1.08 KB
/
pypi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: Publish to PyPi
permissions:
actions: write
on:
workflow_run:
workflows: [Python Tests]
types:
- completed
branches:
- main
jobs:
pypi-release:
name: PyPi Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml
- name: Skip if version did not change.
run: |
version_change=$(git diff -r HEAD^1 pyproject.toml | grep -E "^(\+|-)version =")
if [[ -z "$version_change" ]]; then
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build package.
run: |
pipx install poetry
poetry install --only main
poetry build
- name: Publish to PyPi.
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
verbose: true