-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (84 loc) · 2.62 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
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
name: Publish to PyPI
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
task:
description: 'PyPI or TestPyPI'
required: true
default: 'None'
type: choice
options:
- none
- testpypi
- pypi
- all
jobs:
publish:
name: Publish to TestPyPI and PyPI
runs-on: [ubuntu-latest]
steps:
- name: Check tag
id: check-tag
run: |
task="${{ github.event.inputs.task }}"
if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
task="pypi"
fi
if [[ "$task" == "pypi" || "$task" == "all" ]]; then
echo "run_pypi=true" >> $GITHUB_OUTPUT
else
echo "run_pypi=false" >> $GITHUB_OUTPUT
fi
if [[ "$task" == "testpypi" || "$task" == "all" ]]; then
echo "run_testpypi=true" >> $GITHUB_OUTPUT
else
echo "run_testpypi=false" >> $GITHUB_OUTPUT
fi
if [[ "$task" == "none" ]]; then
echo "match=false" >> $GITHUB_OUTPUT
else
echo "match=true" >> $GITHUB_OUTPUT
fi
- name: Checkout repo
if: steps.check-tag.outputs.match == 'true'
uses: actions/checkout@v4
with:
submodules: recursive
- name: Download Python wheels
if: steps.check-tag.outputs.match == 'true'
uses: dawidd6/action-download-artifact@v6
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: wheels.yml
workflow_conclusion: success
branch: github
#name: cp.*
#name_is_regexp: true
#search_artifacts: true
path: dist/
- name: Set up Python
if: steps.check-tag.outputs.match == 'true'
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Build a a source tarball
if: steps.check-tag.outputs.match == 'true'
run: |
find ./dist -name '*.whl' -exec mv {} ./dist \;
rm -r ./dist/cp*
python -m pip install build
python -m build --sdist
- name: Publish distribution to Test PyPI
if: steps.check-tag.outputs.run_testpypi == 'true'
uses: pypa/[email protected]
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution to PyPI
if: steps.check-tag.outputs.run_pypi == 'true'
uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_API_TOKEN }}