-
-
Notifications
You must be signed in to change notification settings - Fork 22
123 lines (100 loc) · 3.49 KB
/
release-python-package.yaml
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
122
123
name: Release Python Package
on:
workflow_dispatch:
inputs:
version_name:
description: "One of major, minor, or patch"
required: true
type: choice
options:
- major
- minor
- patch
default: patch
pull_request:
branches:
- '**'
env:
UV_SYSTEM_PYTHON: 1
DEFAULT_VERSION_NAME: patch
jobs:
deploy-package:
runs-on: ubuntu-latest
name: ${{ github.event_name == 'pull_request' && '(Dry Run) ' || '' }}Publish Python Package to PyPI
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Python environment
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Set up Python
run: |
uv python install
uv pip install bumpversion
- name: Set version name
run: echo "VERSION_NAME=${{ github.event.inputs.version_name || env.DEFAULT_VERSION_NAME }}" >> $GITHUB_ENV
- name: Dry run bumpversion
run: |
bumpversion --dry-run ${{ env.VERSION_NAME }} --allow-dirty --verbose
- name: Store new version number
run: echo "version_number=`bumpversion --dry-run --list ${{ env.VERSION_NAME }} | grep new_version | sed -r s,"^.*=",,`" >> $GITHUB_ENV
- name: Display new version number
run: |
echo "version_name: ${{ env.VERSION_NAME }}"
echo "version_number: v${{ env.version_number }}"
- name: Ensure repo status is clean
run: git status
- name: Configure Git
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Run bumpversion
run: bumpversion ${{ env.VERSION_NAME }} --verbose
- name: Ensure tag creation
run: git tag | grep ${{ env.version_number }}
- name: Install llamabot package
run: uv pip install -e .
- name: Write release notes
if: github.event_name != 'pull_request'
env:
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
llamabot configure default-model --model-name="${{ secrets.DEFAULT_LANGUAGE_MODEL }}"
llamabot git write-release-notes
- name: Commit release notes
if: github.event_name != 'pull_request'
run: |
uv pip install pre-commit
pre-commit run --all-files || pre-commit run --all-files
git add .
git commit -m "Add release notes for ${{ env.version_number }}"
- name: Build package
run: |
uv build --sdist --wheel
- name: Publish package
if: github.event_name != 'pull_request'
run: uv publish --token ${{ secrets.PYPI_API_TOKEN }}
- name: Push changes with tags
if: github.event_name != 'pull_request'
run: |
git push && git push --tags
- name: Create release in GitHub repo
if: github.event_name != 'pull_request'
uses: ncipollo/release-action@v1
with:
bodyFile: "docs/releases/v${{ env.version_number }}.md"
token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ env.version_number }}
- name: Ensure complete
if: github.event_name != 'pull_request'
run: echo "Auto-release complete!"