Repository navigation
76 lines (67 loc) · 1.88 KB
/
Copy pathbump-version.yml
File metadata and controls
76 lines (67 loc) · 1.88 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
name: Bump version and tag
on:
workflow_dispatch:
inputs:
bump:
description: "Which part to bump?"
required: true
default: "patch"
type: choice
options:
- patch
- minor
- major
target:
description: "Where will this tag be used?"
required: true
default: "pypi"
type: choice
options:
- pypi
- testpypi
jobs:
bump:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install bump2version
run: python -m pip install -U pip bump2version
- name: Configure git
shell: bash
run: |
git config user.name "github-actions"
git config user.email "github-actions@users.noreply.github.com"
- name: Export VERSION from pyproject.toml
shell: bash
run: |
VERSION=$(python - <<'PY'
try:
import tomllib
except Exception:
import tomli as tomllib # type: ignore
from pathlib import Path
data = tomllib.loads(Path("pyproject.toml").read_text(encoding="utf-8"))
print(data["project"]["version"])
PY
)
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Bump version + create tag
shell: bash
run: |
if [ "${{ inputs.target }}" = "testpypi" ]; then
bump2version --current-version "$VERSION" --tag-name "test-v{new_version}" "${{ inputs.bump }}"
else
bump2version --current-version "$VERSION" "${{ inputs.bump }}"
fi
- name: Push commit + tags
shell: bash
run: |
git push
git push --tags