mirror of
https://github.com/saltstack/salt-bootstrap.git
synced 2025-04-09 22:31:53 +00:00
Respect the old directory layout
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
parent
453812a6ea
commit
c07acc326e
1 changed files with 72 additions and 38 deletions
110
tools/release.py
110
tools/release.py
|
@ -5,6 +5,8 @@ These commands are used to release Salt Bootstrap.
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
@ -59,54 +61,86 @@ def s3_publish(ctx: Context, branch: str, key_id: str = None):
|
||||||
ctx.info(
|
ctx.info(
|
||||||
f"Uploading release artifacts to {tools.utils.RELEASE_BUCKET_NAME!r} bucket ..."
|
f"Uploading release artifacts to {tools.utils.RELEASE_BUCKET_NAME!r} bucket ..."
|
||||||
)
|
)
|
||||||
paths_to_upload = [
|
upload_files = {
|
||||||
f"{tools.utils.GPG_KEY_FILENAME}.gpg",
|
"stable": {
|
||||||
f"{tools.utils.GPG_KEY_FILENAME}.pub",
|
f"{tools.utils.GPG_KEY_FILENAME}.gpg": [
|
||||||
]
|
f"bootstrap/stable/{tools.utils.GPG_KEY_FILENAME}.gpg",
|
||||||
copy_exclusions = [
|
],
|
||||||
".asc",
|
f"{tools.utils.GPG_KEY_FILENAME}.pub": [
|
||||||
".gpg",
|
f"bootstrap/stable/{tools.utils.GPG_KEY_FILENAME}.pub",
|
||||||
".pub",
|
],
|
||||||
".sha256",
|
"bootstrap-salt.sh": [
|
||||||
]
|
"bootstrap/stable/bootstrap-salt.sh",
|
||||||
|
],
|
||||||
|
"bootstrap-salt.sh.sha256": [
|
||||||
|
"bootstrap/stable/bootstrap-salt.sh.sha256",
|
||||||
|
"bootstrap/stable/bootstrap/sha256",
|
||||||
|
],
|
||||||
|
"bootstrap-salt.ps1": [
|
||||||
|
"bootstrap/stable/bootstrap-salt.ps1",
|
||||||
|
],
|
||||||
|
"bootstrap-salt.ps1.sha256": [
|
||||||
|
"bootstrap/stable/bootstrap-salt.ps1.sha256",
|
||||||
|
"bootstrap/stable/winbootstrap/sha256",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"develop": {
|
||||||
|
f"{tools.utils.GPG_KEY_FILENAME}.gpg": [
|
||||||
|
f"bootstrap/develop/{tools.utils.GPG_KEY_FILENAME}.gpg",
|
||||||
|
],
|
||||||
|
f"{tools.utils.GPG_KEY_FILENAME}.pub": [
|
||||||
|
f"bootstrap/develop/{tools.utils.GPG_KEY_FILENAME}.pub",
|
||||||
|
],
|
||||||
|
"bootstrap-salt.sh": [
|
||||||
|
"bootstrap/develop/bootstrap-salt.sh",
|
||||||
|
"bootstrap/develop/bootstrap/develop",
|
||||||
|
],
|
||||||
|
"bootstrap-salt.sh.sha256": [
|
||||||
|
"bootstrap/develop/bootstrap-salt.sh.sha256",
|
||||||
|
],
|
||||||
|
"bootstrap-salt.ps1": [
|
||||||
|
"bootstrap/develop/bootstrap-salt.ps1",
|
||||||
|
"bootstrap/develop/winbootstrap/develop",
|
||||||
|
],
|
||||||
|
"bootstrap-salt.ps1.sha256": [
|
||||||
|
"bootstrap/develop/bootstrap-salt.ps1.sha256",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
files_to_upload: list[tuple[str, str]] = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Export the GPG key in use
|
# Export the GPG key in use
|
||||||
tools.utils.export_gpg_key(ctx, key_id, tools.utils.REPO_ROOT)
|
tools.utils.export_gpg_key(ctx, key_id, tools.utils.REPO_ROOT)
|
||||||
|
for lpath, rpaths in upload_files[branch].items():
|
||||||
for fpath in tools.utils.REPO_ROOT.glob("bootstrap-salt.*"):
|
ctx.info(f"Processing {lpath} ...")
|
||||||
if fpath.suffix in copy_exclusions:
|
if lpath.endswith(".sha256") and not os.path.exists(lpath):
|
||||||
continue
|
ret = ctx.run(
|
||||||
paths_to_upload.append(fpath.name)
|
"sha256sum",
|
||||||
ret = ctx.run(
|
lpath.replace(".sha256", ""),
|
||||||
"sha256sum",
|
capture=True,
|
||||||
fpath.relative_to(tools.utils.REPO_ROOT),
|
check=False,
|
||||||
capture=True,
|
|
||||||
check=False,
|
|
||||||
)
|
|
||||||
if ret.returncode:
|
|
||||||
ctx.error(
|
|
||||||
f"Failed to get the sha256sum of {fpath.relative_to(tools.utils.REPO_ROOT)}"
|
|
||||||
)
|
)
|
||||||
ctx.exit(1)
|
if ret.returncode:
|
||||||
shasum_file = fpath.parent / f"{fpath.name}.sha256"
|
ctx.error(f"Failed to get the sha256sum of {lpath}")
|
||||||
shasum_file.write_bytes(ret.stdout)
|
ctx.exit(1)
|
||||||
paths_to_upload.append(shasum_file.name)
|
pathlib.Path(lpath).write_bytes(ret.stdout)
|
||||||
tools.utils.gpg_sign(ctx, key_id, shasum_file)
|
for rpath in rpaths:
|
||||||
paths_to_upload.append(f"{shasum_file.name}.asc")
|
files_to_upload.append((lpath, rpath))
|
||||||
tools.utils.gpg_sign(ctx, key_id, fpath)
|
if not lpath.endswith((".gpg", ".pub")):
|
||||||
paths_to_upload.append(f"{fpath.name}.asc")
|
tools.utils.gpg_sign(ctx, key_id, pathlib.Path(lpath))
|
||||||
|
files_to_upload.append((f"{lpath}.asc", f"{rpaths[0]}.asc"))
|
||||||
|
|
||||||
for path in paths_to_upload:
|
for lpath, rpath in sorted(files_to_upload):
|
||||||
upload_path = f"bootstrap/{branch}/{path}"
|
size = pathlib.Path(lpath).stat().st_size
|
||||||
size = fpath.stat().st_size
|
ctx.info(f" Uploading {lpath} -> {rpath}")
|
||||||
ctx.info(f" {upload_path}")
|
|
||||||
with tools.utils.create_progress_bar(file_progress=True) as progress:
|
with tools.utils.create_progress_bar(file_progress=True) as progress:
|
||||||
task = progress.add_task(description="Uploading...", total=size)
|
task = progress.add_task(description="Uploading...", total=size)
|
||||||
s3.upload_file(
|
s3.upload_file(
|
||||||
fpath,
|
lpath,
|
||||||
tools.utils.RELEASE_BUCKET_NAME,
|
tools.utils.RELEASE_BUCKET_NAME,
|
||||||
upload_path,
|
rpath,
|
||||||
Callback=tools.utils.UpdateProgress(progress, task),
|
Callback=tools.utils.UpdateProgress(progress, task),
|
||||||
)
|
)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|
Loading…
Add table
Reference in a new issue