Skip to content

Commit 7ce5092

Browse files
committed
feat: use sensible defaults for manifest format
The build orig tarball script will choose a sensible format based on the version of the source by default: - .NET 10+ will use the newer json based release manifest format. - .NET 8 & 9 will use the legacy release manifest format. - otherwise no release manifest will be created The behaviour can also be manually specified: - If the --force-use-legacy-manifest-format flag is specified, the legacy release manifest format will be used. - If the --force-use-json-manifest-format flag is specified, the newer json based release manifest format will be used. - The --force-no-manifest flag will force that no release manifest file will be created. These flags are mutually exclusive. Signed-off-by: Dominik Viererbe <[email protected]>
1 parent 027fa5d commit 7ce5092

File tree

2 files changed

+49
-14
lines changed

2 files changed

+49
-14
lines changed

.github/workflows/build-orig-tarball.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
description: 'Git commit-ish (e.g. the tag) of the .NET release'
1212
required: true
1313
type: string
14+
buildId:
15+
description: 'Official Build Id (only needed for .NET 10+)'
16+
required: false
17+
type: string
1418
bootstrap:
1519
description: 'Build bootstraped orig tarballs'
1620
required: false
@@ -60,7 +64,6 @@ jobs:
6064
--clone-git-repository "${DOTNET_GIT_REPOSITORY}" \
6165
--source-version "${{inputs.sourceVersion}}" \
6266
--git-reference "${{inputs.gitCommitish}}" \
63-
--use-legacy-manifest-format \
6467
--vendor-name "Canonical Ltd." \
6568
--verbose
6669
@@ -101,7 +104,7 @@ jobs:
101104
--clone-git-repository "${DOTNET_GIT_REPOSITORY}" \
102105
--source-version "${{inputs.sourceVersion}}" \
103106
--git-reference "${{inputs.gitCommitish}}" \
104-
--use-legacy-manifest-format \
107+
--build-id "${{inputs.buildId}}" \
105108
--vendor-name "Canonical Ltd." \
106109
--include-bootstrap-sdk \
107110
--verbose

eng/build-orig-tarball.py

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,27 @@ def __AddManifestOptions(self) -> None:
170170
help="Name of the organization/person that created the "
171171
"orig tarball.")
172172

173-
manifestGroup.add_argument(
174-
"--use-legacy-manifest-format",
175-
dest="UseLegacyManifestFormat",
173+
manifestFormatGroup = manifestGroup.add_mutually_exclusive_group()
174+
175+
manifestFormatGroup.add_argument(
176+
"--force-no-manifest",
177+
dest="ForceNoManifest",
178+
action="store_true",
179+
help="Force that no release manifest file will be created.")
180+
181+
manifestFormatGroup.add_argument(
182+
"--force-use-legacy-manifest-format",
183+
dest="ForceUseLegacyManifestFormat",
176184
action="store_true",
177-
help="Use the legacy (release.info) release manifest format used "
178-
"by earlier Canonical packages. Without this option a "
179-
"manifest.json file will be created.")
185+
help="Force the use of the legacy release manifest file format "
186+
"(release.info).")
187+
188+
manifestFormatGroup.add_argument(
189+
"--force-use-json-manifest-format",
190+
dest="ForceUseJsonManifestFormat",
191+
action="store_true",
192+
help="Force the use of the newer json based release manifest file "
193+
"format (release.json).")
180194

181195
def __AddBootstrappingOption(self) -> None:
182196
bootstrappinGroup = self.add_argument_group("bootstrapping options")
@@ -277,7 +291,19 @@ def __init__(self, args: argparse.Namespace, hostDpkgArchitecture: str):
277291
LogWarning("Specified .NET security partners repository "
278292
"access token was not used")
279293

280-
self.UseLegacyManifestFormat: bool = args.UseLegacyManifestFormat
294+
self.ReleaseManifestFormat: str | None = None
295+
296+
if args.ForceNoManifest:
297+
self.ReleaseManifestFormat = None
298+
elif args.ForceUseJsonManifestFormat:
299+
self.ReleaseManifestFormat = "json"
300+
elif args.ForceUseLegacyManifestFormat:
301+
self.ReleaseManifestFormat = "legacy"
302+
elif self.DotnetMajorVersion >= 10:
303+
self.ReleaseManifestFormat = "json"
304+
elif self.DotnetMajorVersion >= 8:
305+
self.ReleaseManifestFormat = "legacy"
306+
281307
self.VendorName: str | None = args.VendorName
282308
self.SourceLinkRepository: str | None = args.SourceLinkRepository
283309

@@ -415,7 +441,7 @@ def PrintState(self) -> None:
415441
- TarballName={self.TarballName}
416442
417443
Manifest options:
418-
- UseLegacyManifestFormat={self.UseLegacyManifestFormat}
444+
- ReleaseManifestFormat={self.ReleaseManifestFormat}
419445
- SourceLinkRepository={self.SourceLinkRepository}
420446
- VendorName={self.VendorName}
421447
- BuildId={self.BuildId}
@@ -731,18 +757,22 @@ def GetHeadCommitSha1Hash(context: InvocationContext) -> str:
731757

732758

733759
def CreateReleaseManifest(context: InvocationContext) -> None:
760+
if context.ReleaseManifestFormat is None:
761+
return
762+
734763
sourceRepository = context.SourceLinkRepository
735764
sourceVersion = GetHeadCommitSha1Hash(context)
736765
buildIdUnused = False
737766

738-
if context.UseLegacyManifestFormat:
767+
if context.ReleaseManifestFormat == "legacy":
768+
releaseManifestFileName = "release.info"
739769
releaseManifestFileContent = (
740770
f"RM_GIT_REPO={sourceRepository}\n"
741771
f"RM_GIT_COMMIT={sourceVersion}")
742772

743-
releaseManifestFileName = "release.info"
744773
buildIdUnused = context.BuildId is not None
745-
else:
774+
elif context.ReleaseManifestFormat == "json":
775+
releaseManifestFileName = "release.json"
746776
releaseManifestData = {
747777
"sourceRepository": sourceRepository,
748778
"sourceVersion": sourceVersion,
@@ -759,7 +789,9 @@ def CreateReleaseManifest(context: InvocationContext) -> None:
759789
buildIdUnused = context.BuildId is not None
760790

761791
releaseManifestFileContent = json.dumps(releaseManifestData, indent=4)
762-
releaseManifestFileName = "release.json"
792+
else:
793+
LogErrorAndExit("Unsupported release manifest format "
794+
f"'{context.ReleaseManifestFormat}'.")
763795

764796
if buildIdUnused:
765797
LogWarning(f"Build id '{context.BuildId}' is unused")

0 commit comments

Comments
 (0)