-
Notifications
You must be signed in to change notification settings - Fork 2
127 lines (115 loc) · 4.52 KB
/
python-uv-release.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
124
125
126
127
name: Python uv release
# Reusable workflow for building and releasing Python uv packages
on:
workflow_call:
inputs:
release-type:
description: "Scope of the release (major, minor or patch)."
required: true
type: string
uv-version:
description: "The uv version to be installed. (Default is 0.5.14)"
required: false
default: "0.5.14"
type: string
python-version:
description: "The Python version for setting up uv. (Default is 3.11)"
required: false
default: "3.11"
type: string
changelog:
description: "Create changelog for release."
required: false
default: true
type: boolean
changelog-file:
description: Path to the changelog file in the GitHub repository
required: false
default: "CHANGELOG.md"
type: string
changelog-config:
description: "Changelog config path."
required: false
default: ""
type: string
working-directory:
description: "Working directory containing `.bumpversion.cfg`. (Default is .)"
required: false
default: "."
type: string
secrets:
github-username:
description: "The GitHub username for committing the changes."
required: true
github-email:
description: "The GitHub email for committing the changes."
required: true
github-token:
description: "The GitHub token for committing the changes."
required: true
# Map the workflow outputs to job outputs
outputs:
release-version:
description: "The bumped version."
value: ${{ jobs.release.outputs.release-version }}
old-version:
description: "The old version in your `.bumpversion.cfg` file."
value: ${{ jobs.release.outputs.old-version }}
jobs:
release:
runs-on: ubuntu-22.04
# Map the job outputs to step outputs
outputs:
release-version: ${{ steps.bump-version-release.outputs.release-version }}
old-version: ${{ steps.bump-version-dev.outputs.old-version }}
steps:
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ inputs.python-version }}
version: ${{ inputs.uv-version }}
- name: Check out repository
uses: bakdata/ci-templates/actions/[email protected]
with:
ref: ${{ github.event.repository.default_branch }}
persist-credentials: false # required for pushing to protected branch later
fetch-depth: 0 # required for changelog generation
- name: Bump version
id: bump-version-dev
uses: bakdata/ci-templates/actions/[email protected]
with:
release-type: ${{ inputs.release-type }}
working-directory: ${{ inputs.working-directory }}
- name: Bump version release
id: bump-version-release
uses: bakdata/ci-templates/actions/[email protected]
with:
release-type: release --allow-dirty
working-directory: ${{ inputs.working-directory }}
- name: Apply version bump to uv lock
run: uv lock --no-refresh
- name: Create changelog
id: build-changelog
uses: bakdata/ci-templates/actions/[email protected]
if: ${{ inputs.changelog }}
with:
github-token: ${{ secrets.github-token }}
tag: ${{ steps.bump-version-release.outputs.release-version }}
changelog-file: ${{ inputs.changelog-file }}
- name: Commit and push changes including .bumpversion.cfg file
uses: bakdata/ci-templates/actions/[email protected]
with:
ref: ${{ github.event.repository.default_branch }}
commit-message: "Bump version ${{ steps.bump-version-dev.outputs.old-version }} → ${{ steps.bump-version-release.outputs.release-version }}"
github-username: ${{ secrets.github-username }}
github-email: ${{ secrets.github-email }}
github-token: ${{ secrets.github-token }}
- name: Tag and release
uses: bakdata/ci-templates/actions/[email protected]
with:
tag: "${{ steps.bump-version-release.outputs.release-version }}"
github-username: ${{ secrets.github-username }}
github-email: ${{ secrets.github-email }}
github-token: ${{ secrets.github-token }}
release-title: "${{ steps.bump-version-release.outputs.release-version }}"
release-body: "${{ steps.build-changelog.outputs.single-changelog }}"