-
Notifications
You must be signed in to change notification settings - Fork 5
94 lines (81 loc) · 2.78 KB
/
python-publish.yml
File metadata and controls
94 lines (81 loc) · 2.78 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
name: Build and Release
on:
workflow_dispatch:
inputs:
patch_version:
description: "Patch version"
default: true
required: true
type: boolean
use_custom_version:
description: "Use custom_version instead of increment"
default: false
required: true
type: boolean
custom_version:
description: "Specific version to release:"
default: 0.0.1
type: string
required: true
permissions:
contents: write
jobs:
bump-and-publish:
runs-on: ubuntu-latest
outputs:
release_version: ${{ steps.save-release-version.outputs.release_version }}
steps:
- name: Prepare app token
if: ${{ vars.GH_BUMP_VERSION_APP_ID != '' }}
uses: actions/create-github-app-token@v3
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@v6
with:
token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --user pipx
pipx install poetry
- name: Build & Test
run: |
poetry install
poetry run pytest -m "not integration"
- name: Patch minor version
if: ${{ inputs.patch_version && !inputs.use_custom_version }}
run: poetry version patch
- name: Set specific version
if: ${{ inputs.patch_version && inputs.use_custom_version }}
run: poetry version ${{ inputs.custom_version }}
- name: Save release version
id: save-release-version
run: echo "release_version=$(poetry version --short)" >> "$GITHUB_OUTPUT"
- name: Publish package
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
poetry publish --build --no-interaction
- name: Push updated version
if: ${{ inputs.patch_version }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git commit -a -m "Update version to ${{ steps.save-release-version.outputs.release_version }}"
git push
create-github-release:
permissions:
contents: write
pull-requests: write
needs: [ bump-and-publish ]
uses: Netcracker/qubership-workflow-hub/.github/workflows/release-drafter.yml@v2.2.2
with:
version: ${{ needs.bump-and-publish.outputs.release_version }}
ref: ${{ github.ref_name }}
publish: true