FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnative/scripts/release-assets.py at main · pythonnative/pythonnative · GitHub
pythonnative
/
pythonnative
Public
Notifications
You must be signed in to change notification settings
Fork
23
Star
131
Code
Issues
11
Pull requests
4
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnative
/
scripts
/
release-assets.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
43 lines (35 loc) · 1.43 KB
Breadcrumbs
pythonnative
/
scripts
/
release-assets.py
Copy path
File metadata and controls
43 lines (35 loc) · 1.43 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Preserve the exact distribution bytes across retries of a PyPI upload."""
import
argparse
import
json
import
subprocess
from
pathlib
import
Path
def
sync_assets
(
tag
:
str
,
directory
:
Path
)
->
None
:
"""Upload new assets and reuse existing ones without overwriting releases.
Build timestamps can change archive hashes. Store files on the GitHub
release before publishing to PyPI, then reuse those same bytes on recovery.
The workflow validates the resulting directory again before publishing.
"""
result
=
subprocess
.
run
(
[
"gh"
,
"release"
,
"view"
,
tag
,
"--json"
,
"assets"
],
check
=
True
,
capture_output
=
True
,
text
=
True
,
)
existing
=
{
asset
[
"name"
]
for
asset
in
json
.
loads
(
result
.
stdout
)[
"assets"
]}
for
path
in
sorted
(
directory
.
iterdir
()):
if
path
.
name
in
existing
:
subprocess
.
run
(
[
"gh"
,
"release"
,
"download"
,
tag
,
"--pattern"
,
path
.
name
,
"--dir"
,
str
(
directory
),
"--clobber"
],
check
=
True
,
)
else
:
subprocess
.
run
([
"gh"
,
"release"
,
"upload"
,
tag
,
str
(
path
)],
check
=
True
)
def
main
()
->
None
:
"""Synchronize the selected release's distribution assets."""
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
parser
.
add_argument
(
"tag"
)
parser
.
add_argument
(
"directory"
,
type
=
Path
)
args
=
parser
.
parse_args
()
sync_assets
(
args
.
tag
,
args
.
directory
)
if
__name__
==
"__main__"
:
main
()
Back
|
FazBrowse Home
|
New Git URL