From cb2f89e86431123f09964eceb1dcb99465918c25 Mon Sep 17 00:00:00 2001 From: ksemenenko Date: Wed, 2 Dec 2026 12:18:02 +0100 Subject: [PATCH] Fix Storage package version before publication --- .github/scripts/verify-published-packages.py | 21 +++++++++++++++++--- .github/workflows/release.yml | 9 ++++++++- Directory.Build.props | 1 - docs/Development/setup.md | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.github/scripts/verify-published-packages.py b/.github/scripts/verify-published-packages.py index bbc6fd11..05817015 100644 --- a/.github/scripts/verify-published-packages.py +++ b/.github/scripts/verify-published-packages.py @@ -21,7 +21,7 @@ def metadata(package_bytes): repository.get("commit") if repository is not None else None) -def verify(directory, commit, timeout): +def packed_metadata(directory, commit, expected_version): packages = sorted(directory.glob("*.nupkg")) if not packages: raise ValueError("No packages to verify") @@ -31,9 +31,18 @@ def verify(directory, commit, timeout): package_id, version, source_commit = identity if not re.fullmatch(r"ManagedCode\.Storage(?:\.[A-Za-z0-9_.-]+)?", package_id): raise ValueError(f"Unexpected package identity: {package_id}") + if version != expected_version: + raise ValueError(f"{package_id}: packed version {version} does not match the release version {expected_version}") if source_commit != commit: raise ValueError(f"{package_id}: packed repository commit does not match the release commit") + if package_id in pending: + raise ValueError(f"{package_id}: duplicate packed artifact") pending[package_id] = identity + return pending + + +def verify(pending, commit, timeout): + package_count = len(pending) deadline = time.monotonic() + timeout while pending: for package_id, identity in list(pending.items()): @@ -56,13 +65,19 @@ def verify(directory, commit, timeout): if time.monotonic() >= deadline: raise TimeoutError("Packages unavailable before the publication deadline: " + ", ".join(pending)) time.sleep(min(20, max(0, deadline - time.monotonic()))) - print(f"Verified all {len(packages)} published packages", flush=True) + print(f"Verified all {package_count} published packages", flush=True) if __name__ == "__main__": parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("directory", type=Path) parser.add_argument("commit") + parser.add_argument("version") + parser.add_argument("--packed-only", action="store_true") parser.add_argument("--timeout-seconds", type=int, default=600) arguments = parser.parse_args() - verify(arguments.directory, arguments.commit, arguments.timeout_seconds) + packages = packed_metadata(arguments.directory, arguments.commit, arguments.version) + if arguments.packed_only: + print(f"Verified all {len(packages)} packed artifacts for release {arguments.version}", flush=True) + else: + verify(packages, arguments.commit, arguments.timeout_seconds) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a5bec0d..31b2d680 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,6 +61,11 @@ jobs: - name: Pack NuGet packages run: dotnet pack ManagedCode.Storage.slnx --configuration Release --no-build -p:IncludeSymbols=false -p:SymbolPackageFormat=snupkg --output ./artifacts + - name: Verify every packed artifact + env: + RELEASE_VERSION: ${{ steps.version.outputs.version }} + run: python3 .github/scripts/verify-published-packages.py ./artifacts "$GITHUB_SHA" "$RELEASE_VERSION" --packed-only + - name: Upload artifacts uses: actions/upload-artifact@v4 with: @@ -162,7 +167,9 @@ jobs: fi - name: Verify every package on the public feed - run: python3 .github/scripts/verify-published-packages.py ./artifacts "${{ github.sha }}" + env: + RELEASE_VERSION: ${{ needs.build.outputs.version }} + run: python3 .github/scripts/verify-published-packages.py ./artifacts "$GITHUB_SHA" "$RELEASE_VERSION" create-release: name: Create GitHub Release and Tag diff --git a/Directory.Build.props b/Directory.Build.props index 64543abf..8b4c77e0 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -30,7 +30,6 @@ https://github.com/managedcode/Storage Managed Code - Storage 10.1.16 - 10.1.15 diff --git a/docs/Development/setup.md b/docs/Development/setup.md index 988ad073..3a840997 100644 --- a/docs/Development/setup.md +++ b/docs/Development/setup.md @@ -82,7 +82,7 @@ The HTTP tests run the library's `StorageControllerBase` against Kestrel and the Regression tests also cover offset and EOF handling in VFS reads, directory statistics, deletion-cache invalidation, failed synchronous/asynchronous write commits, canceled container creation, native SFTP upload cancellation, password/private-key SFTP round trips, and existing files without extensions. Actual InputFile browser uploads verify byte integrity through both memory/disk branches and controller/storage helpers, configured limits above 500 KB, and disposal of the upload-owned temporary files. Azure SDK stream creation and option callbacks retain container identity and credential references; Google Drive default options retain the shared-drive flag. `LocalFile` preserves the path of an existing extensionless file; generated extensionless paths retain their temporary-file naming policy. -The release workflow validates every published `.nupkg` against its packed identity, version and repository commit on the public NuGet feed before creating the GitHub release. A successful push command alone is not a publication receipt. +Set the release version once in `Directory.Build.props`. NuGet packing inherits that version from `Version`. The release workflow checks each packed artifact against the expected version and commit before publication, then verifies every published package against the packed identity on the public NuGet feed before creating the GitHub release. ### Container versions and service qualification