-
Notifications
You must be signed in to change notification settings - Fork 8
121 lines (105 loc) · 3.49 KB
/
python-publish.yml
File metadata and controls
121 lines (105 loc) · 3.49 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
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
114
115
116
117
118
119
120
121
name: "[REUSABLE] Python build"
on:
workflow_call:
inputs:
version:
required: false
type: string
poetry_version_options:
required: false
type: string
default: 'patch'
python-version:
required: false
type: string
default: '3.11'
poetry_build_params:
required: false
type: string
pytest_run:
required: true
type: boolean
pytest_params:
required: false
type: string
gh_app_id:
required: true
type: string
secrets:
PYPI_API_TOKEN:
required: true
GH_APP_KEY:
required: true
jobs:
build-publish:
runs-on: ubuntu-latest
steps:
- name: Debug variables
run: |
echo version = ${{ inputs.version }}
echo poetry_version_options = ${{ inputs.poetry_version_options }}
echo python-version = ${{ inputs.python-version }}
echo poetry_build_params = ${{ inputs.poetry_build_params }}
echo pytest_run = ${{ inputs.pytest_run }}
echo pytest_params = ${{ inputs.pytest_params }}
echo "Environment:"
env
- name: "Prepare app token"
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
id: app-token
with:
app-id: ${{ inputs.gh_app_id }}
private-key: ${{ secrets.GH_APP_KEY }}
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
token: ${{ steps.app-token.outputs.token }}
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ inputs.python-version }}
- name: Install dependencies 3.8
if: ${{ inputs.python-version == '3.8' }}
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Install dependencies
if: ${{ inputs.python-version != '3.8' }}
run: |
python -m pip install --upgrade pip
python -m pip install --user pipx
pipx install poetry
- name: Remove dist
run: rm -rf dist/
- name: AutoPatch version
if: ${{ inputs.poetry_version_options != '' && inputs.version == '' }}
run: poetry version ${{ inputs.poetry_version_options }}
- name: Set specific version
if: ${{ inputs.version != '' }}
run: poetry version ${{ inputs.version }}
- name: Build package
run: poetry build ${{ inputs.poetry_build_params }}
- name: Validate build
run: |
ls -l dist/
echo "Build validation complete."
- name: Run tests
if: ${{ inputs.pytest_run == true }}
run: |
poetry install
poetry run pytest ${{ inputs.pytest_params }}
- name: Publish to PyPi
run: |
poetry config pypi-token.pypi $PYPI_TOKEN
# zizmor: ignore[use-trusted-publishing]
poetry publish --no-interaction -p test
env:
PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
- name: Update Source on GitHub
run: |
git config --global user.email "qubership-actions[bot]@users.noreply.github.com"
git config --global user.name "qubership-actions[bot]"
git add .
git commit -m "Update version to ${{ inputs.version }} for release"
git push -u origin main