31
31
_HERE = Path (__file__ ).parent .resolve ()
32
32
_TEMPLATES = _HERE / "templates"
33
33
34
- _SUMMARY = Path (os .getenv ("GITHUB_STEP_SUMMARY" )).open ("a" )
34
+ _summary_path = os .getenv ("GITHUB_STEP_SUMMARY" )
35
+ assert _summary_path is not None
36
+ _SUMMARY = Path (_summary_path ).open ("a" )
37
+
35
38
_RENDER_SUMMARY = os .getenv ("GHA_SIGSTORE_PYTHON_SUMMARY" , "true" ) == "true"
36
39
_DEBUG = os .getenv ("GHA_SIGSTORE_PYTHON_INTERNAL_BE_CAREFUL_DEBUG" , "false" ) != "false"
37
40
@@ -117,49 +120,49 @@ def _fatal_help(msg):
117
120
sigstore_python_env ["SIGSTORE_LOGLEVEL" ] = "DEBUG"
118
121
119
122
identity_token = os .getenv ("GHA_SIGSTORE_PYTHON_IDENTITY_TOKEN" )
120
- if identity_token != "" :
123
+ if identity_token :
121
124
sigstore_sign_args .extend (["--identity-token" , identity_token ])
122
125
123
126
client_id = os .getenv ("GHA_SIGSTORE_PYTHON_OIDC_CLIENT_ID" )
124
- if client_id != "" :
127
+ if client_id :
125
128
sigstore_sign_args .extend (["--oidc-client-id" , client_id ])
126
129
127
130
client_secret = os .getenv ("GHA_SIGSTORE_PYTHON_OIDC_CLIENT_SECRET" )
128
- if client_secret != "" :
131
+ if client_secret :
129
132
sigstore_sign_args .extend (["--oidc-client-secret" , client_secret ])
130
133
131
134
signature = os .getenv ("GHA_SIGSTORE_PYTHON_SIGNATURE" )
132
- if signature != "" :
135
+ if signature :
133
136
sigstore_sign_args .extend (["--signature" , signature ])
134
137
sigstore_verify_args .extend (["--signature" , signature ])
135
138
signing_artifact_paths .append (signature )
136
139
137
140
certificate = os .getenv ("GHA_SIGSTORE_PYTHON_CERTIFICATE" )
138
- if certificate != "" :
141
+ if certificate :
139
142
sigstore_sign_args .extend (["--certificate" , certificate ])
140
143
sigstore_verify_args .extend (["--certificate" , certificate ])
141
144
signing_artifact_paths .append (certificate )
142
145
143
146
bundle = os .getenv ("GHA_SIGSTORE_PYTHON_BUNDLE" )
144
- if bundle != "" :
147
+ if bundle :
145
148
sigstore_sign_args .extend (["--bundle" , bundle ])
146
149
sigstore_verify_args .extend (["--bundle" , bundle ])
147
150
signing_artifact_paths .append (bundle )
148
151
149
152
fulcio_url = os .getenv ("GHA_SIGSTORE_PYTHON_FULCIO_URL" )
150
- if fulcio_url != "" :
153
+ if fulcio_url :
151
154
sigstore_sign_args .extend (["--fulcio-url" , fulcio_url ])
152
155
153
156
rekor_url = os .getenv ("GHA_SIGSTORE_PYTHON_REKOR_URL" )
154
- if rekor_url != "" :
157
+ if rekor_url :
155
158
sigstore_global_args .extend (["--rekor-url" , rekor_url ])
156
159
157
160
ctfe = os .getenv ("GHA_SIGSTORE_PYTHON_CTFE" )
158
- if ctfe != "" :
161
+ if ctfe :
159
162
sigstore_sign_args .extend (["--ctfe" , ctfe ])
160
163
161
164
rekor_root_pubkey = os .getenv ("GHA_SIGSTORE_PYTHON_REKOR_ROOT_PUBKEY" )
162
- if rekor_root_pubkey != "" :
165
+ if rekor_root_pubkey :
163
166
sigstore_global_args .extend (["--rekor-root-pubkey" , rekor_root_pubkey ])
164
167
165
168
if os .getenv ("GHA_SIGSTORE_PYTHON_STAGING" , "false" ) != "false" :
@@ -170,15 +173,15 @@ def _fatal_help(msg):
170
173
_fatal_help ("verify-cert-identity must be specified when verify is enabled" )
171
174
elif not enable_verify and verify_cert_identity :
172
175
_fatal_help ("verify-cert-identity cannot be specified without verify: true" )
173
- else :
176
+ elif verify_cert_identity :
174
177
sigstore_verify_args .extend (["--cert-identity" , verify_cert_identity ])
175
178
176
179
verify_oidc_issuer = os .getenv ("GHA_SIGSTORE_PYTHON_VERIFY_OIDC_ISSUER" )
177
180
if enable_verify and not verify_oidc_issuer :
178
181
_fatal_help ("verify-oidc-issuer must be specified when verify is enabled" )
179
182
elif not enable_verify and verify_oidc_issuer :
180
183
_fatal_help ("verify-oidc-issuer cannot be specified without verify: true" )
181
- else :
184
+ elif verify_oidc_issuer :
182
185
sigstore_verify_args .extend (["--cert-oidc-issuer" , verify_oidc_issuer ])
183
186
184
187
if os .getenv ("GHA_SIGSTORE_PYTHON_RELEASE_SIGNING_ARTIFACTS" ) == "true" :
@@ -211,8 +214,8 @@ def _fatal_help(msg):
211
214
if "--bundle" not in sigstore_sign_args :
212
215
signing_artifact_paths .append (f"{ file_ } .sigstore" )
213
216
214
- sigstore_sign_args .extend (files )
215
- sigstore_verify_args .extend (files )
217
+ sigstore_sign_args .extend ([ str ( f ) for f in files ] )
218
+ sigstore_verify_args .extend ([ str ( f ) for f in files ] )
216
219
217
220
_debug (f"signing: sigstore-python { [str (a ) for a in sigstore_sign_args ]} " )
218
221
@@ -273,7 +276,9 @@ def _fatal_help(msg):
273
276
#
274
277
# In GitHub Actions, environment variables can be made to persist across
275
278
# workflow steps by appending to the file at `GITHUB_ENV`.
276
- with Path (os .getenv ("GITHUB_ENV" )).open ("a" ) as gh_env :
279
+ _github_env = os .getenv ("GITHUB_ENV" )
280
+ assert _github_env is not None
281
+ with Path (_github_env ).open ("a" ) as gh_env :
277
282
# Multiline values must match the following syntax:
278
283
#
279
284
# {name}<<{delimiter}
0 commit comments