-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (81 loc) · 2.54 KB
/
pypi_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
94
95
96
name: PyPI publish
on:
workflow_call:
inputs:
package_version:
description: "The version used to publish to the registry."
type: string
required: true
test_pypi:
description: "Parameter to publish the package to Test PyPI when set to 'true', and to publish to official Pypi when set to 'false'."
type: string
required: true
python_latest:
description: 'Use the latest Python version (3.12)'
required: true
default: false
type: boolean
jobs:
build-package:
name: Build Package with Verified Version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Validate Version Tag
uses: ghga-de/gh-action-pypi/verify-version-tag@main
with:
tag: ${{ inputs.package_version }}
- name: Build Python Package
uses: ghga-de/gh-action-pypi/build-python-package@main
- name: Upload package artifact
uses: actions/upload-artifact@v4
with:
path: ./dist
define-matrix:
runs-on: ubuntu-latest
outputs:
versions: $
steps:
- name: Define python versions
shell: bash
run: |
PYTHON_LATEST=${{ inputs.python_latest }}
if $PYTHON_LATEST; then
echo '["3.12"]' >> "$GITHUB_OUTPUT"
else
echo '["3.9", "3.10", "3.11", "3.12"]' >> "$GITHUB_OUTPUT"
fi
test-package:
name: Test Freshly Built Package
needs:
- build-package
- define-matrix
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ${{ fromJSON(needs.define-matrix.outputs.versions) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download dist content
uses: actions/download-artifact@v4
- name: Test using the test-package action
uses: ghga-de/gh-action-pypi/test-package@main
with:
python_version: ${{ matrix.python-version }}
publish-package:
name: Publish Package
needs: test-package
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download dist content
uses: actions/download-artifact@v4
- name: Publish using the publish-package action
uses: ghga-de/gh-action-pypi/publish-package@main
with:
test_pypi_api_token: ${{ secrets.TEST_PYPI_API_TOKEN }}
pypi_api_token: ${{ secrets.PYPI_API_TOKEN }}
test_pypi: ${{ inputs.test_pypi }}