-
Notifications
You must be signed in to change notification settings - Fork 1
57 lines (53 loc) · 1.82 KB
/
python-publish.yml
File metadata and controls
57 lines (53 loc) · 1.82 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
name: Upload Python Package
on:
workflow_call:
inputs:
test_pypi:
type: boolean
default: false
secrets:
PYPI_PASSWORD:
required: true
jobs:
upload-python-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install dependencies
run: |
# noninteractive is necessary to install libgdal-dev
# which is needed for python gdal which is
# required by rasterio
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update && sudo apt-get install python3 python3-pip python3-venv libgdal-dev -y
pip3 install build
- name: Update Version Number
run: |
# already done in update-version workflow,
# repeated here if other workflow is slower.
OLD_VERSION=`cat pyproject.toml | grep ^version | cut -d '"' -f 2`
OLD_VERSION="\"$OLD_VERSION\""
NEW_VERSION="\"$GITHUB_REF_NAME\""
sed -i "s+version = $OLD_VERSION+version = $NEW_VERSION+g" pyproject.toml
- name: Build package
run: python3 -m build --outdir build .
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: build/*.whl
- name: Publish package to test pypi
uses: pypa/gh-action-pypi-publish@release/v1
if: ${{ inputs.test_pypi }}
with:
repository_url: https://test.pypi.org/legacy/
password: ${{ secrets.PYPI_PASSWORD }}
packages_dir: build/
verbose: true
- name: Publish package to pypi
uses: pypa/gh-action-pypi-publish@release/v1
if: ${{ inputs.test_pypi == false }}
with:
password: ${{ secrets.PYPI_PASSWORD }}
packages_dir: build/
verbose: true