-
Notifications
You must be signed in to change notification settings - Fork 116
105 lines (89 loc) · 3.18 KB
/
publish_to_pypi.yml
File metadata and controls
105 lines (89 loc) · 3.18 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Publish archives to PyPI and TestPyPI using GitHub Actions
name: Publish to PyPI
# Only run for tagged releases and pushes to the development branch
on:
release:
types:
- published
push:
branches:
- development
# Trigger manually at https://github.com/icesat2py/icepyx/actions/workflows/publish_to_pypi.yml
workflow_dispatch:
permissions: {}
jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
# fetch all history so that setuptools-scm works
fetch-depth: 0
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.11'
- name: Install dependencies
run: python -m pip install build setuptools wheel
# This step is only necessary for testing purposes and for TestPyPI
- name: Fix up version string for TestPyPI
if: ${{ !startsWith(github.ref, 'refs/tags') }}
run: |
# Change setuptools-scm local_scheme to "no-local-version" so the
# local part of the version isn't included, making the version string
# compatible with PyPI.
sed --in-place "s/node-and-date/no-local-version/g" pyproject.toml
- name: Build source and wheel distributions
run: |
python -m build
echo ""
echo "Generated files:"
ls -lh dist/
- name: Store the distribution packages
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: python-package-distributions
path: dist/
publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
if: github.repository == 'icesat2py/icepyx'
needs:
- build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/project/icepyx
permissions:
id-token: write # IMPORTANT: mandatory for trusted OIDC publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
repository-url: https://test.pypi.org/legacy/
publish-to-pypi:
name: Publish Python 🐍 distribution 📦 to PyPI
if: github.repository == 'icesat2py/icepyx' && startsWith(github.ref, 'refs/tags/')
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/icepyx/
permissions:
id-token: write # IMPORTANT: mandatory for trusted OIDC publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0