6
6
workflow_dispatch :
7
7
8
8
env :
9
- PYTHON_VERSION : " 3.11"
9
+ PYTHON_VERSION : ' 3.11'
10
10
11
11
jobs :
12
12
dependencies :
16
16
- uses : actions/checkout@v4
17
17
name : Checkout
18
18
19
- - name : Save Cached Poetry
19
+ - name : Load Cached Poetry
20
20
id : cached-poetry
21
21
uses : actions/cache@v4
22
22
with :
99
99
- dependencies
100
100
runs-on : ubuntu-latest
101
101
outputs :
102
- version : ${{ steps.extract_version.outputs.version }}
103
- name : ${{ steps.extract_version.outputs.name }}
102
+ version : ${{ steps.extract_version.outputs.VERSION }}
103
+ name : ${{ steps.extract_version.outputs.NAME }}
104
104
steps :
105
105
- uses : actions/checkout@v4
106
106
name : Checkout
@@ -120,14 +120,41 @@ jobs:
120
120
~/.local
121
121
key : poetry-${{ hashFiles('poetry.lock') }}
122
122
123
- - name : Build
124
- run : poetry build
125
-
126
123
- name : Extract Version
127
124
id : extract_version
128
125
run : |
129
- echo "version=$(poetry version --short)" >> "$GITHUB_OUTPUT"
130
- echo "name=$(poetry version | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
126
+ echo "VERSION=$(poetry version --short)" >> "$GITHUB_OUTPUT"
127
+ echo "NAME=$(poetry version | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
128
+ echo "VERSION=$(poetry version --short)"
129
+ echo "NAME=$(poetry version | cut -d' ' -f1)"
130
+
131
+ - name : Extract Version from CHANGELOG.md
132
+ id : extract_changelog_version
133
+ run : |
134
+ VERSION_CHANGELOG=$(sed -n '3 s/## Version //p' CHANGELOG.md)
135
+ echo "VERSION_CHANGELOG=$VERSION_CHANGELOG"
136
+ if [ "${{ steps.extract_version.outputs.VERSION }}" != "$VERSION_CHANGELOG" ]; then
137
+ echo "Error: Version extracted from CHANGELOG.md does not match the version in pyproject.toml"
138
+ exit 1
139
+ else
140
+ echo "Versions are consistent."
141
+ fi
142
+
143
+ - name : Extract Version from Tag
144
+ if : startsWith(github.ref, 'refs/tags/v')
145
+ id : extract_tag_version
146
+ run : |
147
+ VERSION_TAG=$(sed 's/^v//' <<< ${{ github.ref_name }})
148
+ echo "VERSION_TAG=$VERSION_TAG"
149
+ if [ "${{ steps.extract_version.outputs.VERSION }}" != "$VERSION_TAG" ]; then
150
+ echo "Error: Version extracted from tag does not match the version in pyproject.toml"
151
+ exit 1
152
+ else
153
+ echo "Versions are consistent."
154
+ fi
155
+
156
+ - name : Build
157
+ run : poetry build
131
158
132
159
- name : Upload wheel
133
160
uses : actions/upload-artifact@v4
@@ -175,19 +202,19 @@ jobs:
175
202
verbose : true
176
203
177
204
release :
205
+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
178
206
name : Release
179
207
needs :
180
208
- type-check
181
209
- lint
182
210
- build
183
211
- pypi-publish
212
+ runs-on : ubuntu-latest
184
213
environment :
185
214
name : release
186
215
url : https://pypi.org/p/${{ needs.build.outputs.name }}
187
- runs-on : ubuntu-latest
188
216
permissions :
189
217
contents : write
190
- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
191
218
steps :
192
219
- name : Procure Wheel
193
220
uses : actions/download-artifact@v4
@@ -201,13 +228,28 @@ jobs:
201
228
name : binary
202
229
path : artifacts
203
230
231
+ - uses : actions/checkout@v4
232
+ name : Checkout
233
+
234
+ - name : Extract Changelog
235
+ id : changelog
236
+ run : |
237
+ perl -0777 -ne 'while (/## Version ${{ needs.build.outputs.version }}\n(\s*\n)*(.*?)(\s*\n)*## Version \d+\.\d+\.\d+\n/sg) {print "$2\n"}' CHANGELOG.md > CURRENT_CHANGELOG.md
238
+ {
239
+ echo "CONTENT<<EOF"
240
+ cat CURRENT_CHANGELOG.md
241
+ echo "EOF"
242
+ } >> "$GITHUB_OUTPUT"
243
+
204
244
- name : Release
205
- uses : softprops/action-gh-release@v1
245
+ uses : softprops/action-gh-release@v2
206
246
with :
207
247
files : artifacts/*
208
248
tag_name : v${{ needs.build.outputs.version }}
209
249
body : |
210
- Release of version ${{ needs.build.outputs.version }}
211
250
PyPI package: https://pypi.org/project/${{ needs.build.outputs.name }}/${{ needs.build.outputs.version }}
251
+
252
+ # Changes:
253
+ ${{ steps.changelog.outputs.CONTENT }}
212
254
prerelease : false
213
255
draft : false
0 commit comments