Skip to content

Commit 12df7e8

Browse files
committed
incorporated changes from gardenlinux issue #3485
1 parent 7cc833a commit 12df7e8

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/gardenlinux/github/__main__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ def write_to_release_id_file(release_id):
715715
sys.exit(1)
716716

717717

718-
def create_github_release(owner, repo, tag, commitish, body):
718+
def create_github_release(owner, repo, tag, commitish, latest, body):
719719
token = os.environ.get("GITHUB_TOKEN")
720720
if not token:
721721
raise ValueError("GITHUB_TOKEN environment variable not set")
@@ -732,6 +732,7 @@ def create_github_release(owner, repo, tag, commitish, body):
732732
"body": body,
733733
"draft": False,
734734
"prerelease": False,
735+
"make_latest": latest
735736
}
736737

737738
response = requests.post(
@@ -797,6 +798,7 @@ def main():
797798
create_parser.add_argument("--repo", default="gardenlinux")
798799
create_parser.add_argument("--tag", required=True)
799800
create_parser.add_argument("--commit", required=True)
801+
create_parser.add_argument('--latest', action='store_true', default=False)
800802
create_parser.add_argument("--dry-run", action="store_true", default=False)
801803

802804
upload_parser = subparsers.add_parser("upload")
@@ -811,10 +813,12 @@ def main():
811813
if args.command == "create":
812814
body = create_github_release_notes(args.tag, args.commit)
813815
if args.dry_run:
816+
print("Dry Run ...")
817+
print("This release would be created:")
814818
print(body)
815819
else:
816820
release_id = create_github_release(
817-
args.owner, args.repo, args.tag, args.commit, body
821+
args.owner, args.repo, args.tag, args.commit, args.latest, body
818822
)
819823
write_to_release_id_file(f"{release_id}")
820824
LOGGER.info(f"Release created with ID: {release_id}")

tests/github/test_release_page.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def test_create_github_release_needs_github_token():
200200
"gardenlinux",
201201
TEST_GARDENLINUX_RELEASE,
202202
TEST_GARDENLINUX_COMMIT,
203+
False,
203204
"")
204205
assert str(exn.value) == "GITHUB_TOKEN environment variable not set", \
205206
"Expected an exception to be raised on missing GITHUB_TOKEN environment variable"
@@ -218,6 +219,7 @@ def test_create_github_release_raise_on_failure(caplog, github_token):
218219
"gardenlinux",
219220
TEST_GARDENLINUX_RELEASE,
220221
TEST_GARDENLINUX_COMMIT,
222+
False,
221223
"")
222224
assert any("Failed to create release" in record.message for record in caplog.records), "Expected a failure log record"
223225

@@ -234,6 +236,7 @@ def test_create_github_release(caplog, github_token):
234236
"gardenlinux",
235237
TEST_GARDENLINUX_RELEASE,
236238
TEST_GARDENLINUX_COMMIT,
239+
False,
237240
"") == 101
238241
assert any("Release created successfully" in record.message for record in caplog.records), "Expected a success log record"
239242

@@ -384,7 +387,7 @@ def test_script_create_dry_run(monkeypatch, capfd):
384387
gh.main()
385388
captured = capfd.readouterr()
386389

387-
assert captured.out == f"{TEST_GARDENLINUX_RELEASE} {TEST_GARDENLINUX_COMMIT}\n", \
390+
assert captured.out == f"Dry Run ...\nThis release would be created:\n{TEST_GARDENLINUX_RELEASE} {TEST_GARDENLINUX_COMMIT}\n", \
388391
"Expected dry-run create to return generated release notes text"
389392

390393

@@ -394,7 +397,7 @@ def test_script_create(monkeypatch, caplog):
394397
monkeypatch.setattr("gardenlinux.github.__main__.create_github_release_notes",
395398
lambda tag, commit: f"{tag} {commit}")
396399
monkeypatch.setattr("gardenlinux.github.__main__.create_github_release",
397-
lambda a1, a2, a3, a4, a5: TEST_GARDENLINUX_RELEASE)
400+
lambda a1, a2, a3, a4, a5, a6: TEST_GARDENLINUX_RELEASE)
398401

399402
gh.main()
400403

0 commit comments

Comments
 (0)