Skip to content

Commit 1d42578

Browse files
committed
Add support to create pre-releases with a generated changelog
Backport from #271 On-behalf-of: SAP <tobias.wolf@sap.com> Signed-off-by: Tobias Wolf <wolf@b1-systems.de>
1 parent 80bcd46 commit 1d42578

File tree

2 files changed

+1
-44
lines changed

2 files changed

+1
-44
lines changed

src/gardenlinux/github/release/__init__.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,6 @@
88
LOGGER = LoggerSetup.get_logger("gardenlinux.github.release", logging.INFO)
99

1010

11-
def create_github_release(
12-
owner: str, repo: str, tag: str, commitish: str, latest: bool, body: str
13-
) -> int | None:
14-
token = os.environ.get("GITHUB_TOKEN")
15-
if not token:
16-
raise ValueError("GITHUB_TOKEN environment variable not set")
17-
18-
headers = {
19-
"Authorization": f"token {token}",
20-
"Accept": "application/vnd.github.v3+json",
21-
}
22-
23-
data = {
24-
"tag_name": tag,
25-
"target_commitish": commitish,
26-
"name": tag,
27-
"body": body,
28-
"draft": False,
29-
"prerelease": False,
30-
"make_latest": "true" if latest else "false",
31-
}
32-
33-
response = requests.post(
34-
f"https://api.github.com/repos/{owner}/{repo}/releases",
35-
headers=headers,
36-
data=json.dumps(data),
37-
timeout=REQUESTS_TIMEOUTS,
38-
)
39-
40-
if response.status_code == 201:
41-
LOGGER.info("Release created successfully")
42-
response_json = response.json()
43-
return int(response_json.get("id")) # Will raise KeyError if missing
44-
else:
45-
LOGGER.error("Failed to create release")
46-
LOGGER.debug(response.json())
47-
response.raise_for_status()
48-
49-
return None # Simply to make mypy happy. should not be reached.
50-
51-
5211
def write_to_release_id_file(release_id: str | int) -> None:
5312
try:
5413
with open(RELEASE_ID_FILE, "w") as file:

src/gardenlinux/github/release/__main__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
from gardenlinux.logger import LoggerSetup
66

77
from ..release_notes import create_github_release_notes
8-
from . import (
9-
write_to_release_id_file,
10-
)
8+
from . import write_to_release_id_file
119
from .release import Release
1210

1311
LOGGER = LoggerSetup.get_logger("gardenlinux.github", logging.INFO)

0 commit comments

Comments
 (0)