Skip to content

Commit 7104b6e

Browse files
committed
Merge branch 'maintenance/kebab-case-inputs' into unstable/v1
This patch normalizes the action inputs to be kebab-case while keeping the old snake_case fallbacks working.
2 parents 32b5e93 + f131721 commit 7104b6e

File tree

4 files changed

+83
-18
lines changed

4 files changed

+83
-18
lines changed

.github/workflows/self-smoke-test-action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
with:
9292
user: ${{ env.devpi-username }}
9393
password: ${{ env.devpi-password }}
94-
repository_url: >-
94+
repository-url: >-
9595
http://devpi:${{ env.devpi-port }}/${{ env.devpi-username }}/public/
9696
9797
...

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ project's specific needs.
9999
For example, you could implement a parallel workflow that
100100
pushes every commit to TestPyPI or your own index server,
101101
like `devpi`. For this, you'd need to (1) specify a custom
102-
`repository_url` value and (2) generate a unique version
102+
`repository-url` value and (2) generate a unique version
103103
number for each upload so that they'd not create a conflict.
104104
The latter is possible if you use `setuptools_scm` package but
105105
you could also invent your own solution based on the distance
@@ -114,7 +114,7 @@ The action invocation in this case would look like:
114114
uses: pypa/gh-action-pypi-publish@release/v1
115115
with:
116116
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
117-
repository_url: https://test.pypi.org/legacy/
117+
repository-url: https://test.pypi.org/legacy/
118118
```
119119

120120
### Customizing target package dists directory
@@ -128,7 +128,7 @@ would now look like:
128128
uses: pypa/gh-action-pypi-publish@release/v1
129129
with:
130130
password: ${{ secrets.PYPI_API_TOKEN }}
131-
packages_dir: custom-dir/
131+
packages-dir: custom-dir/
132132
```
133133

134134
### Disabling metadata verification
@@ -139,7 +139,7 @@ check with:
139139

140140
```yml
141141
with:
142-
verify_metadata: false
142+
verify-metadata: false
143143
```
144144

145145
### Tolerating release package file duplicates
@@ -149,12 +149,12 @@ may hit race conditions. For example, when publishing from multiple CIs
149149
or even having workflows with the same steps triggered within GitHub
150150
Actions CI/CD for different events concerning the same high-level act.
151151

152-
To facilitate this use-case, you may use `skip_existing` (disabled by
152+
To facilitate this use-case, you may use `skip-existing` (disabled by
153153
default) setting as follows:
154154

155155
```yml
156156
with:
157-
skip_existing: true
157+
skip-existing: true
158158
```
159159

160160
> **Pro tip**: try to avoid enabling this setting where possible. If you
@@ -177,7 +177,7 @@ It will show SHA256, MD5, BLAKE2-256 values of files to be uploaded.
177177

178178
```yml
179179
with:
180-
print_hash: true
180+
print-hash: true
181181
```
182182

183183
### Specifying a different username

action.yml

+55-10
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,76 @@ inputs:
99
password:
1010
description: Password for your PyPI user or an access token
1111
required: true
12-
repository_url:
12+
repository-url: # Canonical alias for `repository_url`
1313
description: The repository URL to use
1414
required: false
15-
packages_dir:
15+
repository_url: # DEPRECATED ALIAS; TODO: Remove in v3+
16+
description: >-
17+
[DEPRECATED]
18+
The repository URL to use
19+
deprecationMessage: >-
20+
The inputs have been normalized to use kebab-case.
21+
Use `repository-url` instead.
22+
required: false
23+
packages-dir: # Canonical alias for `packages_dir`
1624
description: The target directory for distribution
1725
required: false
1826
default: dist
19-
verify_metadata:
27+
packages_dir: # DEPRECATED ALIAS; TODO: Remove in v3+
28+
description: >-
29+
[DEPRECATED]
30+
The target directory for distribution
31+
deprecationMessage: >-
32+
The inputs have been normalized to use kebab-case.
33+
Use `packages-dir` instead.
34+
required: false
35+
default: dist
36+
verify-metadata: # Canonical alias for `verify_metadata`
2037
description: Check metadata before uploading
2138
required: false
2239
default: 'true'
23-
skip_existing:
40+
verify_metadata: # DEPRECATED ALIAS; TODO: Remove in v3+
41+
description: >-
42+
[DEPRECATED]
43+
Check metadata before uploading
44+
deprecationMessage: >-
45+
The inputs have been normalized to use kebab-case.
46+
Use `verify-metadata` instead.
47+
required: false
48+
default: 'true'
49+
skip-existing: # Canonical alias for `skip_existing`
2450
description: >-
2551
Do not fail if a Python package distribution
2652
exists in the target package index
2753
required: false
2854
default: 'false'
55+
skip_existing: # DEPRECATED ALIAS; TODO: Remove in v3+
56+
description: >-
57+
[DEPRECATED]
58+
Do not fail if a Python package distribution
59+
exists in the target package index
60+
deprecationMessage: >-
61+
The inputs have been normalized to use kebab-case.
62+
Use `skip-existing` instead.
63+
required: false
64+
default: 'false'
2965
verbose:
3066
description: Show verbose output.
3167
required: false
3268
default: 'false'
33-
print_hash:
69+
print-hash: # Canonical alias for `print_hash`
3470
description: Show hash values of files to be uploaded
3571
required: false
3672
default: 'false'
73+
print_hash: # DEPRECATED ALIAS; TODO: Remove in v3+
74+
description: >-
75+
[DEPRECATED]
76+
Show hash values of files to be uploaded
77+
deprecationMessage: >-
78+
The inputs have been normalized to use kebab-case.
79+
Use `print-hash` instead.
80+
required: false
81+
default: 'false'
3782
branding:
3883
color: yellow
3984
icon: upload-cloud
@@ -43,9 +88,9 @@ runs:
4388
args:
4489
- ${{ inputs.user }}
4590
- ${{ inputs.password }}
46-
- ${{ inputs.repository_url }}
47-
- ${{ inputs.packages_dir }}
48-
- ${{ inputs.verify_metadata }}
49-
- ${{ inputs.skip_existing }}
91+
- ${{ inputs.repository-url }}
92+
- ${{ inputs.packages-dir }}
93+
- ${{ inputs.verify-metadata }}
94+
- ${{ inputs.skip-existing }}
5095
- ${{ inputs.verbose }}
51-
- ${{ inputs.print_hash }}
96+
- ${{ inputs.print-hash }}

twine-upload.sh

+20
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@ export PATH="$(python -m site --user-base)/bin:${PATH}"
1818
export PYTHONPATH="$(python -m site --user-site):${PYTHONPATH}"
1919

2020

21+
function get-normalized-input() {
22+
local var_name=${1}
23+
python -c \
24+
'
25+
from os import getenv
26+
from sys import argv
27+
envvar_name = f"INPUT_{argv[1].upper()}"
28+
print(getenv(envvar_name, getenv(envvar_name.replace("-", "_"), "")), end="")
29+
' \
30+
"${var_name}"
31+
}
32+
33+
34+
INPUT_REPOSITORY_URL="$(get-normalized-input 'repository-url')"
35+
INPUT_PACKAGES_DIR="$(get-normalized-input 'packages-dir')"
36+
INPUT_VERIFY_METADATA="$(get-normalized-input 'verify-metadata')"
37+
INPUT_SKIP_EXISTING="$(get-normalized-input 'skip-existing')"
38+
INPUT_PRINT_HASH="$(get-normalized-input 'print-hash')"
39+
40+
2141
if [[
2242
"$INPUT_USER" == "__token__" &&
2343
! "$INPUT_PASSWORD" =~ ^pypi-

0 commit comments

Comments
 (0)