-
-
Notifications
You must be signed in to change notification settings - Fork 3
71 lines (60 loc) · 2.26 KB
/
publish-to-pypi.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Publish archives to PyPI and TestPyPI using GitHub Actions
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
name: Publish to PyPI
# Only run for pushes to the main branch and releases.
on:
push:
branches:
- main
release:
types:
- published
# Runs for pull requests should be disabled other than for testing purposes
#pull_request:
# branches:
# - main
permissions:
contents: read
jobs:
publish-pypi:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-22.04
permissions:
# This permission is mandatory for OIDC publishing
id-token: write
if: github.repository == 'weiji14/zen3geo'
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
# fetch all history so that poetry-dynamic-versioning works
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: '3.11.8'
- name: Install Poetry and dynamic-versioning plugin
run: |
pip install poetry==1.6.1
poetry self add poetry-dynamic-versioning[plugin]
poetry show
- name: Fix up version string for TestPyPI and PyPI
run: |
# Change poetry-dynamic-versioning to use metadata=false so that the
# local part of the version isn't included, making the version string
# compatible with PyPI.
sed --in-place "s/metadata = true/metadata = false/g" pyproject.toml
- name: Build a binary wheel and a source tarball
run: |
poetry build -vvv
echo ""
echo "Generated files:"
ls -lh dist/
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@a56da0b891b3dc519c7ee3284aff1fad93cc8598 # v1.8.6
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@a56da0b891b3dc519c7ee3284aff1fad93cc8598 # v1.8.6