-
-
Notifications
You must be signed in to change notification settings - Fork 270
49 lines (47 loc) · 1.47 KB
/
publish.yml
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
49
name: Publish Python 🐍 distributions 📦 to PyPI
on:
push:
branches:
- main
jobs:
pypi-publish:
name: upload release to PyPI
runs-on: ubuntu-latest
# Specifying a GitHub environment is optional, but strongly encouraged
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# retrieve your distributions here
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools wheel twine build setuptools-scm
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
- name: Check for VERSION file change
id: version_changed
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
echo "changed=false" >> $GITHUB_ENV
if echo "${ALL_CHANGED_FILES}" | grep -q 'VERSION'; then
echo "changed=true" >> $GITHUB_ENV
fi
- name: Build
if: env.changed == 'true'
run: |
python -m build
- name: Publish package distributions to PyPI
if: env.changed == 'true'
uses: pypa/gh-action-pypi-publish@release/v1