@@ -172,41 +172,6 @@ def authors_to_creators(authors):
172172
173173 print (f"Removed inherited file { f ['filename' ]} " )
174174
175-
176- # Upload release archive
177-
178-
179- tag = os .environ ["GITHUB_REF_NAME" ]
180- repo_name = os .environ ['GITHUB_REPOSITORY' ]
181- owner , repo = repo_name .split ("/" , 1 )
182-
183-
184- archive_url = (
185- f"https://github.com/"
186- f"{ repo_name } "
187- f"/archive/refs/tags/{ tag } .zip"
188- )
189-
190- archive_name = f"{ owner } -{ repo } -{ tag } .zip"
191-
192- download = requests .get (archive_url )
193- download .raise_for_status ()
194-
195- with open (archive_name , "wb" ) as fp :
196- fp .write (download .content )
197-
198- with open (archive_name , "rb" ) as fp :
199- r = requests .put (
200- f"{ bucket_url } /{ archive_name } " ,
201- data = fp ,
202- headers = upload_headers
203- )
204-
205- r .raise_for_status ()
206-
207- print (f"Uploaded { archive_name } " )
208-
209-
210175# Upload lesson PDF from the gh-pages branch
211176# (built by sphinx.yml as OUTPUT_BASENAME.pdf, OUTPUT_BASENAME being
212177# "{owner}-{repo}")
@@ -236,29 +201,38 @@ def authors_to_creators(authors):
236201
237202print (f"Uploaded { pdf_name } " )
238203
204+ # Upload release archive
239205
240- # Show the PDF first (Zenodo previews the first file in the list).
241206
242- r = requests .get (
243- f"{ BASE_URL } /deposit/depositions/{ deposition_id } /files" ,
244- headers = json_headers ,
207+ tag = os .environ ["GITHUB_REF_NAME" ]
208+ repo_name = os .environ ['GITHUB_REPOSITORY' ]
209+ owner , repo = repo_name .split ("/" , 1 )
210+
211+
212+ archive_url = (
213+ f"https://github.com/"
214+ f"{ repo_name } "
215+ f"/archive/refs/tags/{ tag } .zip"
245216)
246217
247- r . raise_for_status ()
218+ archive_name = f" { owner } - { repo } - { tag } .zip"
248219
249- files = r .json ()
220+ download = requests .get (archive_url )
221+ download .raise_for_status ()
250222
251- sort_order = sorted (files , key = lambda f : f ["filename" ] != pdf_name )
223+ with open (archive_name , "wb" ) as fp :
224+ fp .write (download .content )
252225
253- r = requests .put (
254- f"{ BASE_URL } /deposit/depositions/{ deposition_id } /files" ,
255- data = json .dumps ([{"id" : f ["id" ]} for f in sort_order ]),
256- headers = json_headers ,
257- )
226+ with open (archive_name , "rb" ) as fp :
227+ r = requests .put (
228+ f"{ bucket_url } /{ archive_name } " ,
229+ data = fp ,
230+ headers = upload_headers
231+ )
258232
259233r .raise_for_status ()
260234
261- print (f"File order: { [ f [ 'filename' ] for f in sort_order ] } " )
235+ print (f"Uploaded { archive_name } " )
262236
263237
264238# Update metadata
0 commit comments