Skip to content

Commit b3690e3

Browse files
authored
Fix release-signing-artifacts behavior and docs (#103)
* action: don't attempt to download artifacts on non-releases Signed-off-by: William Woodruff <[email protected]> * README: clarify release-signing-artifacts behavior Signed-off-by: William Woodruff <[email protected]> * add another selftest Signed-off-by: William Woodruff <[email protected]> --------- Signed-off-by: William Woodruff <[email protected]>
1 parent afe705f commit b3690e3

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

.github/workflows/selftest.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,35 @@ jobs:
3838
run: |
3939
[[ -f ./test/artifact.txt.sigstore ]] || exit 1
4040
41+
selftest-release-signing-artifacts-no-op:
42+
strategy:
43+
matrix:
44+
os:
45+
- ubuntu-latest
46+
- macos-latest
47+
- windows-latest
48+
runs-on: ${{ matrix.os }}
49+
if: (github.event_name != 'pull_request') || !github.event.pull_request.head.repo.fork
50+
steps:
51+
- uses: actions/checkout@v4
52+
- uses: actions/setup-python@v5
53+
if: ${{ matrix.os != 'ubuntu-latest' }}
54+
with:
55+
python-version: "3.x"
56+
- name: Sign artifact and publish signature
57+
uses: ./
58+
id: sigstore-python
59+
with:
60+
inputs: ./test/artifact.txt
61+
# The trigger for this test is not a release, so this has no effect
62+
# (but does not break the workflow either).
63+
release-signing-artifacts: true
64+
internal-be-careful-debug: true
65+
- name: Check outputs
66+
shell: bash
67+
run: |
68+
[[ -f ./test/artifact.txt.sigstore ]] || exit 1
69+
4170
selftest-xfail-invalid-inputs:
4271
runs-on: ubuntu-latest
4372
strategy:
@@ -285,6 +314,7 @@ jobs:
285314

286315
needs:
287316
- selftest
317+
- selftest-release-signing-artifacts-no-op
288318
- selftest-xfail-invalid-inputs
289319
- selftest-staging
290320
- selftest-glob

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ Example:
370370

371371
The `release-signing-artifacts` setting controls whether or not `sigstore-python`
372372
uploads signing artifacts to the release publishing event that triggered this run.
373+
This setting has no effect on non-`release` events.
373374

374375
If enabled, this setting also re-uploads and signs GitHub's default source code artifacts,
375376
as they are not guaranteed to be stable.

action.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
_RENDER_SUMMARY = os.getenv("GHA_SIGSTORE_PYTHON_SUMMARY", "true") == "true"
3939
_DEBUG = os.getenv("GHA_SIGSTORE_PYTHON_INTERNAL_BE_CAREFUL_DEBUG", "false") != "false"
4040

41+
_RELEASE_SIGNING_ARTIFACTS = (
42+
os.getenv("GHA_SIGSTORE_PYTHON_RELEASE_SIGNING_ARTIFACTS", "true") == "true"
43+
and os.getenv("GITHUB_EVENT_NAME") == "release"
44+
)
45+
4146

4247
def _template(name):
4348
path = _TEMPLATES / f"{name}.md"
@@ -189,7 +194,7 @@ def _fatal_help(msg):
189194
elif verify_oidc_issuer:
190195
sigstore_verify_args.extend(["--cert-oidc-issuer", verify_oidc_issuer])
191196

192-
if os.getenv("GHA_SIGSTORE_PYTHON_RELEASE_SIGNING_ARTIFACTS") == "true":
197+
if _RELEASE_SIGNING_ARTIFACTS:
193198
for filetype in ["zip", "tar.gz"]:
194199
artifact = _download_ref_asset(filetype)
195200
if artifact is not None:

0 commit comments

Comments
 (0)