-
Notifications
You must be signed in to change notification settings - Fork 22
78 lines (69 loc) · 2.19 KB
/
release.yml
File metadata and controls
78 lines (69 loc) · 2.19 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
name: PyPI Release
on:
workflow_dispatch:
inputs:
bump:
description: "Version bump type"
required: true
type: choice
options:
- MINOR
- BUGFIX
default: BUGFIX
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
- name: Bump version
run: |
CURRENT=$(sed -n 's/^__version__ = "\([0-9.]*\).*/\1/p' src/banks/__about__.py)
IFS=. read -r major minor patch <<< "$CURRENT"
case "${{ github.event.inputs.bump }}" in
BUGFIX)
patch=$((patch + 1))
;;
MINOR)
minor=$((minor + 1))
patch=0
;;
*)
echo "Unexpected bump type: ${{ github.event.inputs.bump }}"
exit 1
;;
esac
VERSION="${major}.${minor}.${patch}"
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
echo "Bumped ${CURRENT} -> ${VERSION} (${{ github.event.inputs.bump }})"
- name: Update __about__.py on default branch
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
sed -i "s/^__version__ = .*$/__version__ = \"${VERSION}\"/" src/banks/__about__.py
git diff --quiet && exit 0
git add src/banks/__about__.py
git commit -m "chore: set __version__ to ${VERSION} [skip ci]"
git push origin "${{ github.event.repository.default_branch }}"
- name: Create and push tag
run: |
git tag "v${VERSION}"
git push origin "v${VERSION}"
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Publish on PyPi
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
uv build
uv publish
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: v${{ env.VERSION }}
artifacts: "dist/*"
generateReleaseNotes: true