-
Notifications
You must be signed in to change notification settings - Fork 2
117 lines (108 loc) · 3.98 KB
/
python-release.yaml
File metadata and controls
117 lines (108 loc) · 3.98 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
---
name: Python Release
run-name: "${{ github.event.repository.name }} release ${{ inputs.version || inputs.poetry-version-options }}"
on:
workflow_dispatch:
inputs:
version:
description: 'Specify version (optional)'
required: false
default: ''
python-version:
description: 'Python version to use'
required: false
default: '3.8'
poetry-version-options:
description: 'Poetry version bump (e.g., patch, minor, major)'
required: false
default: 'patch'
poetry-build-params:
description: 'Additional poetry build parameters'
required: false
default: ''
pytest-run:
description: 'Run pytest (true/false)'
required: true
type: boolean
default: false
pytest-params:
description: 'Parameters for pytest'
required: false
default: '--maxfail=3 -v'
permissions:
contents: read
jobs:
pre-build-checks:
runs-on: ubuntu-latest
steps:
- name: Input parameters
run: |
echo "Input parameters:" >> $GITHUB_STEP_SUMMARY
echo "Version: ${{ github.event.inputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "Python version: ${{ github.event.inputs.python-version }}" >> $GITHUB_STEP_SUMMARY
echo "Poetry version options: ${{ github.event.inputs.poetry-version-options }}" >> $GITHUB_STEP_SUMMARY
echo "Poetry build parameters: ${{ github.event.inputs.poetry-build-params }}" >> $GITHUB_STEP_SUMMARY
echo "Pytest run: ${{ github.event.inputs.pytest-run }}" >> $GITHUB_STEP_SUMMARY
echo "Pytest parameters: ${{ github.event.inputs.pytest-params }}" >> $GITHUB_STEP_SUMMARY
- name: Check if tag exists
if: ${{ inputs.version != '' }}
id: check_tag
uses: netcracker/qubership-workflow-hub/actions/tag-action@v1.0.1
with:
tag-name: 'v${{ inputs.version }}'
ref: ${{ github.ref }}
create-tag: false
check-tag: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
runs-on: ubuntu-latest
permissions:
contents: write
needs: [pre-build-checks]
outputs:
published-version: ${{ steps.publish.outputs.release-version }}
steps:
- name: "Prepare app token"
if: ${{ vars.GH_BUMP_VERSION_APP_ID != '' }}
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.GH_BUMP_VERSION_APP_ID }}
private-key: ${{ secrets.GH_BUMP_VERSION_APP_KEY }}
- name: "Checkout"
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
- name: "Setup Python ${{ inputs.python-version }}"
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: "Publish"
id: publish
uses: netcracker/qubership-workflow-hub/actions/poetry-publisher@main
with:
package_version: ${{ inputs.version }}
poetry_version_bump: ${{ inputs.poetry-version-options }}
poetry_build_options: ${{ inputs.poetry-build-params }}
run_pytest: ${{ inputs.pytest-run }}
pytest_options: ${{ inputs.pytest-params }}
publish: "true"
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
- name: "Commit changes"
run: |
git config --global user.email "github-actions@github.com"
git config --global user.name "github-actions[bot]"
git add .
git commit -m "Update version to ${{ steps.publish.outputs.release-version }} for release"
git push -u origin ${{ github.ref }}
github-release:
permissions:
contents: write
pull-requests: write
needs: [publish]
uses: Netcracker/qubership-workflow-hub/.github/workflows/release-drafter.yml@v1.0.1
with:
version: ${{ needs.publish.outputs.published-version }}
publish: true