Skip to content

Commit 08a568c

Browse files
Allow empty inputs with release artifacts (#110)
* Make inputs optional on releases if release-signing-artifacts is set to true Signed-off-by: Jean-Christophe Morin <[email protected]> * Add basic .gitignore to ignore venv Signed-off-by: Jean-Christophe Morin <[email protected]> * Make behavior more explicit Signed-off-by: Jean-Christophe Morin <[email protected]> --------- Signed-off-by: Jean-Christophe Morin <[email protected]>
1 parent 8579d48 commit 08a568c

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
env/

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ optional.
4848
### `inputs`
4949

5050
The `inputs` setting controls what files `sigstore-python` signs. At least one input must be
51-
provided.
51+
provided unless [release-signing-artifacts](#release-signing-artifacts) is set to `true` on release events.
5252

5353
To sign one or more files:
5454

@@ -405,6 +405,22 @@ permissions:
405405
release-signing-artifacts: true
406406
```
407407

408+
On release events, it is also valid to have no explicit inputs. When used on release
409+
events with `release-signing-artifacts: true`, this action will sign any pre-existing
410+
release artifacts:
411+
412+
```yaml
413+
permissions:
414+
contents: write
415+
416+
# ...
417+
418+
- uses: sigstore/[email protected]
419+
with:
420+
# Only valid on release events
421+
release-signing-artifacts: true
422+
```
423+
408424
### Internal options
409425
<details>
410426
<summary>⚠️ Internal options ⚠️</summary>

action.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,15 @@ def _fatal_help(msg):
106106
sys.exit(1)
107107

108108

109-
inputs = shlex.split(sys.argv[1])
109+
# Allow inputs to be empty if the event type is release and release-signing-artifacts is
110+
# set to true. This allows projects without artifacts to still sign the source
111+
# archives in their releases.
112+
inputs = shlex.split(sys.argv[1]) if len(sys.argv) == 2 else []
113+
if not inputs and not _RELEASE_SIGNING_ARTIFACTS:
114+
_fatal_help(
115+
"inputs must be specified when release-signing-artifacts is disabled "
116+
"and the event type is not release"
117+
)
110118

111119
# The arguments we pass into `sigstore-python` get built up in these lists.
112120
sigstore_global_args = []

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ description: "Use sigstore-python to sign Python packages"
1818
inputs:
1919
inputs:
2020
description: "the files to sign, whitespace separated"
21-
required: true
21+
required: false
2222
default: ""
2323
identity-token:
2424
description: "the OIDC identity token to use"

0 commit comments

Comments
 (0)