From aa2da2d45c3bcd74d79b68b17d9e03c04ad74bf3 Mon Sep 17 00:00:00 2001 From: Felipe Fumero Date: Tue, 17 Nov 2026 15:03:34 -0600 Subject: [PATCH 01/15] build: document release preparation and adopt Changie --- .changes/header.tpl.md | 1 + .changes/unreleased/migrated-1.yaml | 3 + .changes/unreleased/migrated-2.yaml | 3 + .changes/unreleased/migrated-3.yaml | 3 + .changes/unreleased/migrated-4.yaml | 3 + .changes/unreleased/migrated-5.yaml | 3 + .changes/unreleased/release-preparation.yaml | 3 + .changes/v0.0.6.md | 24 +++ .changes/v1.0.0.md | 10 ++ .changes/v1.1.1.md | 11 ++ .changes/v1.2.0.md | 18 ++ .changes/v1.3.0.md | 12 ++ .changes/v1.4.0.md | 6 + .changes/v2.0.0.md | 11 ++ .changes/v3.0.0.md | 5 + .changes/v3.1.0.md | 25 +++ .changes/v4.0.0.md | 24 +++ .changes/v5.0.0.md | 15 ++ .changes/v5.1.0.md | 6 + .changes/v6.0.0.md | 6 + .changes/v6.1.0.md | 5 + .changes/v6.1.1.md | 8 + .changes/v6.2.0.md | 47 +++++ .changes/v6.2.1.md | 3 + .changes/v6.3.0.md | 7 + .changes/v6.4.0.md | 4 + .changes/v6.5.0.md | 2 + .changie.yaml | 31 ++++ .github/workflows/changelog.yml | 36 ++++ .gitignore | 1 + CHANGELOG.md | 13 +- RELEASE.md | 171 +++++++++++++++++++ scripts/health-classpath.gradle | 12 ++ scripts/release.py | 91 ++++++++++ scripts/tests/test_release.py | 109 ++++++++++++ 35 files changed, 721 insertions(+), 11 deletions(-) create mode 100644 .changes/header.tpl.md create mode 100644 .changes/unreleased/migrated-1.yaml create mode 100644 .changes/unreleased/migrated-2.yaml create mode 100644 .changes/unreleased/migrated-3.yaml create mode 100644 .changes/unreleased/migrated-4.yaml create mode 100644 .changes/unreleased/migrated-5.yaml create mode 100644 .changes/unreleased/release-preparation.yaml create mode 100644 .changes/v0.0.6.md create mode 100644 .changes/v1.0.0.md create mode 100644 .changes/v1.1.1.md create mode 100644 .changes/v1.2.0.md create mode 100644 .changes/v1.3.0.md create mode 100644 .changes/v1.4.0.md create mode 100644 .changes/v2.0.0.md create mode 100644 .changes/v3.0.0.md create mode 100644 .changes/v3.1.0.md create mode 100644 .changes/v4.0.0.md create mode 100644 .changes/v5.0.0.md create mode 100644 .changes/v5.1.0.md create mode 100644 .changes/v6.0.0.md create mode 100644 .changes/v6.1.0.md create mode 100644 .changes/v6.1.1.md create mode 100644 .changes/v6.2.0.md create mode 100644 .changes/v6.2.1.md create mode 100644 .changes/v6.3.0.md create mode 100644 .changes/v6.4.0.md create mode 100644 .changes/v6.5.0.md create mode 100644 .changie.yaml create mode 100644 .github/workflows/changelog.yml create mode 100644 RELEASE.md create mode 100644 scripts/health-classpath.gradle create mode 100644 scripts/release.py create mode 100644 scripts/tests/test_release.py diff --git a/.changes/header.tpl.md b/.changes/header.tpl.md new file mode 100644 index 000000000..825c32f0d --- /dev/null +++ b/.changes/header.tpl.md @@ -0,0 +1 @@ +# Changelog diff --git a/.changes/unreleased/migrated-1.yaml b/.changes/unreleased/migrated-1.yaml new file mode 100644 index 000000000..4e2b16cc6 --- /dev/null +++ b/.changes/unreleased/migrated-1.yaml @@ -0,0 +1,3 @@ +kind: Changed +body: "`toString()` of credential-bearing structures (`B2AccountAuthorization`, `B2FileSseForRequest`, `B2WebhookConfiguration`, `B2WebhookCustomHeader`, and `B2HeadersImpl`) omits sensitive values; `B2WebhookCustomHeader` omits all header values." +time: 2026-11-16T00:00:00Z diff --git a/.changes/unreleased/migrated-2.yaml b/.changes/unreleased/migrated-2.yaml new file mode 100644 index 000000000..0770b706e --- /dev/null +++ b/.changes/unreleased/migrated-2.yaml @@ -0,0 +1,3 @@ +kind: Changed +body: "`B2EventNotificationRule` now orders and deduplicates rules by `maxEventsPerBatch`, so rules that differ only by batch size no longer collapse in sorted collections; it also uses direct webhook settings instead of the former string-based order (url, headers, then signing secret), so callers that persist or diff ordered rules may observe a different order." +time: 2026-11-16T00:00:00Z diff --git a/.changes/unreleased/migrated-3.yaml b/.changes/unreleased/migrated-3.yaml new file mode 100644 index 000000000..a3622dee1 --- /dev/null +++ b/.changes/unreleased/migrated-3.yaml @@ -0,0 +1,3 @@ +kind: Changed +body: "Security / behaviour change: the three-argument `B2EventNotification.parse` overloads now require a signature header and a signing secret; receivers should answer HTTP 401 on `B2SignatureVerificationException`.\n A missing or empty signature header throws `B2SignatureVerificationException`; a null or empty signing secret throws `IllegalArgumentException`." +time: 2026-11-16T00:00:00Z diff --git a/.changes/unreleased/migrated-4.yaml b/.changes/unreleased/migrated-4.yaml new file mode 100644 index 000000000..7705c8fa0 --- /dev/null +++ b/.changes/unreleased/migrated-4.yaml @@ -0,0 +1,3 @@ +kind: Changed +body: "Signature comparison is now constant-time." +time: 2026-11-16T00:00:00Z diff --git a/.changes/unreleased/migrated-5.yaml b/.changes/unreleased/migrated-5.yaml new file mode 100644 index 000000000..3f0d67c26 --- /dev/null +++ b/.changes/unreleased/migrated-5.yaml @@ -0,0 +1,3 @@ +kind: Added +body: "Added `B2EventNotification.parseUnverified`, which parses without checking a signature. The one-argument `parse` overloads are deprecated in its favor." +time: 2026-11-16T00:00:00Z diff --git a/.changes/unreleased/release-preparation.yaml b/.changes/unreleased/release-preparation.yaml new file mode 100644 index 000000000..2f79be178 --- /dev/null +++ b/.changes/unreleased/release-preparation.yaml @@ -0,0 +1,3 @@ +kind: Changed +body: Document release preparation and generate the changelog and Gradle version from Changie release notes. +time: 2026-11-17T00:00:00Z diff --git a/.changes/v0.0.6.md b/.changes/v0.0.6.md new file mode 100644 index 000000000..263a38ed1 --- /dev/null +++ b/.changes/v0.0.6.md @@ -0,0 +1,24 @@ +## [0.0.6] - 2017-08-17 +### Added +* These changes were driven by switching our internal b2-sdk uses to use the http client from the sdk instead of a +different, custom interface. + +[Unreleased]: https://github.com/Backblaze/b2-sdk-java/compare/v6.4.0...HEAD +[6.4.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v6.4.0 +[6.3.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v6.3.0 +[6.2.1]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v6.2.1 +[6.2.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v6.2.0 +[6.1.1]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v6.1.1 +[6.1.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v6.1.0 +[6.0.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v6.0.0 +[5.0.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v5.0.0 +[4.0.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v4.0.0 +[3.1.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v3.1.0 +[3.0.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v3.0.0 +[2.0.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v2.0.0 +[1.4.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v1.4.0 +[1.3.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v1.3.0 +[1.2.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v1.2.0 +[1.1.1]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v1.1.1 +[1.0.0]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v1.0.0 +[0.0.6]: https://github.com/Backblaze/b2-sdk-java/releases/tag/v-0.0.6-alpha diff --git a/.changes/v1.0.0.md b/.changes/v1.0.0.md new file mode 100644 index 000000000..78125779a --- /dev/null +++ b/.changes/v1.0.0.md @@ -0,0 +1,10 @@ +## [1.0.0] - 2017-09-08 +### Added +* We have been using the SDK in production for a while at Backblaze and we're feature complete (for now), so we're going 1.0! + + We hope you enjoy it. + + Please let us know how it works for you. :) + + thanks, + ab diff --git a/.changes/v1.1.1.md b/.changes/v1.1.1.md new file mode 100644 index 000000000..b3a01e4f1 --- /dev/null +++ b/.changes/v1.1.1.md @@ -0,0 +1,11 @@ +## [1.1.1] - 2017-11-01 +### Added +* B2FileVersion now has string constants for "actions" +* Download request objects now have an optional 'b2ContentDisposition' field. +* B2StorageClient now has `getDownloadByIdUrl()` and `getDownloadByNameUrl()` +* B2 command-line program now has an option to get_download_authorization +* List buckets now has an optional 'bucketTypes' field. + +### Fixed +* Percent encode file names when downloading by name +* Large file uploader now uses RetryPolicySupplier in all cases, instead of just part of the code. diff --git a/.changes/v1.2.0.md b/.changes/v1.2.0.md new file mode 100644 index 000000000..0d5b3a870 --- /dev/null +++ b/.changes/v1.2.0.md @@ -0,0 +1,18 @@ +## [1.2.0] - 2017-11-30 +### Added +* Adds support setting CorsRules on buckets. +* B2StorageClient now exposes the following methods. + You should read the comments about why you probably + want to let the SDK handle things for you instead + of calling them. ;) + - `getAccountAuthorization()` + - `getUploadUrl()` + - `getUploadPartUrl()` + +### Fixed +* Speeds up writing json (by doing custom UTF8 encoding instead of using the generic java versions). + (and a bug fix which changed the behavior of B2Json.toJson(...outputStream) to not close the stream.) +* While uploading a large file, the caller provides a ExecutorService. + if that service rejects a task we submit, we throw a + B2LocalException instead of letting the RejectedExecutionException + (a RuntimeException) percolate up. diff --git a/.changes/v1.3.0.md b/.changes/v1.3.0.md new file mode 100644 index 000000000..ea66ce2e3 --- /dev/null +++ b/.changes/v1.3.0.md @@ -0,0 +1,12 @@ +## [1.3.0] - 2018-05-04 +### Added +* Add `deleteAllFilesInBucket()` and `getFileInfoByName()`. (thanks, valenpo!) +* Add support for upcoming ApplicationKeys apis. (thanks, valenpo!) +* Expose `startLargeFile()` and `finishLargeFile()` +* Add support for "union types" in B2Json. +* Add default codes for exception classes so `B2Exception.create()` can be used for HEAD. + +### Fixed +* Explicitly set user-agent on HttpClient to keep HttpClient from doing a bunch of unneeded work. +* Improve use of clocks in unit tests to make the tests less order dependent. +* Make search for "file info" headers in B2Headers check header names case-insensitively! diff --git a/.changes/v1.4.0.md b/.changes/v1.4.0.md new file mode 100644 index 000000000..2b25dec66 --- /dev/null +++ b/.changes/v1.4.0.md @@ -0,0 +1,6 @@ +## [1.4.0] - 2018-05-23 +### Added +* Add BigInteger support to B2Json. + +### Fixed +* Percent decoding of file name returned from `getFileInfoByName()` diff --git a/.changes/v2.0.0.md b/.changes/v2.0.0.md new file mode 100644 index 000000000..db12f4868 --- /dev/null +++ b/.changes/v2.0.0.md @@ -0,0 +1,11 @@ +## [2.0.0] - 2018-10-17 +### Changed `[Incompatible]` +* The SDK now uses version 2 of the B2 APIs, which deals with restricted application keys differently +* B2Json type handler interface takes B2JsonOptions as a parameter, and not an int bitmask + +### Added +* B2Json support for versioned structures + +### Fixed +* Remembering account ID after authorizing with application key +* B2Json now serialized unions correctly diff --git a/.changes/v3.0.0.md b/.changes/v3.0.0.md new file mode 100644 index 000000000..20db9376a --- /dev/null +++ b/.changes/v3.0.0.md @@ -0,0 +1,5 @@ +## [3.0.0] - 2019-05-01 +### Added +* Renaming the application key terminology to the new convention +* Being able to call `b2FromJsonOrThrow()` to check if you can parse + a JSON String into a given object diff --git a/.changes/v3.1.0.md b/.changes/v3.1.0.md new file mode 100644 index 000000000..6fb978e79 --- /dev/null +++ b/.changes/v3.1.0.md @@ -0,0 +1,25 @@ +## [3.1.0] - 2019-05-16 +### Added +* Added `@B2Json.sensitive` annotation to redact fields when B2Json is + used with the new redactSensitive option set to true. +* Added `B2ContentSource.createContentSourceWithRangeOrNull()` which + is used by the large file uploader to give the content source the + opportunity to make a more efficient content source for a range of + the file. this is really useful if the content isn't coming from + memory or a local file because the default implementation reads + and discards data to get to the desired range. Added sample + UploadLargeFileFromUrl and UrlContentSource. +* Added support for using okhttp3 as the HTTP client instead of + Apache's HttpClient. there are limitations with this + implementation for uploading files that are about 2GB or + larger. See README.md for details. +* Added B2StorageClientFactory interface for creating + B2StorageClients without having to select a particular + implementation at build time. The static `createDefaultFactory()` + method can be used to create a B2StorageClient using either of the + two official web client implementations, whichever is in the + classpath at runtime. The sample programs use this now so they + can be used with either web client implementation. + +### Fixed +* Don't use default character set in B2Json; explicitly use UTF8. diff --git a/.changes/v4.0.0.md b/.changes/v4.0.0.md new file mode 100644 index 000000000..7b9c19c63 --- /dev/null +++ b/.changes/v4.0.0.md @@ -0,0 +1,24 @@ +## [4.0.0] - 2020-05-11 +### Added +* Removed the deprecated okhttp client +* Added 'readBuckets' and 'listAllBucketNames' application key capability names +* Added the "Expect: 100-continue" header to upload file/part requests +* Validates file info header name characters against RFC 7230 (https://tools.ietf.org/html/rfc7230#section-3.2) +* B2Json: +* Add general generics support to B2Json +* Allow generic types for top-level objects from select entry points +* Add support for parameterized classes that contain generic arrays +* Add support for CharSequence +* Add an omitNull parameter to @B2Json.optional +* Disabled URI normalization in Apache HttpClient +* Extended B2FileVersion and B2Part to include contentMd5 +* Added support to override additional download headers +* Added optional 'options' parameter in the B2Bucket and B2ApplicationKey constructor +* Added b2_copy_file support +* Added progress reporting in the B2LargeFileStorer +* Updated to version `4.5.9` of `org.apache.httpcomponents:httpclient` +* B2Bucket and B2ApplicationKey both have an `options` parameter in the constructor. These are optional. +* `B2StorageClient.DownloadByName` supports downloading files with looser naming requirements, e.g. names containing double slashes (`//`). + +### Fixed +* See the closed issues for a complete list diff --git a/.changes/v5.0.0.md b/.changes/v5.0.0.md new file mode 100644 index 000000000..47d6b865c --- /dev/null +++ b/.changes/v5.0.0.md @@ -0,0 +1,15 @@ +## [5.0.0] - 2021-05-10 +### Changed `[Incompatible]` +* Disabled automatic decompression of compressed content in HTTP client download library +* Added `updateFileRetention` and `updateLegalHold` to `B2StorageClient` +* Added `storeLargeFileFromLocalContentAsync` to `B2StorageClient` to support asynchronous large file uploads + +### Added +* Added Server-Side Encryption (SSE) support to relevant API requests/responses +* Added File Lock support to relevant API requests/responses +* Set gradle targetCompatibility to 1.8 +* Added support for java.util.SortedMap interface +* Support more than 64 fields per object + +### Fixed +* Fixed regular expression that had an unescaped '.' diff --git a/.changes/v5.1.0.md b/.changes/v5.1.0.md new file mode 100644 index 000000000..6bb61639a --- /dev/null +++ b/.changes/v5.1.0.md @@ -0,0 +1,6 @@ +## [5.1.0] - 2022-05-06 +### Added +* Added `s3ApiUrl` to `B2AccountAuthorization`. +* Updated to version `4.5.13` of `org.apache.httpcomponents:httpclient` +* Updated to version `4.13.2` of `junit:junit` +* Added Replication Configuration to Create Bucket and Update Bucket API requests/responses diff --git a/.changes/v6.0.0.md b/.changes/v6.0.0.md new file mode 100644 index 000000000..f3bda9288 --- /dev/null +++ b/.changes/v6.0.0.md @@ -0,0 +1,6 @@ +## [6.0.0] - 2022-06-03 +### Changed `[Incompatible]` +* Updated `includeExistingFiles` to be required on B2ReplicationRule + +### Added +* Updated to version `1.15` of `commons-codec`. diff --git a/.changes/v6.1.0.md b/.changes/v6.1.0.md new file mode 100644 index 000000000..587f73e21 --- /dev/null +++ b/.changes/v6.1.0.md @@ -0,0 +1,5 @@ +## [6.1.0] - 2022-09-19 +### Added +* Added support for custom upload timestamps +* Added support for Java 8's `-parameters` option so constructor parameters do not need to be reiterated in `B2Json.constructor#params` +* Added `fileLockEnabled` to `B2UpdateBucketRequest` to support enabling file lock on existing buckets diff --git a/.changes/v6.1.1.md b/.changes/v6.1.1.md new file mode 100644 index 000000000..98fdf832a --- /dev/null +++ b/.changes/v6.1.1.md @@ -0,0 +1,8 @@ +## [6.1.1] - 2022-11-10 +### Added +* Return a subtype of `B2Exception` on errors when the response body does not conform to `B2ErrorStructure`. + Returning a `B2Exception` subtype enables the `B2Retryer` to retry exceptions that may succeed on retry. + +### Fixed +* Fixed B2ListFilesIterableBase assuming a response with 0 results was the end. It now looks for + `nextFileName` being null to indicate the end. diff --git a/.changes/v6.2.0.md b/.changes/v6.2.0.md new file mode 100644 index 000000000..7e4c59056 --- /dev/null +++ b/.changes/v6.2.0.md @@ -0,0 +1,47 @@ +## [6.2.0] - 2024-04-15 +### Added +* Added support to specify B2Json union types using annotations. Annotation support for union types is required because + Java records do not support inheritance. Example usage: + ```java + @B2Json.union(typeField = "type") + @B2Json.unionSubtypes({ + @B2Json.unionSubtypes.type(name = "email", clazz = Email.class), + @B2Json.unionSubtypes.type(name = "sms", clazz = Sms.class) + }) + sealed interface Message permits Email, Sms { + String subject(); + } + + @B2Json.type + private record Email(@B2Json.required String subject, @B2Json.required String email) implements Message { + } + + @B2Json.type + private record Sms(@B2Json.required String subject, @B2Json.required String phoneNumber) implements Message { + } + ``` +* Added `@B2Json.type` annotation that can be used with Java records. Using `@B2Json.type` allows for the implicit + Java constructor of Java records to not require the `@B2Json.constructor` annotation. Example usage: + ```java + @B2Json.type + record Point(@B2Json.required int x, @B2Json.required int y) { } + ``` +* Added support for B2 Event Notifications +* Added B2Json `fromJson` methods that take a `java.io.Reader` as input for JSON +* Added B2StorageClient.storePartsForLargeFile +* Added support for daysFromStartingToCancelingUnfinishedLargeFiles to B2LifecycleRule +* Added the `serializedName` annotation to rename the serialized Json member name +* Added support for AtomicLongArray in B2Json +* Added support for custom upload timestamps + +### Changed +* Optimized `B2DateTimeUtil.formatFguidDateTime` +* Reduced memory allocation for small input when deserializing byte[] to JSON +* Reduced lock contention in B2Clock +* Updated B2Json `fromJson` methods to utilize a BufferedReader when deserializing JSON for performance improvement +* Reduced lock contention in B2AccountAuthorizationCache +* Reduced lock contention in B2Json +* Updated internal python for building to python3 + +### Fixed +* Fixed union types to ignore extra and discarded fields when deserializing JSON to Java objects diff --git a/.changes/v6.2.1.md b/.changes/v6.2.1.md new file mode 100644 index 000000000..b6bdbbc5b --- /dev/null +++ b/.changes/v6.2.1.md @@ -0,0 +1,3 @@ +## [6.2.1] - 2024-07-16 +### Added +* Added `eventId` field to `B2EventNotificationEvent`. diff --git a/.changes/v6.3.0.md b/.changes/v6.3.0.md new file mode 100644 index 000000000..42b10c3cd --- /dev/null +++ b/.changes/v6.3.0.md @@ -0,0 +1,7 @@ +## [6.3.0] - 2024-11-08 +### Added +* Fixed `B2StorageClient.deleteAllFilesInBucket` so it uses `fileVersions` instead of `fileNames`. +* Added `maxEventsPerBatch` field to `B2WebhookConfiguration`. + +### Changed +* Validate idle connections after 2 seconds of inactivity diff --git a/.changes/v6.4.0.md b/.changes/v6.4.0.md new file mode 100644 index 000000000..9a17e78a2 --- /dev/null +++ b/.changes/v6.4.0.md @@ -0,0 +1,4 @@ +## [6.4.0] - 2025-05-14 +### Added +* Add `readBucketLogging` and `writeBucketLogging` capabilities. +* Close idle connections after 4 seconds of inactivity. diff --git a/.changes/v6.5.0.md b/.changes/v6.5.0.md new file mode 100644 index 000000000..5c35ce2ba --- /dev/null +++ b/.changes/v6.5.0.md @@ -0,0 +1,2 @@ +## [6.5.0] - 2025-12-15 +* Add `readBucketLifecycleRules` and `writeBucketLifecycleRules` capabilities. diff --git a/.changie.yaml b/.changie.yaml new file mode 100644 index 000000000..b18b3393b --- /dev/null +++ b/.changie.yaml @@ -0,0 +1,31 @@ +changesDir: .changes +unreleasedDir: unreleased +headerPath: header.tpl.md +changelogPath: CHANGELOG.md +versionExt: md +versionFormat: '## [{{.VersionNoPrefix}}] - {{.Time.Format "2006-01-02"}}' +kindFormat: '### {{.Kind}}' +changeFormat: '* {{.Body}}' +kinds: + - label: Added + auto: minor + - label: Changed + auto: minor + - label: Deprecated + auto: minor + - label: Removed + auto: major + - label: Fixed + auto: patch + - label: Security + auto: patch +newlines: + afterChangelogHeader: 0 + beforeChangelogVersion: 1 + endOfVersion: 1 + afterKind: 1 + beforeKind: 1 +replacements: + - path: gradle.properties + find: '^version=.*' + replace: 'version={{.VersionNoPrefix}}' diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 000000000..b6e37c586 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,36 @@ +name: Changelog + +on: + pull_request: + branches: [master, api-v2, 7.x] + push: + branches: [master] + +permissions: + contents: read + +jobs: + changelog-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + with: + fetch-depth: 0 + persist-credentials: false + - uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 + with: + go-version: '1.24.0' + cache: false + - name: Install Changie + run: go install github.com/miniscruff/changie@v1.24.0 + - name: Validate changelog + env: + BASE_SHA: ${{ github.event.pull_request.base.sha }} + run: | + if [ -n "$BASE_SHA" ]; then + python3 scripts/release.py changelog-check --base "$BASE_SHA" + else + python3 scripts/release.py changelog-check + fi + - name: Test release metadata checks + run: python3 -m unittest discover -s scripts/tests -v diff --git a/.gitignore b/.gitignore index b63368639..6fd4dd8f7 100644 --- a/.gitignore +++ b/.gitignore @@ -12,5 +12,6 @@ out/ hs_err_pid* .DS_Store +__pycache__/ !gradle/wrapper/gradle-wrapper.jar diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c43cf915..ef15c1585 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,17 +1,8 @@ # Changelog -## [Unreleased] -### Changed -* `toString()` of credential-bearing structures (`B2AccountAuthorization`, `B2FileSseForRequest`, `B2WebhookConfiguration`, `B2WebhookCustomHeader`, and `B2HeadersImpl`) omits sensitive values; `B2WebhookCustomHeader` omits all header values. -* `B2EventNotificationRule` now orders and deduplicates rules by `maxEventsPerBatch`, so rules that differ only by batch size no longer collapse in sorted collections; it also uses direct webhook settings instead of the former string-based order (url, headers, then signing secret), so callers that persist or diff ordered rules may observe a different order. -* Security / behaviour change: the three-argument `B2EventNotification.parse` overloads now require a signature header and a signing secret; receivers should answer HTTP 401 on `B2SignatureVerificationException`. - A missing or empty signature header throws `B2SignatureVerificationException`; a null or empty signing secret throws `IllegalArgumentException`. -* Signature comparison is now constant-time. - -### Added -* Added `B2EventNotification.parseUnverified`, which parses without checking a signature. The one-argument `parse` overloads are deprecated in its favor. ## [6.5.0] - 2025-12-15 -* Add `readBucketLifecycleRules` and `writeBucketLifecycleRules` capabilities. +* Add `readBucketLifecycleRules` and `writeBucketLifecycleRules` capabilities. + ## [6.4.0] - 2025-05-14 ### Added * Add `readBucketLogging` and `writeBucketLogging` capabilities. diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 000000000..0aba5b075 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,171 @@ +# Releasing the B2 SDK for Java + +A release is a reviewed version commit on `master`, an annotated, signed `vX.Y.Z` tag on that +commit, and the same version published to Maven Central. This process follows the release-prep +approach in [Blazer's release guide](https://github.com/Backblaze/blazer/blob/main/RELEASE.md). + +## Prerequisites + +- JDK 11 and the checked-in Gradle wrapper; the build also runs the JDK 17 test module. +- Python 3, Git, GitHub CLI (`gh auth status`), GnuPG or OpenSSH for tag signing. +- Changie v1.24.0, a standalone Go binary. Install with + `go install github.com/miniscruff/changie@v1.24.0` using Go 1.24 or newer, then put + `$(go env GOPATH)/bin` on `PATH`. This does not change the Java toolchain. +- Maven Central publishing credentials and artifact-signing secrets remain configured for + `.github/workflows/deploy.yml`: `SONATYPE_TOKEN_USERNAME`, `SONATYPE_TOKEN_PASSWORD`, + `GPG_SIGNING_KEY`, and `GPG_PASSPHRASE`. Tag signing and Maven artifact signing are separate. + +Do not run a publishing task locally as a verification step. A tag push starts the production +deployment, including closing and releasing the Sonatype staging repository. + +## Changelog and versioning + +Use semantic versioning: fixes use a patch release, compatible features a minor release, and +incompatible changes a major release. Choose the version explicitly; a `Changed` entry alone +does not determine whether the release is compatible. + +Each PR adds a fragment rather than editing `CHANGELOG.md`: + +```bash +changie new --kind Fixed --body 'Describe the observable change.' +python3 scripts/release.py changelog-check +python3 -m unittest discover -s scripts/tests -v +``` + +Kinds are Added, Changed, Deprecated, Removed, Fixed, and Security. Keep unpublished security +details out of public fragments. Existing release history is preserved in `.changes/v*.md`; +unreleased changes live in `.changes/unreleased/*.yaml`. `CHANGELOG.md` contains the generated +released history. `changie merge` also sets `version=` in `gradle.properties` from the latest +version notes. Do not edit the generated changelog or bump the Gradle version independently. +The `changelog-check` CI job verifies generated output, version consistency, and a fragment for +each PR (or a complete batch and version update for a release-prep PR). + +## Milestones and release preparation + +1. Select the version and create its milestone before preparing the release. Assign every + intended issue and PR to it. Publicly track public work only; unpublished advisories remain + in GitHub Security Advisories. Deferred work moves to the next milestone with a written reason. + + ```bash + export VERSION=6.5.1 # choose the actual next version + export TAG="v$VERSION" + gh api --method POST repos/Backblaze/b2-sdk-java/milestones -f title="$TAG" + gh issue edit --milestone "$TAG" + gh pr edit --milestone "$TAG" + git fetch origin master --tags + git switch -c "release/$TAG" origin/master + ``` + +2. Confirm the release scope has merged and the relevant CI checks are green. Check the + repository Security tab: an open medium, high, or critical finding holds the release, + including findings without a patched dependency. Failures to read findings are unverified, + not clean. A maintainer must resolve or dismiss findings with a written reason before release. + +3. Batch the changelog and update the version in one operation: + + ```bash + changie batch "$TAG" --dry-run --allow-no-changes=false + changie batch "$TAG" --allow-no-changes=false + changie merge + python3 scripts/release.py changelog-check + python3 scripts/release.py notes "$TAG" > /tmp/b2-java-release-notes.md + git diff -- gradle.properties CHANGELOG.md .changes/ + ``` + + Review the generated `.changes/$TAG.md` and regenerate with `changie merge` after any edits. + A release-prep PR changes only `.changes/`, `CHANGELOG.md`, and `gradle.properties`. Keep + workflow or SDK behavior changes in separate PRs. + +4. Verify locally without publishing: + + ```bash + python3 -m unittest discover -s scripts/tests -v + ./gradlew build --no-daemon + RELEASE_BUILD=true ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository \ + createBundle --dry-run --no-daemon \ + -PsonatypeUsername=dry-run -PsonatypePassword=dry-run + ``` + + The placeholder credentials are only for task-graph validation with `--dry-run`; this does + not contact Sonatype, sign artifacts, or prove that production secrets are usable. + Run the local health check below against a fresh loopback simulator as well. + +5. Commit and open a release-prep PR linked to its issue, assign its milestone, and request a + maintainer review. Include the release notes, build, health-check, and dry-run results. + A human merges it after required CI and review pass. Do not tag an unmerged PR. + +## Tag and deploy + +Tag the merged release-prep commit, which may differ from the latest tip of `master`: + +```bash +git fetch origin master --tags +SHA=$(gh pr view --json mergeCommit --jq .mergeCommit.oid) +git merge-base --is-ancestor "$SHA" origin/master +git show "$SHA:gradle.properties" | grep -Fx "version=$VERSION" +git log -1 --oneline "$SHA" + +# GPG: use your full signing-key fingerprint. +git -c gpg.format=openpgp tag -s -u "$TAG" "$SHA" -m "$TAG" +git verify-tag "$TAG" + +# Alternatively, with a registered SSH signing key: +# git -c gpg.format=ssh -c user.signingkey="$HOME/.ssh/id_ed25519.pub" \ +# tag -s "$TAG" "$SHA" -m "$TAG" +# git -c gpg.format=ssh -c gpg.ssh.allowedSignersFile= verify-tag "$TAG" + +git push origin "$TAG" +``` + +The tag-triggered deploy workflow publishes using the existing Gradle command: + +```bash +./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository createBundle --no-daemon --stacktrace +``` + +Maven Central, GPG artifact signing, the Sonatype staging endpoint, and the release/close tasks +are unchanged by the changelog tooling. Never run this production command as a dry-run substitute. + +## Verify the published release + +1. Inspect the deployment run for the tag and confirm the Sonatype close/release step succeeded: + `gh run list --workflow deploy.yml --branch "$TAG"` and `gh run view --log-failed`. +2. Confirm the GitHub Release contains this version's changelog section and all three module bundles: + `gh release view "$TAG" --json tagName,body,assets`. +3. After Maven Central indexing completes, check each module and its signature: + + ```bash + for module in core httpclient samples; do + url="https://repo.maven.apache.org/maven2/com/backblaze/b2/b2-sdk-$module/$VERSION/b2-sdk-$module-$VERSION.pom" + curl --fail --show-error --location "$url" -o "/tmp/b2-sdk-$module-$VERSION.pom" + curl --fail --show-error --location "$url.asc" -o "/tmp/b2-sdk-$module-$VERSION.pom.asc" + gpg --verify "/tmp/b2-sdk-$module-$VERSION.pom.asc" "/tmp/b2-sdk-$module-$VERSION.pom" + done + ``` + + Verify using the established Maven artifact-signing public key, independently of tag keys. +4. Confirm there are no open issues/PRs left in the version milestone, then close it. Publish any + advisories coordinated with the release only after the fixed artifacts are available. + +## Local health check + +Use a local B2 simulator with the fixed test credentials and an empty `sdkharness-healthcheck` +bucket. This check authorizes, uploads, downloads, compares bytes, lists, and deletes; it refuses +non-loopback endpoints. It must print `SDKHARNESS_RESULT` with `health`, `golden-path`, and `PASS`. +Set `SDKHARNESS_SIMULATOR_URL` to the running simulator's IPv4 loopback URL, then run: + +```bash +: "${SDKHARNESS_SIMULATOR_URL:?set the local simulator URL, e.g. http://127.0.0.1:8180}" +./gradlew build --no-daemon +CP=$(./gradlew -q -I scripts/health-classpath.gradle :b2-sdk-httpclient:healthClasspath) +SDKHARNESS_TEST_LEVEL=health SDKHARNESS_SCENARIO=golden-path \ + B2_BUCKET_NAME=sdkharness-healthcheck SDKHARNESS_JAVA_CLASSPATH="$CP" \ + .sdkharness/tests/run-health +``` + +## Recovery + +Never move a published tag or reuse a Maven Central version. If a release fails, inspect staging +and Central before retrying: the existing deploy command closes and releases staging repositories. +Do not blindly rerun a partially completed publish. If artifacts are already published, ship a new +patch version. Reverting SDK code does not remove artifacts already used by consumers. diff --git a/scripts/health-classpath.gradle b/scripts/health-classpath.gradle new file mode 100644 index 000000000..c60a3f873 --- /dev/null +++ b/scripts/health-classpath.gradle @@ -0,0 +1,12 @@ +// Prints the SDK and dependency classpath after ./gradlew build; does not change publication tasks. +allprojects { + afterEvaluate { + if (path == ':b2-sdk-httpclient') { + tasks.register('healthClasspath') { + doLast { + println sourceSets.main.runtimeClasspath.asPath + } + } + } + } +} diff --git a/scripts/release.py b/scripts/release.py new file mode 100644 index 000000000..4220833f3 --- /dev/null +++ b/scripts/release.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python3 +"""Release metadata checks. Uses the standard library and the pinned Changie binary.""" + +import argparse +import os +import pathlib +import re +import shutil +import subprocess +import sys +import tempfile + + +VERSION = r"[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?" + + +def project_version(root): + versions = re.findall(r"^version=(.+)$", (root / "gradle.properties").read_text(), re.M) + if len(versions) != 1 or not re.fullmatch(VERSION, versions[0]): + raise ValueError("gradle.properties must contain exactly one semantic version property") + return versions[0] + + +def release_notes(root, tag): + if not re.fullmatch("v" + VERSION, tag): + raise ValueError("expected a version tag such as v6.5.1") + if tag != "v" + project_version(root): + raise ValueError("tag does not match gradle.properties") + path = root / ".changes" / (tag + ".md") + if not path.is_file(): + raise ValueError("release notes are missing: " + path.name) + notes = path.read_text().strip() + heading = re.escape("## [" + tag[1:] + "]") + section = re.search(r"^" + heading + r"[^\n]*\n.*?(?=^## \[|\Z)", + (root / "CHANGELOG.md").read_text(), re.M | re.S) + if not section or notes != section.group().strip(): + raise ValueError("release notes and CHANGELOG.md disagree; run changie merge") + return notes + "\n" + + +def changelog_check(root, base): + changie = os.environ.get("CHANGIE", "changie") + fragments = list((root / ".changes/unreleased").glob("*.yaml")) + with tempfile.TemporaryDirectory(prefix="b2-changelog-") as temporary: + target = pathlib.Path(temporary) + shutil.copy(root / ".changie.yaml", target) + shutil.copy(root / "gradle.properties", target) + shutil.copytree(root / ".changes", target / ".changes") + subprocess.run([changie, "merge"], cwd=target, check=True) + if (target / "CHANGELOG.md").read_bytes() != (root / "CHANGELOG.md").read_bytes(): + raise ValueError("CHANGELOG.md is generated; run changie merge") + if project_version(target) != project_version(root): + raise ValueError("gradle.properties must match the latest Changie version") + if fragments: + subprocess.run([changie, "batch", "patch", "--dry-run", "--allow-no-changes=false"], + cwd=target, check=True, stdout=subprocess.DEVNULL) + if base: + changes = subprocess.check_output( + ["git", "diff", "--name-status", base + "...HEAD"], cwd=root, text=True + ).splitlines() + added = [line.split("\t")[-1] for line in changes if line.startswith(("A\t", "M\t"))] + if not any(name.startswith(".changes/unreleased/") and name.endswith(".yaml") for name in added): + tag = "v" + project_version(root) + if ".changes/" + tag + ".md" not in added or "gradle.properties" not in added or fragments: + raise ValueError("add a Changie fragment, or batch all fragments in a release-prep PR") + release_notes(root, tag) + print("changelog-check: generated changelog, fragments, and version agree") + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--root", type=pathlib.Path, default=pathlib.Path(__file__).resolve().parents[1]) + commands = parser.add_subparsers(dest="command", required=True) + notes = commands.add_parser("notes") + notes.add_argument("tag") + changelog = commands.add_parser("changelog-check") + changelog.add_argument("--base") + args = parser.parse_args() + try: + if args.command == "notes": + print(release_notes(args.root, args.tag), end="") + elif args.command == "changelog-check": + changelog_check(args.root, args.base) + except (ValueError, OSError, subprocess.CalledProcessError) as error: + print("HOLD: " + str(error), file=sys.stderr) + return 1 + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/scripts/tests/test_release.py b/scripts/tests/test_release.py new file mode 100644 index 000000000..148b64127 --- /dev/null +++ b/scripts/tests/test_release.py @@ -0,0 +1,109 @@ +"""Local contract tests for release preparation; no network or credentials required.""" + +import pathlib +import os +import shutil +import subprocess +import sys +import tempfile +import unittest + + +SCRIPT = pathlib.Path(__file__).resolve().parents[1] / "release.py" + + +class ReleaseNotesTest(unittest.TestCase): + def setUp(self): + self.temporary = tempfile.TemporaryDirectory() + self.addCleanup(self.temporary.cleanup) + self.root = pathlib.Path(self.temporary.name) + (self.root / ".changes").mkdir() + self.notes = "## [1.2.3] - 2026-01-02\n\n### Fixed\n\n- Keep this release only.\n" + (self.root / ".changes/v1.2.3.md").write_text(self.notes) + (self.root / "CHANGELOG.md").write_text( + "# Changelog\n\n" + self.notes + "\n## [1.2.2] - 2026-01-01\n\n- Older.\n" + ) + (self.root / "gradle.properties").write_text("version=1.2.3\ngroup=com.backblaze.b2\n") + + def run_notes(self, tag="v1.2.3"): + return subprocess.run( + [sys.executable, str(SCRIPT), "--root", str(self.root), "notes", tag], + capture_output=True, text=True, + ) + + def test_extracts_exact_release_section(self): + result = self.run_notes() + self.assertEqual(0, result.returncode, result.stderr) + self.assertEqual(self.notes, result.stdout) + self.assertNotIn("Older", result.stdout) + + def test_rejects_tag_version_mismatch(self): + result = self.run_notes("v1.2.4") + self.assertNotEqual(0, result.returncode) + self.assertIn("gradle.properties", result.stderr) + + def test_rejects_missing_notes(self): + (self.root / ".changes/v1.2.3.md").unlink() + result = self.run_notes() + self.assertNotEqual(0, result.returncode) + self.assertIn("release notes", result.stderr) + + def test_rejects_edited_generated_changelog(self): + (self.root / "CHANGELOG.md").write_text("# Changelog\n\n" + self.notes.replace("Keep", "Changed")) + result = self.run_notes() + self.assertNotEqual(0, result.returncode) + self.assertIn("disagree", result.stderr) + + def test_rejects_path_as_tag(self): + result = self.run_notes("../v1.2.3") + self.assertNotEqual(0, result.returncode) + self.assertIn("version tag", result.stderr) + + def test_rejects_duplicate_version_property(self): + (self.root / "gradle.properties").write_text("version=1.2.3\nversion=1.2.4\n") + result = self.run_notes() + self.assertNotEqual(0, result.returncode) + self.assertIn("exactly one", result.stderr) + + +class ChangelogTest(unittest.TestCase): + def setUp(self): + self.temporary = tempfile.TemporaryDirectory() + self.addCleanup(self.temporary.cleanup) + self.root = pathlib.Path(self.temporary.name) + repository = SCRIPT.parents[1] + for name in (".changie.yaml", "gradle.properties", "CHANGELOG.md"): + shutil.copy(repository / name, self.root) + shutil.copytree(repository / ".changes", self.root / ".changes") + self.changie = os.environ.get("CHANGIE", "changie") + + def run_check(self): + return subprocess.run( + [sys.executable, str(SCRIPT), "--root", str(self.root), "changelog-check"], + capture_output=True, text=True, + ) + + def test_current_generated_changelog_matches(self): + result = self.run_check() + self.assertEqual(0, result.returncode, result.stderr) + + def test_hand_edited_changelog_is_rejected_without_modifying_it(self): + path = self.root / "CHANGELOG.md" + edited = path.read_text() + "\nHand edited.\n" + path.write_text(edited) + result = self.run_check() + self.assertNotEqual(0, result.returncode) + self.assertIn("generated", result.stderr) + self.assertEqual(edited, path.read_text()) + + def test_batch_and_merge_update_gradle_version_and_release_notes(self): + for arguments in (("batch", "v6.5.1", "--allow-no-changes=false"), ("merge",)): + subprocess.run([self.changie, *arguments], cwd=self.root, check=True, capture_output=True) + self.assertIn("version=6.5.1\n", (self.root / "gradle.properties").read_text()) + self.assertTrue((self.root / ".changes/v6.5.1.md").is_file()) + result = self.run_check() + self.assertEqual(0, result.returncode, result.stderr) + + +if __name__ == "__main__": + unittest.main() From 0c88b005fa4242c2ed2625c8e277131decdbb19d Mon Sep 17 00:00:00 2001 From: Felipe Fumero Date: Tue, 17 Nov 2026 15:16:25 -0600 Subject: [PATCH 02/15] test: keep changelog generation valid across releases --- .changie.yaml | 1 + scripts/tests/test_release.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.changie.yaml b/.changie.yaml index b18b3393b..c5a62b230 100644 --- a/.changie.yaml +++ b/.changie.yaml @@ -6,6 +6,7 @@ versionExt: md versionFormat: '## [{{.VersionNoPrefix}}] - {{.Time.Format "2006-01-02"}}' kindFormat: '### {{.Kind}}' changeFormat: '* {{.Body}}' +footerFormat: '[{{.VersionNoPrefix}}]: https://github.com/Backblaze/b2-sdk-java/releases/tag/{{.Version}}' kinds: - label: Added auto: minor diff --git a/scripts/tests/test_release.py b/scripts/tests/test_release.py index 148b64127..7c746180f 100644 --- a/scripts/tests/test_release.py +++ b/scripts/tests/test_release.py @@ -75,6 +75,9 @@ def setUp(self): for name in (".changie.yaml", "gradle.properties", "CHANGELOG.md"): shutil.copy(repository / name, self.root) shutil.copytree(repository / ".changes", self.root / ".changes") + (self.root / ".changes/unreleased/contract-test.yaml").write_text( + 'kind: Fixed\nbody: Exercise a complete release batch.\ntime: 2026-01-01T00:00:00Z\n' + ) self.changie = os.environ.get("CHANGIE", "changie") def run_check(self): @@ -97,10 +100,14 @@ def test_hand_edited_changelog_is_rejected_without_modifying_it(self): self.assertEqual(edited, path.read_text()) def test_batch_and_merge_update_gradle_version_and_release_notes(self): - for arguments in (("batch", "v6.5.1", "--allow-no-changes=false"), ("merge",)): + current = next(line[8:] for line in (self.root / "gradle.properties").read_text().splitlines() + if line.startswith("version=")) + major, minor, patch = current.split("-")[0].split(".") + version = major + "." + minor + "." + str(int(patch) + 1) + for arguments in (("batch", "v" + version, "--allow-no-changes=false"), ("merge",)): subprocess.run([self.changie, *arguments], cwd=self.root, check=True, capture_output=True) - self.assertIn("version=6.5.1\n", (self.root / "gradle.properties").read_text()) - self.assertTrue((self.root / ".changes/v6.5.1.md").is_file()) + self.assertIn("version=" + version + "\n", (self.root / "gradle.properties").read_text()) + self.assertTrue((self.root / (".changes/v" + version + ".md")).is_file()) result = self.run_check() self.assertEqual(0, result.returncode, result.stderr) From 7e2a952cc2c2fb932baf7cd2735a6a305e816a08 Mon Sep 17 00:00:00 2001 From: Felipe Fumero Date: Tue, 17 Nov 2026 15:24:52 -0600 Subject: [PATCH 03/15] docs: make release tag commands self-contained --- .github/workflows/changelog.yml | 3 +++ RELEASE.md | 2 ++ scripts/tests/test_release.py | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index b6e37c586..fa25f7b0d 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -1,3 +1,6 @@ +# Copyright 2026, Backblaze Inc. All Rights Reserved. +# License https://www.backblaze.com/using_b2_code.html + name: Changelog on: diff --git a/RELEASE.md b/RELEASE.md index 0aba5b075..52c23f6cc 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -99,6 +99,8 @@ each PR (or a complete batch and version update for a release-prep PR). Tag the merged release-prep commit, which may differ from the latest tip of `master`: ```bash +: "${TAG:?export the release tag, e.g. v6.5.1}" +VERSION="${TAG#v}" git fetch origin master --tags SHA=$(gh pr view --json mergeCommit --jq .mergeCommit.oid) git merge-base --is-ancestor "$SHA" origin/master diff --git a/scripts/tests/test_release.py b/scripts/tests/test_release.py index 7c746180f..3ee7eea22 100644 --- a/scripts/tests/test_release.py +++ b/scripts/tests/test_release.py @@ -112,5 +112,25 @@ def test_batch_and_merge_update_gradle_version_and_release_notes(self): self.assertEqual(0, result.returncode, result.stderr) +class ReleaseInstructionsTest(unittest.TestCase): + def test_tag_commands_work_with_only_tag_exported(self): + guide = (SCRIPT.parents[1] / "RELEASE.md").read_text() + block = guide.split("## Tag and deploy", 1)[1].split("```bash", 1)[1].split("```", 1)[0] + block = block.replace("", "123").replace("", "fixture-key") + with tempfile.TemporaryDirectory() as temporary: + root = pathlib.Path(temporary) + git = root / "git" + git.write_text("#!/bin/sh\nif [ \"$1\" = show ]; then printf 'version=1.2.3\\n'; fi\n") + git.chmod(0o755) + gh = root / "gh" + gh.write_text("#!/bin/sh\nprintf '0123456789012345678901234567890123456789\\n'\n") + gh.chmod(0o755) + environment = dict(os.environ, PATH=str(root) + os.pathsep + os.environ["PATH"], TAG="v1.2.3") + environment.pop("VERSION", None) + result = subprocess.run(["bash", "-euo", "pipefail", "-c", block], env=environment, + capture_output=True, text=True) + self.assertEqual(0, result.returncode, result.stdout + result.stderr) + + if __name__ == "__main__": unittest.main() From ba0096d779eb9d5317cac4d2c14127fbcf7f283c Mon Sep 17 00:00:00 2001 From: Felipe Fumero Date: Tue, 17 Nov 2026 15:33:16 -0600 Subject: [PATCH 04/15] ci: validate automated action updates without release fragments --- .github/workflows/changelog.yml | 5 ++++- RELEASE.md | 3 +++ scripts/release.py | 12 +++++++++-- scripts/tests/test_release.py | 37 +++++++++++++++++++++++++++++++-- 4 files changed, 52 insertions(+), 5 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index fa25f7b0d..18a039614 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -29,9 +29,12 @@ jobs: - name: Validate changelog env: BASE_SHA: ${{ github.event.pull_request.base.sha }} + PR_AUTHOR: ${{ github.event.pull_request.user.login }} run: | + flags=() + if [ "$PR_AUTHOR" = 'dependabot[bot]' ]; then flags=(--dependabot); fi if [ -n "$BASE_SHA" ]; then - python3 scripts/release.py changelog-check --base "$BASE_SHA" + python3 scripts/release.py changelog-check --base "$BASE_SHA" "${flags[@]}" else python3 scripts/release.py changelog-check fi diff --git a/RELEASE.md b/RELEASE.md index 52c23f6cc..375e02543 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -39,6 +39,9 @@ released history. `changie merge` also sets `version=` in `gradle.properties` fr version notes. Do not edit the generated changelog or bump the Gradle version independently. The `changelog-check` CI job verifies generated output, version consistency, and a fragment for each PR (or a complete batch and version update for a release-prep PR). +Dependabot PRs that only modify existing workflow YAML files do not need a release fragment; +generated-output checks and the release-tooling tests still run. Source/dependency changes outside +workflow files and human-authored changes still need a fragment. ## Milestones and release preparation diff --git a/scripts/release.py b/scripts/release.py index 4220833f3..df0fad218 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -38,7 +38,7 @@ def release_notes(root, tag): return notes + "\n" -def changelog_check(root, base): +def changelog_check(root, base, dependabot=False): changie = os.environ.get("CHANGIE", "changie") fragments = list((root / ".changes/unreleased").glob("*.yaml")) with tempfile.TemporaryDirectory(prefix="b2-changelog-") as temporary: @@ -58,6 +58,13 @@ def changelog_check(root, base): changes = subprocess.check_output( ["git", "diff", "--name-status", base + "...HEAD"], cwd=root, text=True ).splitlines() + workflow_only = changes and all( + line.startswith("M\t.github/workflows/") and line.endswith((".yml", ".yaml")) + for line in changes + ) + if dependabot and workflow_only: + print("changelog-check: validated automated workflow-only update; fragment not required") + return added = [line.split("\t")[-1] for line in changes if line.startswith(("A\t", "M\t"))] if not any(name.startswith(".changes/unreleased/") and name.endswith(".yaml") for name in added): tag = "v" + project_version(root) @@ -75,12 +82,13 @@ def main(): notes.add_argument("tag") changelog = commands.add_parser("changelog-check") changelog.add_argument("--base") + changelog.add_argument("--dependabot", action="store_true") args = parser.parse_args() try: if args.command == "notes": print(release_notes(args.root, args.tag), end="") elif args.command == "changelog-check": - changelog_check(args.root, args.base) + changelog_check(args.root, args.base, args.dependabot) except (ValueError, OSError, subprocess.CalledProcessError) as error: print("HOLD: " + str(error), file=sys.stderr) return 1 diff --git a/scripts/tests/test_release.py b/scripts/tests/test_release.py index 3ee7eea22..d9ff34288 100644 --- a/scripts/tests/test_release.py +++ b/scripts/tests/test_release.py @@ -80,9 +80,9 @@ def setUp(self): ) self.changie = os.environ.get("CHANGIE", "changie") - def run_check(self): + def run_check(self, *arguments): return subprocess.run( - [sys.executable, str(SCRIPT), "--root", str(self.root), "changelog-check"], + [sys.executable, str(SCRIPT), "--root", str(self.root), "changelog-check", *arguments], capture_output=True, text=True, ) @@ -90,6 +90,39 @@ def test_current_generated_changelog_matches(self): result = self.run_check() self.assertEqual(0, result.returncode, result.stderr) + def make_pull_request(self, path): + workflow = self.root / ".github/workflows/dependency.yml" + workflow.parent.mkdir(parents=True) + workflow.write_text("name: dependency\n") + for args in (("init", "-q"), ("config", "user.name", "Release Fixture"), + ("config", "user.email", "fixture@example.invalid"), ("add", "."), + ("-c", "commit.gpgSign=false", "commit", "-qm", "Base fixture")): + subprocess.run(["git", *args], cwd=self.root, check=True, capture_output=True) + base = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=self.root, text=True).strip() + changed = self.root / path + changed.write_text("updated fixture\n") + subprocess.run(["git", "add", "."], cwd=self.root, check=True, capture_output=True) + subprocess.run(["git", "-c", "commit.gpgSign=false", "commit", "-qm", "Update fixture"], + cwd=self.root, check=True, capture_output=True) + return base + + def test_dependabot_workflow_pin_update_needs_no_fragment(self): + base = self.make_pull_request(".github/workflows/dependency.yml") + result = self.run_check("--base", base, "--dependabot") + self.assertEqual(0, result.returncode, result.stderr) + + def test_human_workflow_update_still_requires_fragment(self): + base = self.make_pull_request(".github/workflows/dependency.yml") + result = self.run_check("--base", base) + self.assertNotEqual(0, result.returncode) + self.assertIn("fragment", result.stderr) + + def test_dependabot_source_change_still_requires_fragment(self): + base = self.make_pull_request("Source.java") + result = self.run_check("--base", base, "--dependabot") + self.assertNotEqual(0, result.returncode) + self.assertIn("fragment", result.stderr) + def test_hand_edited_changelog_is_rejected_without_modifying_it(self): path = self.root / "CHANGELOG.md" edited = path.read_text() + "\nHand edited.\n" From 89c0a19e5773735ba2be486784e75eaab228befd Mon Sep 17 00:00:00 2001 From: Felipe Fumero Date: Wed, 18 Nov 2026 16:04:33 -0600 Subject: [PATCH 05/15] fix: verify all release modules and version metadata --- RELEASE.md | 2 +- scripts/release.py | 5 +++ scripts/tests/test_release.py | 57 +++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index 375e02543..ce35f52bd 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -140,7 +140,7 @@ are unchanged by the changelog tooling. Never run this production command as a d 3. After Maven Central indexing completes, check each module and its signature: ```bash - for module in core httpclient samples; do + for module in core httpclient samples core-test-jdk17; do url="https://repo.maven.apache.org/maven2/com/backblaze/b2/b2-sdk-$module/$VERSION/b2-sdk-$module-$VERSION.pom" curl --fail --show-error --location "$url" -o "/tmp/b2-sdk-$module-$VERSION.pom" curl --fail --show-error --location "$url.asc" -o "/tmp/b2-sdk-$module-$VERSION.pom.asc" diff --git a/scripts/release.py b/scripts/release.py index df0fad218..2038cfcb0 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -51,6 +51,11 @@ def changelog_check(root, base, dependabot=False): raise ValueError("CHANGELOG.md is generated; run changie merge") if project_version(target) != project_version(root): raise ValueError("gradle.properties must match the latest Changie version") + latest = re.search(r"^## \[(" + VERSION + r")\]", + (root / "CHANGELOG.md").read_text(), re.M) + if not latest: + raise ValueError("CHANGELOG.md must contain a released version heading") + release_notes(root, "v" + latest.group(1)) if fragments: subprocess.run([changie, "batch", "patch", "--dry-run", "--allow-no-changes=false"], cwd=target, check=True, stdout=subprocess.DEVNULL) diff --git a/scripts/tests/test_release.py b/scripts/tests/test_release.py index d9ff34288..b6ec1cef4 100644 --- a/scripts/tests/test_release.py +++ b/scripts/tests/test_release.py @@ -90,6 +90,32 @@ def test_current_generated_changelog_matches(self): result = self.run_check() self.assertEqual(0, result.returncode, result.stderr) + def test_rejects_gradle_version_mismatch_with_or_without_replacements(self): + path = self.root / "gradle.properties" + properties = path.read_text() + current = next(line for line in properties.splitlines() if line.startswith("version=")) + mismatched = properties.replace(current, "version=0.0.0", 1) + path.write_text(mismatched) + for replacements in (True, False): + with self.subTest(replacements=replacements): + if not replacements: + config = self.root / ".changie.yaml" + config.write_text(config.read_text().split("\nreplacements:", 1)[0] + "\n") + result = self.run_check() + self.assertNotEqual(0, result.returncode, result.stdout) + self.assertIn("gradle.properties", result.stderr) + self.assertEqual(mismatched, path.read_text()) + + def test_rejects_latest_notes_with_a_mismatched_version_heading(self): + current = next(line[8:] for line in (self.root / "gradle.properties").read_text().splitlines() + if line.startswith("version=")) + path = self.root / (".changes/v" + current + ".md") + path.write_text(path.read_text().replace("## [" + current + "]", "## [0.0.0]", 1)) + subprocess.run([self.changie, "merge"], cwd=self.root, check=True, capture_output=True) + result = self.run_check() + self.assertNotEqual(0, result.returncode, result.stdout) + self.assertIn("gradle.properties", result.stderr) + def make_pull_request(self, path): workflow = self.root / ".github/workflows/dependency.yml" workflow.parent.mkdir(parents=True) @@ -146,6 +172,37 @@ def test_batch_and_merge_update_gradle_version_and_release_notes(self): class ReleaseInstructionsTest(unittest.TestCase): + def test_maven_verification_checks_every_published_module_and_signature(self): + guide = (SCRIPT.parents[1] / "RELEASE.md").read_text() + block = guide.split("## Verify the published release", 1)[1].split("```bash", 1)[1].split("```", 1)[0] + with tempfile.TemporaryDirectory() as temporary: + root = pathlib.Path(temporary) + curl = root / "curl" + curl.write_text( + '#!/bin/sh\nfor argument; do\n' + ' case "$argument" in https://*) printf "%s\\n" "$argument" >> "$CURL_LOG";; esac\n' + 'done\n' + ) + curl.chmod(0o755) + gpg = root / "gpg" + gpg.write_text('#!/bin/sh\nprintf "%s\\n" "$*" >> "$GPG_LOG"\n') + gpg.chmod(0o755) + environment = dict(os.environ, PATH=str(root) + os.pathsep + os.environ["PATH"], + VERSION="1.2.3", CURL_LOG=str(root / "curl.log"), GPG_LOG=str(root / "gpg.log")) + result = subprocess.run(["bash", "-euo", "pipefail", "-c", block], env=environment, + capture_output=True, text=True) + self.assertEqual(0, result.returncode, result.stdout + result.stderr) + urls = (root / "curl.log").read_text().splitlines() + signatures = (root / "gpg.log").read_text().splitlines() + for module in ("core", "httpclient", "samples", "core-test-jdk17"): + with self.subTest(module=module): + artifact = "b2-sdk-" + module + url = "https://repo.maven.apache.org/maven2/com/backblaze/b2/" + artifact + "/1.2.3/" + artifact + "-1.2.3.pom" + self.assertIn(url, urls) + self.assertIn(url + ".asc", urls) + pom = "/tmp/" + artifact + "-1.2.3.pom" + self.assertIn("--verify " + pom + ".asc " + pom, signatures) + def test_tag_commands_work_with_only_tag_exported(self): guide = (SCRIPT.parents[1] / "RELEASE.md").read_text() block = guide.split("## Tag and deploy", 1)[1].split("```bash", 1)[1].split("```", 1)[0] From f0e1f8a91e0b7d11e46db0b52f0cc3ab30cc2feb Mon Sep 17 00:00:00 2001 From: Felipe Fumero Date: Wed, 18 Nov 2026 16:14:48 -0600 Subject: [PATCH 06/15] docs: clarify verification of all published modules --- RELEASE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RELEASE.md b/RELEASE.md index ce35f52bd..3cdc1816a 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -148,6 +148,8 @@ are unchanged by the changelog tooling. Never run this production command as a d done ``` + The shared Gradle publication plugin also publishes `b2-sdk-core-test-jdk17`, so this + loop verifies all four published modules, including that test module's POM and signature. Verify using the established Maven artifact-signing public key, independently of tag keys. 4. Confirm there are no open issues/PRs left in the version milestone, then close it. Publish any advisories coordinated with the release only after the fixed artifacts are available. From 8d459f2e74ca473efece3bd542ade7df7590b530 Mon Sep 17 00:00:00 2001 From: Felipe Fumero Date: Wed, 18 Nov 2026 16:35:17 -0600 Subject: [PATCH 07/15] docs: document manual notes during release rollout --- RELEASE.md | 19 +++++++++++ scripts/tests/test_release.py | 60 ++++++++++++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index 3cdc1816a..b02648332 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -137,6 +137,25 @@ are unchanged by the changelog tooling. Never run this production command as a d `gh run list --workflow deploy.yml --branch "$TAG"` and `gh run view --log-failed`. 2. Confirm the GitHub Release contains this version's changelog section and all three module bundles: `gh release view "$TAG" --json tagName,body,assets`. + + Release standardization rolls out in stages: changelog tooling and this guide first, + then automated release notes. For releases made before notes automation is enabled, + the deployment workflow attaches the three bundles without setting a changelog-derived + body. From a checkout of the tagged commit, update those releases manually before + verifying them. Once enabled, automation supplies the notes body. + + ```bash + ( + set -euo pipefail + : "${TAG:?export the release tag, e.g. v6.5.1}" + NOTES_FILE=$(mktemp) + trap 'rm -f "$NOTES_FILE"' EXIT + python3 scripts/release.py notes "$TAG" > "$NOTES_FILE" + gh release edit "$TAG" --notes-file "$NOTES_FILE" + gh release view "$TAG" --json tagName,body,assets + ) + ``` + 3. After Maven Central indexing completes, check each module and its signature: ```bash diff --git a/scripts/tests/test_release.py b/scripts/tests/test_release.py index b6ec1cef4..802539871 100644 --- a/scripts/tests/test_release.py +++ b/scripts/tests/test_release.py @@ -1,5 +1,6 @@ """Local contract tests for release preparation; no network or credentials required.""" +import json import pathlib import os import shutil @@ -65,6 +66,61 @@ def test_rejects_duplicate_version_property(self): self.assertNotEqual(0, result.returncode) self.assertIn("exactly one", result.stderr) + def run_documented_manual_update(self): + guide = (SCRIPT.parents[1] / "RELEASE.md").read_text() + section = guide.split("## Verify the published release", 1)[1].split("\n## ", 1)[0] + blocks = [part.split("```", 1)[0] for part in section.split("```bash")[1:]] + updates = [block for block in blocks if "gh release edit" in block] + self.assertEqual(1, len(updates), "release guide must document a validated manual notes update") + script = self.root / "scripts/release.py" + script.parent.mkdir() + shutil.copy(SCRIPT, script) + binaries = self.root / "bin" + binaries.mkdir() + gh = binaries / "gh" + gh.write_text( + "#!" + sys.executable + "\n" + "import json, os, pathlib, sys\n" + "arguments = sys.argv[1:]\n" + "record = {'argv': arguments}\n" + "if arguments[:2] == ['release', 'edit']:\n" + " notes = pathlib.Path(arguments[arguments.index('--notes-file') + 1])\n" + " record.update(notes_file=str(notes), body=notes.read_text())\n" + "with open(os.environ['GH_LOG'], 'a') as output:\n" + " output.write(json.dumps(record) + '\\n')\n" + ) + gh.chmod(0o755) + notes_directory = self.root / "temporary-notes" + notes_directory.mkdir() + log = self.root / "gh.jsonl" + environment = dict(os.environ, PATH=str(binaries) + os.pathsep + os.environ["PATH"], + TAG="v1.2.3", GH_LOG=str(log), TMPDIR=str(notes_directory)) + result = subprocess.run(["bash", "-euo", "pipefail", "-c", updates[0]], cwd=self.root, + env=environment, capture_output=True, text=True) + records = [json.loads(line) for line in log.read_text().splitlines()] if log.exists() else [] + return result, records, notes_directory + + def test_documented_manual_update_uses_only_validated_version_notes(self): + result, records, notes_directory = self.run_documented_manual_update() + self.assertEqual(0, result.returncode, result.stdout + result.stderr) + self.assertEqual(2, len(records), records) + update, view = records + self.assertEqual(["release", "edit", "v1.2.3", "--notes-file", update["notes_file"]], update["argv"]) + self.assertEqual(self.notes, update["body"]) + self.assertNotIn("Older", update["body"]) + self.assertEqual(["release", "view", "v1.2.3", "--json", "tagName,body,assets"], view["argv"]) + self.assertFalse(pathlib.Path(update["notes_file"]).exists()) + self.assertEqual([], list(notes_directory.iterdir())) + + def test_documented_manual_update_rejects_invalid_notes_and_cleans_up(self): + path = self.root / ".changes/v1.2.3.md" + path.write_text(self.notes.replace("Keep", "Changed")) + result, records, notes_directory = self.run_documented_manual_update() + self.assertNotEqual(0, result.returncode) + self.assertIn("disagree", result.stderr) + self.assertEqual([], records) + self.assertEqual([], list(notes_directory.iterdir())) + class ChangelogTest(unittest.TestCase): def setUp(self): @@ -174,7 +230,9 @@ def test_batch_and_merge_update_gradle_version_and_release_notes(self): class ReleaseInstructionsTest(unittest.TestCase): def test_maven_verification_checks_every_published_module_and_signature(self): guide = (SCRIPT.parents[1] / "RELEASE.md").read_text() - block = guide.split("## Verify the published release", 1)[1].split("```bash", 1)[1].split("```", 1)[0] + section = guide.split("## Verify the published release", 1)[1].split("\n## ", 1)[0] + blocks = [part.split("```", 1)[0] for part in section.split("```bash")[1:]] + block = next(block for block in blocks if "for module in" in block) with tempfile.TemporaryDirectory() as temporary: root = pathlib.Path(temporary) curl = root / "curl" From e85b1e702c73fbb29fd22cc09b6eae85a3452e0a Mon Sep 17 00:00:00 2001 From: Felipe Fumero Date: Wed, 18 Nov 2026 16:50:16 -0600 Subject: [PATCH 08/15] fix: require new changelog fragments and stop failed tag preparation Require an added fragment for ordinary changes and preserve release-preparation handling. Pin the five migrated entries through Changie batching and merging. Make the documented tag block stop on failed metadata, ancestry, version, or signature checks, with focused regression tests. --- RELEASE.md | 39 +++++++------- scripts/release.py | 5 +- scripts/tests/test_release.py | 98 +++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+), 20 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index b02648332..dbdbf8580 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -102,24 +102,27 @@ workflow files and human-authored changes still need a fragment. Tag the merged release-prep commit, which may differ from the latest tip of `master`: ```bash -: "${TAG:?export the release tag, e.g. v6.5.1}" -VERSION="${TAG#v}" -git fetch origin master --tags -SHA=$(gh pr view --json mergeCommit --jq .mergeCommit.oid) -git merge-base --is-ancestor "$SHA" origin/master -git show "$SHA:gradle.properties" | grep -Fx "version=$VERSION" -git log -1 --oneline "$SHA" - -# GPG: use your full signing-key fingerprint. -git -c gpg.format=openpgp tag -s -u "$TAG" "$SHA" -m "$TAG" -git verify-tag "$TAG" - -# Alternatively, with a registered SSH signing key: -# git -c gpg.format=ssh -c user.signingkey="$HOME/.ssh/id_ed25519.pub" \ -# tag -s "$TAG" "$SHA" -m "$TAG" -# git -c gpg.format=ssh -c gpg.ssh.allowedSignersFile= verify-tag "$TAG" - -git push origin "$TAG" +( + set -euo pipefail + : "${TAG:?export the release tag, e.g. v6.5.1}" + VERSION="${TAG#v}" + git fetch origin master --tags + SHA=$(gh pr view --json mergeCommit --jq .mergeCommit.oid) + git merge-base --is-ancestor "$SHA" origin/master + git show "$SHA:gradle.properties" | grep -Fx "version=$VERSION" + git log -1 --oneline "$SHA" + + # GPG: use your full signing-key fingerprint. + git -c gpg.format=openpgp tag -s -u "$TAG" "$SHA" -m "$TAG" + git verify-tag "$TAG" + + # Alternatively, with a registered SSH signing key: + # git -c gpg.format=ssh -c user.signingkey="$HOME/.ssh/id_ed25519.pub" \ + # tag -s "$TAG" "$SHA" -m "$TAG" + # git -c gpg.format=ssh -c gpg.ssh.allowedSignersFile= verify-tag "$TAG" + + git push origin "$TAG" +) ``` The tag-triggered deploy workflow publishes using the existing Gradle command: diff --git a/scripts/release.py b/scripts/release.py index 2038cfcb0..18d023315 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -70,10 +70,11 @@ def changelog_check(root, base, dependabot=False): if dependabot and workflow_only: print("changelog-check: validated automated workflow-only update; fragment not required") return - added = [line.split("\t")[-1] for line in changes if line.startswith(("A\t", "M\t"))] + added = [line.split("\t")[-1] for line in changes if line.startswith("A\t")] if not any(name.startswith(".changes/unreleased/") and name.endswith(".yaml") for name in added): + updated = [line.split("\t")[-1] for line in changes if line.startswith(("A\t", "M\t"))] tag = "v" + project_version(root) - if ".changes/" + tag + ".md" not in added or "gradle.properties" not in added or fragments: + if ".changes/" + tag + ".md" not in updated or "gradle.properties" not in updated or fragments: raise ValueError("add a Changie fragment, or batch all fragments in a release-prep PR") release_notes(root, tag) print("changelog-check: generated changelog, fragments, and version agree") diff --git a/scripts/tests/test_release.py b/scripts/tests/test_release.py index 802539871..76eef4d0c 100644 --- a/scripts/tests/test_release.py +++ b/scripts/tests/test_release.py @@ -205,6 +205,59 @@ def test_dependabot_source_change_still_requires_fragment(self): self.assertNotEqual(0, result.returncode) self.assertIn("fragment", result.stderr) + def test_modifying_an_existing_fragment_does_not_cover_a_source_change(self): + base = self.make_pull_request("Source.java") + fragment = self.root / ".changes/unreleased/contract-test.yaml" + fragment.write_text(fragment.read_text().replace("complete release batch", "modified release batch")) + subprocess.run(["git", "-c", "commit.gpgSign=false", "commit", "-qam", "Edit existing fragment"], + cwd=self.root, check=True, capture_output=True) + result = self.run_check("--base", base) + self.assertNotEqual(0, result.returncode, result.stdout) + self.assertIn("fragment", result.stderr) + + def test_adding_a_new_fragment_covers_a_source_change(self): + base = self.make_pull_request("Source.java") + (self.root / ".changes/unreleased/new-change.yaml").write_text( + 'kind: Fixed\nbody: Describe the source change.\ntime: 2026-01-02T00:00:00Z\n' + ) + subprocess.run(["git", "add", "."], cwd=self.root, check=True, capture_output=True) + subprocess.run(["git", "-c", "commit.gpgSign=false", "commit", "-qm", "Add a change fragment"], + cwd=self.root, check=True, capture_output=True) + result = self.run_check("--base", base) + self.assertEqual(0, result.returncode, result.stderr) + + def test_migrated_unreleased_entries_survive_a_release_batch_unchanged(self): + expected = ( + "`toString()` of credential-bearing structures (`B2AccountAuthorization`, " + "`B2FileSseForRequest`, `B2WebhookConfiguration`, `B2WebhookCustomHeader`, and " + "`B2HeadersImpl`) omits sensitive values; `B2WebhookCustomHeader` omits all header values.", + "`B2EventNotificationRule` now orders and deduplicates rules by `maxEventsPerBatch`, " + "so rules that differ only by batch size no longer collapse in sorted collections; " + "it also uses direct webhook settings instead of the former string-based order " + "(url, headers, then signing secret), so callers that persist or diff ordered rules " + "may observe a different order.", + "Security / behaviour change: the three-argument `B2EventNotification.parse` overloads " + "now require a signature header and a signing secret; receivers should answer HTTP " + "401 on `B2SignatureVerificationException`.\n A missing or empty signature header " + "throws `B2SignatureVerificationException`; a null or empty signing secret throws " + "`IllegalArgumentException`.", + "Signature comparison is now constant-time.", + "Added `B2EventNotification.parseUnverified`, which parses without checking a signature. " + "The one-argument `parse` overloads are deprecated in its favor.", + ) + subprocess.run([self.changie, "batch", "patch", "--allow-no-changes=false"], + cwd=self.root, check=True, capture_output=True) + subprocess.run([self.changie, "merge"], cwd=self.root, check=True, capture_output=True) + releases = [path.read_text() for path in (self.root / ".changes").glob("v*.md")] + migrated_releases = [notes for notes in releases if "* " + expected[0] + "\n" in notes] + self.assertEqual(1, len(migrated_releases), "migrated changes must survive in one release") + notes = migrated_releases[0] + changelog = (self.root / "CHANGELOG.md").read_text() + for body in expected: + with self.subTest(body=body): + self.assertIn("* " + body + "\n", notes) + self.assertIn("* " + body + "\n", changelog) + def test_hand_edited_changelog_is_rejected_without_modifying_it(self): path = self.root / "CHANGELOG.md" edited = path.read_text() + "\nHand edited.\n" @@ -228,6 +281,51 @@ def test_batch_and_merge_update_gradle_version_and_release_notes(self): class ReleaseInstructionsTest(unittest.TestCase): + def test_tag_guards_stop_before_tag_or_push(self): + guide = (SCRIPT.parents[1] / "RELEASE.md").read_text() + block = guide.split("## Tag and deploy", 1)[1].split("```bash", 1)[1].split("```", 1)[0] + block = block.replace("", "123").replace("", "fixture-key") + for failure in ("gh", "empty-sha", "ancestor", "version", "verify"): + with self.subTest(failure=failure), tempfile.TemporaryDirectory() as temporary: + root = pathlib.Path(temporary) + git = root / "git" + git.write_text( + "#!" + sys.executable + "\n" + "import json, os, sys\n" + "args = sys.argv[1:]\n" + "failure = os.environ['TAG_GUARD_FAILURE']\n" + "if 'tag' in args or args[0] in ('push', 'verify-tag'):\n" + " with open(os.environ['GIT_LOG'], 'a') as output:\n" + " output.write(json.dumps(args) + '\\n')\n" + "if args[0] == 'merge-base' and (failure == 'ancestor' or not args[2]):\n" + " sys.exit(1)\n" + "if args[0] == 'show':\n" + " print('version=9.9.9' if failure == 'version' else 'version=1.2.3')\n" + "if args[0] == 'verify-tag' and failure == 'verify':\n" + " sys.exit(1)\n" + ) + git.chmod(0o755) + gh = root / "gh" + gh.write_text( + "#!" + sys.executable + "\n" + "import os, sys\n" + "failure = os.environ['TAG_GUARD_FAILURE']\n" + "if failure == 'gh':\n" + " sys.exit(1)\n" + "print('' if failure == 'empty-sha' else '0123456789012345678901234567890123456789')\n" + ) + gh.chmod(0o755) + log = root / "git.jsonl" + environment = dict(os.environ, PATH=str(root) + os.pathsep + os.environ["PATH"], + TAG="v1.2.3", TAG_GUARD_FAILURE=failure, GIT_LOG=str(log)) + result = subprocess.run(["bash", "-c", block], env=environment, + capture_output=True, text=True) + calls = [json.loads(line) for line in log.read_text().splitlines()] if log.exists() else [] + self.assertNotEqual(0, result.returncode, result.stdout + result.stderr) + self.assertFalse(any(call[0] == "push" for call in calls), calls) + if failure != "verify": + self.assertEqual([], calls) + def test_maven_verification_checks_every_published_module_and_signature(self): guide = (SCRIPT.parents[1] / "RELEASE.md").read_text() section = guide.split("## Verify the published release", 1)[1].split("\n## ", 1)[0] From 5e4bf9ba66dfc4577016e94e48bbcc2777f69bd7 Mon Sep 17 00:00:00 2001 From: Felipe Fumero Date: Wed, 18 Nov 2026 16:58:14 -0600 Subject: [PATCH 09/15] docs: verify Maven artifacts against the expected signing fingerprint Stop the verification block on download or signature failures and require the independently confirmed artifact-signing fingerprint. Check primary-key and signing-subkey status records, with regression coverage for failed downloads, invalid signatures, and unexpected signers. --- RELEASE.md | 26 +++++++-- scripts/tests/test_release.py | 104 +++++++++++++++++++++++++--------- 2 files changed, 96 insertions(+), 34 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index dbdbf8580..8c38de706 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -161,13 +161,27 @@ are unchanged by the changelog tooling. Never run this production command as a d 3. After Maven Central indexing completes, check each module and its signature: + Import the established Maven artifact-signing public key and independently confirm its + full uppercase primary-key fingerprint with the release maintainers. Export that value as + `MAVEN_SIGNING_FINGERPRINT`; do not derive it from the downloaded artifacts or signatures. + ```bash - for module in core httpclient samples core-test-jdk17; do - url="https://repo.maven.apache.org/maven2/com/backblaze/b2/b2-sdk-$module/$VERSION/b2-sdk-$module-$VERSION.pom" - curl --fail --show-error --location "$url" -o "/tmp/b2-sdk-$module-$VERSION.pom" - curl --fail --show-error --location "$url.asc" -o "/tmp/b2-sdk-$module-$VERSION.pom.asc" - gpg --verify "/tmp/b2-sdk-$module-$VERSION.pom.asc" "/tmp/b2-sdk-$module-$VERSION.pom" - done + ( + set -euo pipefail + : "${VERSION:?export the released version, e.g. 6.5.1}" + : "${MAVEN_SIGNING_FINGERPRINT:?export the independently confirmed full signing fingerprint}" + for module in core httpclient samples core-test-jdk17; do + url="https://repo.maven.apache.org/maven2/com/backblaze/b2/b2-sdk-$module/$VERSION/b2-sdk-$module-$VERSION.pom" + curl --fail --show-error --location "$url" -o "/tmp/b2-sdk-$module-$VERSION.pom" + curl --fail --show-error --location "$url.asc" -o "/tmp/b2-sdk-$module-$VERSION.pom.asc" + signature_status=$(gpg --batch --status-fd=1 --verify \ + "/tmp/b2-sdk-$module-$VERSION.pom.asc" "/tmp/b2-sdk-$module-$VERSION.pom") + printf '%s\n' "$signature_status" | awk -v expected="$MAVEN_SIGNING_FINGERPRINT" ' + $1 == "[GNUPG:]" && $2 == "VALIDSIG" && ($3 == expected || $12 == expected) { found = 1 } + END { exit !found } + ' || { printf '%s\n' 'Maven signature does not match the expected fingerprint' >&2; exit 1; } + done + ) ``` The shared Gradle publication plugin also publishes `b2-sdk-core-test-jdk17`, so this diff --git a/scripts/tests/test_release.py b/scripts/tests/test_release.py index 76eef4d0c..5e45ca106 100644 --- a/scripts/tests/test_release.py +++ b/scripts/tests/test_release.py @@ -326,38 +326,86 @@ def test_tag_guards_stop_before_tag_or_push(self): if failure != "verify": self.assertEqual([], calls) - def test_maven_verification_checks_every_published_module_and_signature(self): + def run_documented_maven_verification(self, failure="none"): guide = (SCRIPT.parents[1] / "RELEASE.md").read_text() section = guide.split("## Verify the published release", 1)[1].split("\n## ", 1)[0] blocks = [part.split("```", 1)[0] for part in section.split("```bash")[1:]] block = next(block for block in blocks if "for module in" in block) - with tempfile.TemporaryDirectory() as temporary: - root = pathlib.Path(temporary) - curl = root / "curl" - curl.write_text( - '#!/bin/sh\nfor argument; do\n' - ' case "$argument" in https://*) printf "%s\\n" "$argument" >> "$CURL_LOG";; esac\n' - 'done\n' - ) - curl.chmod(0o755) - gpg = root / "gpg" - gpg.write_text('#!/bin/sh\nprintf "%s\\n" "$*" >> "$GPG_LOG"\n') - gpg.chmod(0o755) - environment = dict(os.environ, PATH=str(root) + os.pathsep + os.environ["PATH"], - VERSION="1.2.3", CURL_LOG=str(root / "curl.log"), GPG_LOG=str(root / "gpg.log")) - result = subprocess.run(["bash", "-euo", "pipefail", "-c", block], env=environment, - capture_output=True, text=True) - self.assertEqual(0, result.returncode, result.stdout + result.stderr) - urls = (root / "curl.log").read_text().splitlines() - signatures = (root / "gpg.log").read_text().splitlines() - for module in ("core", "httpclient", "samples", "core-test-jdk17"): - with self.subTest(module=module): - artifact = "b2-sdk-" + module - url = "https://repo.maven.apache.org/maven2/com/backblaze/b2/" + artifact + "/1.2.3/" + artifact + "-1.2.3.pom" - self.assertIn(url, urls) - self.assertIn(url + ".asc", urls) - pom = "/tmp/" + artifact + "-1.2.3.pom" - self.assertIn("--verify " + pom + ".asc " + pom, signatures) + temporary = tempfile.TemporaryDirectory() + self.addCleanup(temporary.cleanup) + root = pathlib.Path(temporary.name) + curl = root / "curl" + curl.write_text( + '#!/bin/sh\nfor argument; do\n' + ' case "$argument" in https://*) printf "%s\\n" "$argument" >> "$CURL_LOG";; esac\n' + ' case "$MAVEN_FAILURE:$argument" in\n' + ' download:*b2-sdk-core-1.2.3.pom) exit 22;;\n' + ' signature-download:*b2-sdk-core-1.2.3.pom.asc) exit 22;;\n' + ' esac\n' + 'done\n' + ) + curl.chmod(0o755) + gpg = root / "gpg" + gpg.write_text( + '#!/bin/sh\nprintf "%s\\n" "$*" >> "$GPG_LOG"\n' + 'case "$MAVEN_FAILURE:$*" in invalid-signature:*b2-sdk-core-1.2.3.pom*) exit 1;; esac\n' + 'case "$MAVEN_FAILURE" in\n' + ' wrong-signer) signer=' + "C" * 40 + ';;\n' + ' *) signer=' + "A" * 40 + ';;\n' + 'esac\n' + 'key="$signer"\n' + 'if [ "$MAVEN_FAILURE" = signing-subkey ]; then key=' + "B" * 40 + '; fi\n' + 'if [ "$MAVEN_FAILURE" != missing-status ]; then\n' + ' printf "[GNUPG:] VALIDSIG %s 2026-01-02 1767312000 0 4 0 22 8 00 %s\\n" "$key" "$signer"\n' + 'fi\n' + ) + gpg.chmod(0o755) + environment = dict(os.environ, PATH=str(root) + os.pathsep + os.environ["PATH"], + VERSION="1.2.3", MAVEN_SIGNING_FINGERPRINT="A" * 40, + MAVEN_FAILURE=failure, CURL_LOG=str(root / "curl.log"), + GPG_LOG=str(root / "gpg.log")) + if failure == "missing-fingerprint": + environment.pop("MAVEN_SIGNING_FINGERPRINT") + result = subprocess.run(["bash", "-c", block], env=environment, capture_output=True, text=True) + urls = (root / "curl.log").read_text().splitlines() if (root / "curl.log").exists() else [] + signatures = (root / "gpg.log").read_text().splitlines() if (root / "gpg.log").exists() else [] + return result, urls, signatures + + def test_maven_verification_checks_every_published_module_and_signature(self): + result, urls, signatures = self.run_documented_maven_verification() + self.assertEqual(0, result.returncode, result.stdout + result.stderr) + for module in ("core", "httpclient", "samples", "core-test-jdk17"): + with self.subTest(module=module): + artifact = "b2-sdk-" + module + url = "https://repo.maven.apache.org/maven2/com/backblaze/b2/" + artifact + "/1.2.3/" + artifact + "-1.2.3.pom" + self.assertIn(url, urls) + self.assertIn(url + ".asc", urls) + pom = "/tmp/" + artifact + "-1.2.3.pom" + self.assertTrue(any("--verify " + pom + ".asc " + pom in call for call in signatures)) + + def test_maven_verification_stops_on_download_or_signature_failure(self): + for failure in ("download", "signature-download", "invalid-signature"): + with self.subTest(failure=failure): + result, urls, signatures = self.run_documented_maven_verification(failure) + self.assertNotEqual(0, result.returncode, result.stdout + result.stderr) + self.assertFalse(any("b2-sdk-httpclient" in url for url in urls), urls) + if failure != "invalid-signature": + self.assertEqual([], signatures) + + def test_maven_verification_requires_the_expected_signer(self): + for failure in ("wrong-signer", "missing-status", "missing-fingerprint"): + with self.subTest(failure=failure): + result, urls, _ = self.run_documented_maven_verification(failure) + self.assertNotEqual(0, result.returncode, result.stdout + result.stderr) + self.assertFalse(any("b2-sdk-httpclient" in url for url in urls), urls) + if failure == "missing-fingerprint": + self.assertEqual([], urls) + + def test_maven_verification_accepts_the_expected_primary_keys_signing_subkey(self): + result, urls, signatures = self.run_documented_maven_verification("signing-subkey") + self.assertEqual(0, result.returncode, result.stdout + result.stderr) + self.assertEqual(8, len(urls)) + self.assertEqual(4, len(signatures)) def test_tag_commands_work_with_only_tag_exported(self): guide = (SCRIPT.parents[1] / "RELEASE.md").read_text() From 342adab24de124d9ef07db52f92a892a9d019bd0 Mon Sep 17 00:00:00 2001 From: Felipe Fumero Date: Wed, 18 Nov 2026 17:24:01 -0600 Subject: [PATCH 10/15] docs: make Maven signing trust enrollment explicit Leave the artifact-signing key source and independent confirmation procedure for release-owner approval. Require the configured primary fingerprint and cover multiple fixture identities, signing subkeys, and rejection of a subkey configured as the primary key. --- RELEASE.md | 15 +++++++++++---- scripts/tests/test_release.py | 33 ++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 8c38de706..1b17702b9 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -161,9 +161,16 @@ are unchanged by the changelog tooling. Never run this production command as a d 3. After Maven Central indexing completes, check each module and its signature: - Import the established Maven artifact-signing public key and independently confirm its - full uppercase primary-key fingerprint with the release maintainers. Export that value as - `MAVEN_SIGNING_FINGERPRINT`; do not derive it from the downloaded artifacts or signatures. + TODO (release owner): approve and record the public-key retrieval URL or file, the full + uppercase primary-key fingerprint, and the out-of-band fingerprint-confirmation channel + and procedure here. No Maven artifact-signing trust source is approved in this repository + yet. A key found in a historical Maven signature or on a keyserver is only a candidate. + + Artifact verification remains blocked until the release owner completes that decision. + Once confirmed, obtain and import the key from the approved location, follow the recorded + independent confirmation procedure, and export the approved primary-key fingerprint as + `MAVEN_SIGNING_FINGERPRINT`. There is no default; do not derive the configured value from + the artifacts or signatures being verified. ```bash ( @@ -177,7 +184,7 @@ are unchanged by the changelog tooling. Never run this production command as a d signature_status=$(gpg --batch --status-fd=1 --verify \ "/tmp/b2-sdk-$module-$VERSION.pom.asc" "/tmp/b2-sdk-$module-$VERSION.pom") printf '%s\n' "$signature_status" | awk -v expected="$MAVEN_SIGNING_FINGERPRINT" ' - $1 == "[GNUPG:]" && $2 == "VALIDSIG" && ($3 == expected || $12 == expected) { found = 1 } + $1 == "[GNUPG:]" && $2 == "VALIDSIG" && $12 == expected { found = 1 } END { exit !found } ' || { printf '%s\n' 'Maven signature does not match the expected fingerprint' >&2; exit 1; } done diff --git a/scripts/tests/test_release.py b/scripts/tests/test_release.py index 5e45ca106..c256f5a61 100644 --- a/scripts/tests/test_release.py +++ b/scripts/tests/test_release.py @@ -326,7 +326,7 @@ def test_tag_guards_stop_before_tag_or_push(self): if failure != "verify": self.assertEqual([], calls) - def run_documented_maven_verification(self, failure="none"): + def run_documented_maven_verification(self, failure="none", fingerprint="A" * 40): guide = (SCRIPT.parents[1] / "RELEASE.md").read_text() section = guide.split("## Verify the published release", 1)[1].split("\n## ", 1)[0] blocks = [part.split("```", 1)[0] for part in section.split("```bash")[1:]] @@ -351,21 +351,24 @@ def run_documented_maven_verification(self, failure="none"): 'case "$MAVEN_FAILURE:$*" in invalid-signature:*b2-sdk-core-1.2.3.pom*) exit 1;; esac\n' 'case "$MAVEN_FAILURE" in\n' ' wrong-signer) signer=' + "C" * 40 + ';;\n' - ' *) signer=' + "A" * 40 + ';;\n' + ' *) signer="$MAVEN_FIXTURE_PRIMARY";;\n' 'esac\n' 'key="$signer"\n' - 'if [ "$MAVEN_FAILURE" = signing-subkey ]; then key=' + "B" * 40 + '; fi\n' + 'case "$MAVEN_FAILURE" in signing-subkey|subkey-as-primary) key=' + "B" * 40 + ';; esac\n' 'if [ "$MAVEN_FAILURE" != missing-status ]; then\n' ' printf "[GNUPG:] VALIDSIG %s 2026-01-02 1767312000 0 4 0 22 8 00 %s\\n" "$key" "$signer"\n' 'fi\n' ) gpg.chmod(0o755) environment = dict(os.environ, PATH=str(root) + os.pathsep + os.environ["PATH"], - VERSION="1.2.3", MAVEN_SIGNING_FINGERPRINT="A" * 40, + VERSION="1.2.3", MAVEN_SIGNING_FINGERPRINT=fingerprint, + MAVEN_FIXTURE_PRIMARY=fingerprint, MAVEN_FAILURE=failure, CURL_LOG=str(root / "curl.log"), GPG_LOG=str(root / "gpg.log")) if failure == "missing-fingerprint": environment.pop("MAVEN_SIGNING_FINGERPRINT") + elif failure == "subkey-as-primary": + environment["MAVEN_SIGNING_FINGERPRINT"] = "B" * 40 result = subprocess.run(["bash", "-c", block], env=environment, capture_output=True, text=True) urls = (root / "curl.log").read_text().splitlines() if (root / "curl.log").exists() else [] signatures = (root / "gpg.log").read_text().splitlines() if (root / "gpg.log").exists() else [] @@ -393,7 +396,7 @@ def test_maven_verification_stops_on_download_or_signature_failure(self): self.assertEqual([], signatures) def test_maven_verification_requires_the_expected_signer(self): - for failure in ("wrong-signer", "missing-status", "missing-fingerprint"): + for failure in ("wrong-signer", "missing-status", "missing-fingerprint", "subkey-as-primary"): with self.subTest(failure=failure): result, urls, _ = self.run_documented_maven_verification(failure) self.assertNotEqual(0, result.returncode, result.stdout + result.stderr) @@ -402,10 +405,22 @@ def test_maven_verification_requires_the_expected_signer(self): self.assertEqual([], urls) def test_maven_verification_accepts_the_expected_primary_keys_signing_subkey(self): - result, urls, signatures = self.run_documented_maven_verification("signing-subkey") - self.assertEqual(0, result.returncode, result.stdout + result.stderr) - self.assertEqual(8, len(urls)) - self.assertEqual(4, len(signatures)) + for fingerprint in ("A" * 40, "D" * 40): + with self.subTest(fingerprint=fingerprint): + result, urls, signatures = self.run_documented_maven_verification("signing-subkey", fingerprint) + self.assertEqual(0, result.returncode, result.stdout + result.stderr) + self.assertEqual(8, len(urls)) + self.assertEqual(4, len(signatures)) + + def test_maven_verification_uses_the_configured_primary_fingerprint(self): + for fingerprint in ("A" * 40, "D" * 40): + with self.subTest(fingerprint=fingerprint): + result, _, signatures = self.run_documented_maven_verification(fingerprint=fingerprint) + self.assertEqual(0, result.returncode, result.stdout + result.stderr) + self.assertEqual(4, len(signatures)) + mismatch, urls, _ = self.run_documented_maven_verification("wrong-signer", fingerprint) + self.assertNotEqual(0, mismatch.returncode, mismatch.stdout + mismatch.stderr) + self.assertFalse(any("b2-sdk-httpclient" in url for url in urls), urls) def test_tag_commands_work_with_only_tag_exported(self): guide = (SCRIPT.parents[1] / "RELEASE.md").read_text() From 94f19559ac35ad42874eb7fc5d918ef03e8cf64a Mon Sep 17 00:00:00 2001 From: Felipe Fumero Date: Wed, 18 Nov 2026 17:39:09 -0600 Subject: [PATCH 11/15] docs: verify every published Maven artifact Verify main, sources, and Javadoc JAR signatures alongside each POM. Exercise failures in JAR downloads and signatures even when POM verification succeeds. Run the standalone tag example test with only its required environment. --- RELEASE.md | 23 +++++++++++++---------- scripts/tests/test_release.py | 35 +++++++++++++++++++++++++---------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 1b17702b9..08a13c4d5 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -178,21 +178,24 @@ are unchanged by the changelog tooling. Never run this production command as a d : "${VERSION:?export the released version, e.g. 6.5.1}" : "${MAVEN_SIGNING_FINGERPRINT:?export the independently confirmed full signing fingerprint}" for module in core httpclient samples core-test-jdk17; do - url="https://repo.maven.apache.org/maven2/com/backblaze/b2/b2-sdk-$module/$VERSION/b2-sdk-$module-$VERSION.pom" - curl --fail --show-error --location "$url" -o "/tmp/b2-sdk-$module-$VERSION.pom" - curl --fail --show-error --location "$url.asc" -o "/tmp/b2-sdk-$module-$VERSION.pom.asc" - signature_status=$(gpg --batch --status-fd=1 --verify \ - "/tmp/b2-sdk-$module-$VERSION.pom.asc" "/tmp/b2-sdk-$module-$VERSION.pom") - printf '%s\n' "$signature_status" | awk -v expected="$MAVEN_SIGNING_FINGERPRINT" ' - $1 == "[GNUPG:]" && $2 == "VALIDSIG" && $12 == expected { found = 1 } - END { exit !found } - ' || { printf '%s\n' 'Maven signature does not match the expected fingerprint' >&2; exit 1; } + for suffix in .pom .jar -sources.jar -javadoc.jar; do + artifact="b2-sdk-$module-$VERSION$suffix" + url="https://repo.maven.apache.org/maven2/com/backblaze/b2/b2-sdk-$module/$VERSION/$artifact" + curl --fail --show-error --location "$url" -o "/tmp/$artifact" + curl --fail --show-error --location "$url.asc" -o "/tmp/$artifact.asc" + signature_status=$(gpg --batch --status-fd=1 --verify "/tmp/$artifact.asc" "/tmp/$artifact") + printf '%s\n' "$signature_status" | awk -v expected="$MAVEN_SIGNING_FINGERPRINT" ' + $1 == "[GNUPG:]" && $2 == "VALIDSIG" && $12 == expected { found = 1 } + END { exit !found } + ' || { printf '%s\n' 'Maven signature does not match the expected fingerprint' >&2; exit 1; } + done done ) ``` The shared Gradle publication plugin also publishes `b2-sdk-core-test-jdk17`, so this - loop verifies all four published modules, including that test module's POM and signature. + loop verifies the POM, main JAR, sources JAR, and Javadoc JAR for all four published + modules, including that test module, against the configured signing fingerprint. Verify using the established Maven artifact-signing public key, independently of tag keys. 4. Confirm there are no open issues/PRs left in the version milestone, then close it. Publish any advisories coordinated with the release only after the fixed artifacts are available. diff --git a/scripts/tests/test_release.py b/scripts/tests/test_release.py index c256f5a61..b2d979c83 100644 --- a/scripts/tests/test_release.py +++ b/scripts/tests/test_release.py @@ -341,6 +341,7 @@ def run_documented_maven_verification(self, failure="none", fingerprint="A" * 40 ' case "$MAVEN_FAILURE:$argument" in\n' ' download:*b2-sdk-core-1.2.3.pom) exit 22;;\n' ' signature-download:*b2-sdk-core-1.2.3.pom.asc) exit 22;;\n' + ' jar-signature-download:*b2-sdk-core-1.2.3.jar.asc) exit 22;;\n' ' esac\n' 'done\n' ) @@ -349,10 +350,12 @@ def run_documented_maven_verification(self, failure="none", fingerprint="A" * 40 gpg.write_text( '#!/bin/sh\nprintf "%s\\n" "$*" >> "$GPG_LOG"\n' 'case "$MAVEN_FAILURE:$*" in invalid-signature:*b2-sdk-core-1.2.3.pom*) exit 1;; esac\n' + 'case "$MAVEN_FAILURE:$*" in invalid-jar-signature:*b2-sdk-core-1.2.3.jar*) exit 1;; esac\n' 'case "$MAVEN_FAILURE" in\n' ' wrong-signer) signer=' + "C" * 40 + ';;\n' ' *) signer="$MAVEN_FIXTURE_PRIMARY";;\n' 'esac\n' + 'case "$MAVEN_FAILURE:$*" in wrong-jar-signer:*b2-sdk-core-1.2.3.jar*) signer=' + "C" * 40 + ';; esac\n' 'key="$signer"\n' 'case "$MAVEN_FAILURE" in signing-subkey|subkey-as-primary) key=' + "B" * 40 + ';; esac\n' 'if [ "$MAVEN_FAILURE" != missing-status ]; then\n' @@ -380,11 +383,16 @@ def test_maven_verification_checks_every_published_module_and_signature(self): for module in ("core", "httpclient", "samples", "core-test-jdk17"): with self.subTest(module=module): artifact = "b2-sdk-" + module - url = "https://repo.maven.apache.org/maven2/com/backblaze/b2/" + artifact + "/1.2.3/" + artifact + "-1.2.3.pom" - self.assertIn(url, urls) - self.assertIn(url + ".asc", urls) - pom = "/tmp/" + artifact + "-1.2.3.pom" - self.assertTrue(any("--verify " + pom + ".asc " + pom in call for call in signatures)) + for suffix in (".pom", ".jar", "-sources.jar", "-javadoc.jar"): + with self.subTest(suffix=suffix): + filename = artifact + "-1.2.3" + suffix + url = "https://repo.maven.apache.org/maven2/com/backblaze/b2/" + artifact + "/1.2.3/" + filename + self.assertIn(url, urls) + self.assertIn(url + ".asc", urls) + local_file = "/tmp/" + filename + self.assertTrue(any("--verify " + local_file + ".asc " + local_file in call for call in signatures)) + self.assertEqual(32, len(urls)) + self.assertEqual(16, len(signatures)) def test_maven_verification_stops_on_download_or_signature_failure(self): for failure in ("download", "signature-download", "invalid-signature"): @@ -395,6 +403,14 @@ def test_maven_verification_stops_on_download_or_signature_failure(self): if failure != "invalid-signature": self.assertEqual([], signatures) + def test_maven_verification_rejects_bad_jars_even_with_a_valid_pom(self): + for failure in ("jar-signature-download", "invalid-jar-signature", "wrong-jar-signer"): + with self.subTest(failure=failure): + result, urls, signatures = self.run_documented_maven_verification(failure) + self.assertNotEqual(0, result.returncode, result.stdout + result.stderr) + self.assertFalse(any("b2-sdk-httpclient" in url for url in urls), urls) + self.assertTrue(any("b2-sdk-core-1.2.3.pom.asc" in call for call in signatures)) + def test_maven_verification_requires_the_expected_signer(self): for failure in ("wrong-signer", "missing-status", "missing-fingerprint", "subkey-as-primary"): with self.subTest(failure=failure): @@ -409,15 +425,15 @@ def test_maven_verification_accepts_the_expected_primary_keys_signing_subkey(sel with self.subTest(fingerprint=fingerprint): result, urls, signatures = self.run_documented_maven_verification("signing-subkey", fingerprint) self.assertEqual(0, result.returncode, result.stdout + result.stderr) - self.assertEqual(8, len(urls)) - self.assertEqual(4, len(signatures)) + self.assertEqual(32, len(urls)) + self.assertEqual(16, len(signatures)) def test_maven_verification_uses_the_configured_primary_fingerprint(self): for fingerprint in ("A" * 40, "D" * 40): with self.subTest(fingerprint=fingerprint): result, _, signatures = self.run_documented_maven_verification(fingerprint=fingerprint) self.assertEqual(0, result.returncode, result.stdout + result.stderr) - self.assertEqual(4, len(signatures)) + self.assertEqual(16, len(signatures)) mismatch, urls, _ = self.run_documented_maven_verification("wrong-signer", fingerprint) self.assertNotEqual(0, mismatch.returncode, mismatch.stdout + mismatch.stderr) self.assertFalse(any("b2-sdk-httpclient" in url for url in urls), urls) @@ -434,8 +450,7 @@ def test_tag_commands_work_with_only_tag_exported(self): gh = root / "gh" gh.write_text("#!/bin/sh\nprintf '0123456789012345678901234567890123456789\\n'\n") gh.chmod(0o755) - environment = dict(os.environ, PATH=str(root) + os.pathsep + os.environ["PATH"], TAG="v1.2.3") - environment.pop("VERSION", None) + environment = {"PATH": str(root) + os.pathsep + os.defpath, "TAG": "v1.2.3"} result = subprocess.run(["bash", "-euo", "pipefail", "-c", block], env=environment, capture_output=True, text=True) self.assertEqual(0, result.returncode, result.stdout + result.stderr) From 4529d7efea3e4eec8d1915a7e81036d458f560d2 Mon Sep 17 00:00:00 2001 From: Felipe Fumero Date: Wed, 18 Nov 2026 17:45:33 -0600 Subject: [PATCH 12/15] docs: make release examples recoverable and self-contained Delete a newly created local tag if signature verification fails, and explicitly pass the simulator URL to the health harness. Cover both failure paths with shell contract tests. --- RELEASE.md | 8 ++++++-- scripts/tests/test_release.py | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 08a13c4d5..df9a8a29c 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -114,7 +114,10 @@ Tag the merged release-prep commit, which may differ from the latest tip of `mas # GPG: use your full signing-key fingerprint. git -c gpg.format=openpgp tag -s -u "$TAG" "$SHA" -m "$TAG" - git verify-tag "$TAG" + if ! git verify-tag "$TAG"; then + git tag --delete "$TAG" + exit 1 + fi # Alternatively, with a registered SSH signing key: # git -c gpg.format=ssh -c user.signingkey="$HOME/.ssh/id_ed25519.pub" \ @@ -211,7 +214,8 @@ Set `SDKHARNESS_SIMULATOR_URL` to the running simulator's IPv4 loopback URL, the : "${SDKHARNESS_SIMULATOR_URL:?set the local simulator URL, e.g. http://127.0.0.1:8180}" ./gradlew build --no-daemon CP=$(./gradlew -q -I scripts/health-classpath.gradle :b2-sdk-httpclient:healthClasspath) -SDKHARNESS_TEST_LEVEL=health SDKHARNESS_SCENARIO=golden-path \ +SDKHARNESS_SIMULATOR_URL="$SDKHARNESS_SIMULATOR_URL" \ + SDKHARNESS_TEST_LEVEL=health SDKHARNESS_SCENARIO=golden-path \ B2_BUCKET_NAME=sdkharness-healthcheck SDKHARNESS_JAVA_CLASSPATH="$CP" \ .sdkharness/tests/run-health ``` diff --git a/scripts/tests/test_release.py b/scripts/tests/test_release.py index b2d979c83..d2ee5175f 100644 --- a/scripts/tests/test_release.py +++ b/scripts/tests/test_release.py @@ -325,6 +325,27 @@ def test_tag_guards_stop_before_tag_or_push(self): self.assertFalse(any(call[0] == "push" for call in calls), calls) if failure != "verify": self.assertEqual([], calls) + else: + self.assertIn(["tag", "--delete", "v1.2.3"], calls, + "delete the newly created local tag if signature verification fails") + + def test_health_example_passes_an_unexported_simulator_url_to_the_harness(self): + guide = (SCRIPT.parents[1] / "RELEASE.md").read_text() + block = guide.split("## Local health check", 1)[1].split("```bash", 1)[1].split("```", 1)[0] + with tempfile.TemporaryDirectory() as temporary: + root = pathlib.Path(temporary) + gradle = root / "gradlew" + gradle.write_text('#!/bin/sh\ncase "$*" in *healthClasspath*) printf /fixture/health.jar;; esac\n') + gradle.chmod(0o755) + harness = root / ".sdkharness/tests/run-health" + harness.parent.mkdir(parents=True) + harness.write_text('#!/bin/sh\n[ "$SDKHARNESS_SIMULATOR_URL" = http://127.0.0.1:8180 ] || exit 42\n' + '[ "$SDKHARNESS_JAVA_CLASSPATH" = /fixture/health.jar ] || exit 43\n') + harness.chmod(0o755) + result = subprocess.run( + ["bash", "-euo", "pipefail", "-c", "SDKHARNESS_SIMULATOR_URL=http://127.0.0.1:8180\n" + block], + cwd=root, env={"PATH": os.defpath}, capture_output=True, text=True) + self.assertEqual(0, result.returncode, result.stdout + result.stderr) def run_documented_maven_verification(self, failure="none", fingerprint="A" * 40): guide = (SCRIPT.parents[1] / "RELEASE.md").read_text() From c186a4e53aa8f5f2b95d1d4f0f0ab0d7ec029503 Mon Sep 17 00:00:00 2001 From: Felipe Fumero Date: Thu, 19 Nov 2026 09:16:22 -0600 Subject: [PATCH 13/15] docs: clean up SSH tags after failed verification Mirror the local tag cleanup guard in the documented SSH signing alternative. Verify trusted and rejected signatures with real disposable Git and SSH keys, including execution of tag deletion after rejection. --- RELEASE.md | 5 ++- scripts/tests/test_release.py | 65 +++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index df9a8a29c..1da08a295 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -122,7 +122,10 @@ Tag the merged release-prep commit, which may differ from the latest tip of `mas # Alternatively, with a registered SSH signing key: # git -c gpg.format=ssh -c user.signingkey="$HOME/.ssh/id_ed25519.pub" \ # tag -s "$TAG" "$SHA" -m "$TAG" - # git -c gpg.format=ssh -c gpg.ssh.allowedSignersFile= verify-tag "$TAG" + # if ! git -c gpg.format=ssh -c gpg.ssh.allowedSignersFile= verify-tag "$TAG"; then + # git tag --delete "$TAG" + # exit 1 + # fi git push origin "$TAG" ) diff --git a/scripts/tests/test_release.py b/scripts/tests/test_release.py index d2ee5175f..b9f92ceda 100644 --- a/scripts/tests/test_release.py +++ b/scripts/tests/test_release.py @@ -281,6 +281,71 @@ def test_batch_and_merge_update_gradle_version_and_release_notes(self): class ReleaseInstructionsTest(unittest.TestCase): + def test_documented_ssh_verification_cleans_up_failed_tag(self): + guide = (SCRIPT.parents[1] / "RELEASE.md").read_text() + block = guide.split("## Tag and deploy", 1)[1].split("```bash", 1)[1].split("```", 1)[0] + alternative = block.split(" # Alternatively, with a registered SSH signing key:\n", 1)[1].split("\n\n", 1)[0] + script = "\n".join(line[4:] for line in alternative.splitlines() if line.startswith(" # ")) + script = script.replace("$HOME/.ssh/id_ed25519.pub", "$RELEASE_TEST_SIGNING_KEY") + script = script.replace("", '"$RELEASE_TEST_ALLOWED_SIGNERS"') + with tempfile.TemporaryDirectory(prefix="b2-guide-ssh-") as temporary: + root = pathlib.Path(temporary) + real_git = shutil.which("git") + environment = dict(os.environ, GIT_CONFIG_GLOBAL=os.devnull, GIT_CONFIG_NOSYSTEM="1") + for arguments in (("init", "-q"), ("config", "user.name", "Release Fixture"), + ("config", "user.email", "fixture@example.invalid"), + ("-c", "commit.gpgSign=false", "commit", "--allow-empty", "-qm", "Release fixture")): + subprocess.run([real_git, *arguments], cwd=root, env=environment, check=True, capture_output=True) + commit = subprocess.check_output([real_git, "rev-parse", "HEAD"], cwd=root, + env=environment, text=True).strip() + key = root / "signing-key" + subprocess.run(["ssh-keygen", "-q", "-t", "ed25519", "-N", "", "-f", str(key)], + check=True, capture_output=True) + allowed = root / "allowed-signers" + log = root / "git.jsonl" + binaries = root / "bin" + binaries.mkdir() + git = binaries / "git" + git.write_text( + "#!" + sys.executable + "\n" + "import json, os, subprocess, sys\n" + "arguments = sys.argv[1:]\n" + "result = subprocess.run([os.environ['RELEASE_TEST_REAL_GIT'], *arguments])\n" + "with open(os.environ['RELEASE_TEST_GIT_LOG'], 'a') as output:\n" + " output.write(json.dumps({'argv': arguments, 'status': result.returncode}) + '\\n')\n" + "sys.exit(result.returncode)\n" + ) + git.chmod(0o755) + environment.update(PATH=str(binaries) + os.pathsep + os.environ["PATH"], SHA=commit, + RELEASE_TEST_SIGNING_KEY=str(key) + ".pub", + RELEASE_TEST_ALLOWED_SIGNERS=str(allowed), RELEASE_TEST_REAL_GIT=real_git, + RELEASE_TEST_GIT_LOG=str(log)) + for trusted in (True, False): + with self.subTest(trusted=trusted): + tag = "v9.9.9-ssh-" + ("trusted" if trusted else "untrusted") + environment["TAG"] = tag + allowed.write_text('release-maintainer namespaces="git" ' + (root / "signing-key.pub").read_text() + if trusted else "") + log.write_text("") + result = subprocess.run(["bash", "-euo", "pipefail", "-c", script], cwd=root, + env=environment, capture_output=True, text=True) + calls = [json.loads(line) for line in log.read_text().splitlines()] + creations = [call for call in calls if "tag" in call["argv"] and "-s" in call["argv"]] + verifications = [call for call in calls if "verify-tag" in call["argv"]] + self.assertEqual([0], [call["status"] for call in creations], result.stderr) + self.assertEqual(1, len(verifications), calls) + reference = subprocess.run([real_git, "show-ref", "--verify", "--quiet", "refs/tags/" + tag], + cwd=root, env=environment, capture_output=True) + if trusted: + self.assertEqual(0, result.returncode, result.stderr) + self.assertEqual(0, verifications[0]["status"], calls) + self.assertEqual(0, reference.returncode) + else: + self.assertNotEqual(0, result.returncode) + self.assertNotEqual(0, verifications[0]["status"], calls) + self.assertNotEqual(0, reference.returncode, "failed SSH verification left the local tag") + self.assertIn({"argv": ["tag", "--delete", tag], "status": 0}, calls) + def test_tag_guards_stop_before_tag_or_push(self): guide = (SCRIPT.parents[1] / "RELEASE.md").read_text() block = guide.split("## Tag and deploy", 1)[1].split("```bash", 1)[1].split("```", 1)[0] From 79926f46680f6d394cc05041cf2e1863e4a4bb9d Mon Sep 17 00:00:00 2001 From: Felipe Fumero Date: Thu, 19 Nov 2026 09:39:20 -0600 Subject: [PATCH 14/15] fix: validate batched release notes with stable file statuses Disable rename detection when validating release-preparation changes so a fragment batched into version notes is counted as a new notes file. Add a real Git and Changie regression for that case.\n\nExercise the documented runtime classpath task through Gradle and provision Java for the changelog test job. --- .github/workflows/changelog.yml | 4 +++ scripts/release.py | 2 +- scripts/tests/test_health_classpath.py | 44 +++++++++++++++++++++++ scripts/tests/test_release_prep.py | 48 ++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 scripts/tests/test_health_classpath.py create mode 100644 scripts/tests/test_release_prep.py diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 18a039614..a012f3be0 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -24,6 +24,10 @@ jobs: with: go-version: '1.24.0' cache: false + - uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4 + with: + distribution: temurin + java-version: '11' - name: Install Changie run: go install github.com/miniscruff/changie@v1.24.0 - name: Validate changelog diff --git a/scripts/release.py b/scripts/release.py index 18d023315..7d45cbd02 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -61,7 +61,7 @@ def changelog_check(root, base, dependabot=False): cwd=target, check=True, stdout=subprocess.DEVNULL) if base: changes = subprocess.check_output( - ["git", "diff", "--name-status", base + "...HEAD"], cwd=root, text=True + ["git", "diff", "--name-status", "--no-renames", base + "...HEAD"], cwd=root, text=True ).splitlines() workflow_only = changes and all( line.startswith("M\t.github/workflows/") and line.endswith((".yml", ".yaml")) diff --git a/scripts/tests/test_health_classpath.py b/scripts/tests/test_health_classpath.py new file mode 100644 index 000000000..ad8873da1 --- /dev/null +++ b/scripts/tests/test_health_classpath.py @@ -0,0 +1,44 @@ +"""Exercise the real Gradle init script with a minimal multi-project Java fixture.""" + +import os +import pathlib +import subprocess +import tempfile +import unittest +import zipfile + + +ROOT = pathlib.Path(__file__).resolve().parents[2] +INIT_SCRIPT = ROOT / "scripts/health-classpath.gradle" + + +class HealthClasspathTest(unittest.TestCase): + def test_init_script_resolves_the_sdk_runtime_classpath(self): + with tempfile.TemporaryDirectory(prefix="b2-health-classpath-") as temporary: + root = pathlib.Path(temporary).resolve() + (root / "settings.gradle").write_text( + "rootProject.name = 'health-classpath-fixture'\ninclude 'core', 'httpclient'\n" + "project(':core').name = 'b2-sdk-core'\n" + "project(':httpclient').name = 'b2-sdk-httpclient'\n") + (root / "build.gradle").write_text("subprojects { apply plugin: 'java'; version = '1.0' }\n") + (root / "core").mkdir() + httpclient = root / "httpclient" + httpclient.mkdir() + (httpclient / "build.gradle").write_text( + "dependencies { implementation project(':b2-sdk-core'); runtimeOnly files('../deps/fixture.jar') }\n") + dependency = root / "deps/fixture.jar" + dependency.parent.mkdir() + with zipfile.ZipFile(dependency, "w") as jar: + jar.writestr("META-INF/MANIFEST.MF", "Manifest-Version: 1.0\n") + result = subprocess.run( + [str(ROOT / "gradlew"), "--quiet", "--console=plain", "--offline", "--no-daemon", + "--project-dir", str(root), "--init-script", str(INIT_SCRIPT), + ":b2-sdk-httpclient:healthClasspath"], capture_output=True, text=True, timeout=300) + self.assertEqual(0, result.returncode, result.stdout + result.stderr) + expected = {str(httpclient / "build/classes/java/main"), str(httpclient / "build/resources/main"), + str(root / "core/build/libs/b2-sdk-core-1.0.jar"), str(dependency)} + self.assertEqual(expected, set(result.stdout.strip().split(os.pathsep))) + + +if __name__ == "__main__": + unittest.main() diff --git a/scripts/tests/test_release_prep.py b/scripts/tests/test_release_prep.py new file mode 100644 index 000000000..a40b9f472 --- /dev/null +++ b/scripts/tests/test_release_prep.py @@ -0,0 +1,48 @@ +"""Exercise release-preparation diffs using real Git and Changie.""" + +import os +import pathlib +import shutil +import subprocess +import sys +import tempfile +import unittest + + +ROOT = pathlib.Path(__file__).resolve().parents[2] + + +class ReleasePrepTest(unittest.TestCase): + def test_batch_detected_as_a_rename_is_accepted(self): + with tempfile.TemporaryDirectory(prefix="b2-release-prep-") as temporary: + root = pathlib.Path(temporary) + shutil.copy(ROOT / ".changie.yaml", root) + (root / ".changes/unreleased").mkdir(parents=True) + (root / ".changes/header.tpl.md").write_text("# Changelog\n") + (root / ".changes/v1.2.3.md").write_text("## [1.2.3] - 2026-01-01\n\n### Fixed\n\n* Prior release.\n") + (root / "gradle.properties").write_text("version=1.2.3\n") + body = "Validate release metadata before preparing the next version. " * 120 + (root / ".changes/unreleased/long.yaml").write_text( + "kind: Fixed\nbody: " + body + "\ntime: 2026-01-02T00:00:00Z\n") + changie = os.environ.get("CHANGIE", "changie") + subprocess.run([changie, "merge"], cwd=root, check=True, capture_output=True) + for args in (("init", "-q"), ("config", "user.name", "Release Fixture"), + ("config", "user.email", "fixture@example.invalid"), ("config", "diff.renames", "true"), + ("add", "."), ("-c", "commit.gpgSign=false", "commit", "-qm", "Base fixture")): + subprocess.run(["git", *args], cwd=root, check=True, capture_output=True) + base = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=root, text=True).strip() + for args in (("batch", "v1.2.4", "--allow-no-changes=false"), ("merge",)): + subprocess.run([changie, *args], cwd=root, check=True, capture_output=True) + subprocess.run(["git", "add", "."], cwd=root, check=True, capture_output=True) + subprocess.run(["git", "-c", "commit.gpgSign=false", "commit", "-qm", "Batch release"], + cwd=root, check=True, capture_output=True) + changes = subprocess.check_output(["git", "diff", "--name-status", base + "...HEAD"], + cwd=root, text=True) + self.assertRegex(changes, r"R\d+\t.changes/unreleased/long.yaml\t.changes/v1.2.4.md") + result = subprocess.run([sys.executable, str(ROOT / "scripts/release.py"), "--root", str(root), + "changelog-check", "--base", base], capture_output=True, text=True) + self.assertEqual(0, result.returncode, result.stdout + result.stderr) + + +if __name__ == "__main__": + unittest.main() From 1dc67479859d6b0deb7de86233d181c4c49f2506 Mon Sep 17 00:00:00 2001 From: Felipe Fumero Date: Thu, 19 Nov 2026 09:49:56 -0600 Subject: [PATCH 15/15] fix: distinguish new changelog fragments from renamed entries Use rename-aware statuses for the new-entry requirement, independent of user Git configuration. Disable rename detection only when recognizing batched version notes in a release-preparation diff. Cover both accepted release batching and rejection of a renamed existing fragment with real Git and Changie. --- scripts/release.py | 7 +++++-- scripts/tests/test_release_prep.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/scripts/release.py b/scripts/release.py index 7d45cbd02..1f30bb0ce 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -61,7 +61,7 @@ def changelog_check(root, base, dependabot=False): cwd=target, check=True, stdout=subprocess.DEVNULL) if base: changes = subprocess.check_output( - ["git", "diff", "--name-status", "--no-renames", base + "...HEAD"], cwd=root, text=True + ["git", "diff", "--name-status", "--find-renames", base + "...HEAD"], cwd=root, text=True ).splitlines() workflow_only = changes and all( line.startswith("M\t.github/workflows/") and line.endswith((".yml", ".yaml")) @@ -72,7 +72,10 @@ def changelog_check(root, base, dependabot=False): return added = [line.split("\t")[-1] for line in changes if line.startswith("A\t")] if not any(name.startswith(".changes/unreleased/") and name.endswith(".yaml") for name in added): - updated = [line.split("\t")[-1] for line in changes if line.startswith(("A\t", "M\t"))] + release_changes = subprocess.check_output( + ["git", "diff", "--name-status", "--no-renames", base + "...HEAD"], cwd=root, text=True + ).splitlines() + updated = [line.split("\t")[-1] for line in release_changes if line.startswith(("A\t", "M\t"))] tag = "v" + project_version(root) if ".changes/" + tag + ".md" not in updated or "gradle.properties" not in updated or fragments: raise ValueError("add a Changie fragment, or batch all fragments in a release-prep PR") diff --git a/scripts/tests/test_release_prep.py b/scripts/tests/test_release_prep.py index a40b9f472..785d411ea 100644 --- a/scripts/tests/test_release_prep.py +++ b/scripts/tests/test_release_prep.py @@ -13,6 +13,36 @@ class ReleasePrepTest(unittest.TestCase): + def test_renaming_an_existing_fragment_does_not_count_as_a_new_entry(self): + with tempfile.TemporaryDirectory(prefix="b2-fragment-rename-") as temporary: + root = pathlib.Path(temporary) + shutil.copy(ROOT / ".changie.yaml", root) + (root / ".changes/unreleased").mkdir(parents=True) + (root / ".changes/header.tpl.md").write_text("# Changelog\n") + (root / ".changes/v1.2.3.md").write_text("## [1.2.3] - 2026-01-01\n\n### Fixed\n\n* Prior release.\n") + (root / "gradle.properties").write_text("version=1.2.3\n") + original = root / ".changes/unreleased/original.yaml" + original.write_text("kind: Fixed\nbody: Existing entry.\ntime: 2026-01-02T00:00:00Z\n") + changie = os.environ.get("CHANGIE", "changie") + subprocess.run([changie, "merge"], cwd=root, check=True, capture_output=True) + for args in (("init", "-q"), ("config", "user.name", "Release Fixture"), + ("config", "user.email", "fixture@example.invalid"), ("config", "diff.renames", "false"), + ("add", "."), ("-c", "commit.gpgSign=false", "commit", "-qm", "Base fixture")): + subprocess.run(["git", *args], cwd=root, check=True, capture_output=True) + base = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=root, text=True).strip() + original.rename(original.with_name("renamed.yaml")) + (root / "README.md").write_text("An unrelated SDK change without a new changelog entry.\n") + subprocess.run(["git", "add", "."], cwd=root, check=True, capture_output=True) + subprocess.run(["git", "-c", "commit.gpgSign=false", "commit", "-qm", "Rename existing fragment"], + cwd=root, check=True, capture_output=True) + changes = subprocess.check_output(["git", "diff", "--name-status", "--find-renames", base + "...HEAD"], + cwd=root, text=True) + self.assertIn("R100\t.changes/unreleased/original.yaml\t.changes/unreleased/renamed.yaml", changes) + result = subprocess.run([sys.executable, str(ROOT / "scripts/release.py"), "--root", str(root), + "changelog-check", "--base", base], capture_output=True, text=True) + self.assertNotEqual(0, result.returncode, result.stdout + result.stderr) + self.assertIn("add a Changie fragment", result.stderr) + def test_batch_detected_as_a_rename_is_accepted(self): with tempfile.TemporaryDirectory(prefix="b2-release-prep-") as temporary: root = pathlib.Path(temporary)