-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (103 loc) · 3 KB
/
wheel-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
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
106
107
108
109
110
111
112
113
## Build wheel and upload to PyPI
## https://github.com/joerick/cibuildwheel/blob/master/examples/github-deploy.yml
## https://scikit-hep.org/developer/gha_wheels
name: Build wheel and upload to PyPI
# When pushing with a tag (i.e. new version)
on:
push:
tags:
- "*"
jobs:
check-current-branch:
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.check_step.outputs.branch }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get current branch
id: check_step
# 1. Get the list of branches ref where this tag exists
# 2. Remove 'origin/' from that result
# 3. Put that string in output
# => We can now use function 'contains(list, item)''
run: |
raw=$(git branch -r --contains ${{ github.ref }})
branch="$(echo ${raw//origin\//} | tr -d '\n')"
echo "{name}=branch" >> $GITHUB_OUTPUT
echo "Branches where this tag exists : $branch."
build_wheels:
name: Build universal wheels
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.11'
- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip setuptools wheel
- name: Build wheels
run: |
python3 setup.py bdist_wheel --universal
- uses: actions/upload-artifact@v3
with:
path: dist
build_sdist:
name: Build source
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.11'
- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip setuptools wheel
- name: Build sdist
run: |
python3 setup.py sdist
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
dist_check:
name: Check build with twine
runs-on: ubuntu-latest
needs: [build_wheels, build_sdist]
steps:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: "3.11"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install twine
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Check dist
run: |
twine check dist/*
upload_pypi:
name: Upload to PyPI
needs: [dist_check]
runs-on: ubuntu-latest
if: contains(${{ needs.check.outputs.branch }}, 'main')
environment:
name: pypi
url: https://pypi.org/p/geefcc
permissions:
id-token: write # Mandatory for trusted publishing.
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
# End