Skip to content

Commit 5f31d8a

Browse files
authored
Merge pull request #2332 from sirosen/fix-release-version-normalization
Fix release workflow to normalize versions
2 parents 3a0f5ed + 106f1d6 commit 5f31d8a

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ on:
2525
release-version:
2626
description: >-
2727
Target PEP440-compliant version to release.
28-
Please, don't prepend `v`.
28+
Any leading `v` will be stripped off.
2929
required: false
3030
type: string
3131
release-committish:
@@ -93,11 +93,7 @@ jobs:
9393
# NOTE: inaccessible when passing inputs to reusable workflows.
9494
dists-artifact-name: python-package-distributions
9595
dist-version: >-
96-
${{
97-
steps.request-check.outputs.release-requested == 'true'
98-
&& inputs.release-version
99-
|| steps.scm-version.outputs.dist-version
100-
}}
96+
${{ steps.normalize-dist-version.outputs.dist-version }}
10197
project-name: ${{ steps.metadata.outputs.project-name }}
10298
release-requested: >-
10399
${{
@@ -224,6 +220,27 @@ jobs:
224220
f'dist-version-for-filenames={ver.replace("+", "-")}',
225221
file=outputs_file,
226222
)
223+
- name: Normalize dist version
224+
id: normalize-dist-version
225+
run: |
226+
from os import environ
227+
from pathlib import Path
228+
229+
FILE_APPEND_MODE = 'a'
230+
231+
dist_version = "${{
232+
steps.request-check.outputs.release-requested == 'true'
233+
&& inputs.release-version
234+
|| steps.scm-version.outputs.dist-version
235+
}}".lstrip("v")
236+
237+
with Path(environ['GITHUB_OUTPUT']).open(
238+
mode=FILE_APPEND_MODE,
239+
) as outputs_file:
240+
print(
241+
f"dist-version={dist_version}",
242+
file=outputs_file,
243+
)
227244
- name: Set the expected dist artifact names
228245
id: artifact-name
229246
env:
@@ -240,24 +257,17 @@ jobs:
240257
replace('.', '_').
241258
lower()
242259
)
260+
dist_version = "${{ steps.normalize-dist-version.outputs.dist-version }}"
243261
244262
with Path(environ['GITHUB_OUTPUT']).open(
245263
mode=FILE_APPEND_MODE,
246264
) as outputs_file:
247265
print(
248-
f"sdist={sdist_file_prj_base_name !s}-${{
249-
steps.request-check.outputs.release-requested == 'true'
250-
&& inputs.release-version
251-
|| steps.scm-version.outputs.dist-version
252-
}}.tar.gz",
266+
f"sdist={sdist_file_prj_base_name !s}-{dist_version}.tar.gz",
253267
file=outputs_file,
254268
)
255269
print(
256-
f"wheel={whl_file_prj_base_name !s}-${{
257-
steps.request-check.outputs.release-requested == 'true'
258-
&& inputs.release-version
259-
|| steps.scm-version.outputs.dist-version
260-
}}-py3-none-any.whl",
270+
f"wheel={whl_file_prj_base_name !s}-{dist_version}-py3-none-any.whl",
261271
file=outputs_file,
262272
)
263273

0 commit comments

Comments
 (0)