Skip to content

Version resolution: --pkg-version/--output-dir overrides and dynamic version tokens - #20

Merged
jordancalhoun merged 2 commits into
codecarton:nextfrom
rodchristiansen:feat/version-resolution
Jul 26, 2026
Merged

jordancalhoun merged 2 commits into
codecarton:nextfrom
rodchristiansen:feat/version-resolution

Conversation

@rodchristiansen

@rodchristiansen rodchristiansen commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Two version-handling features that compose:

  • --pkg-version / --output-dir overrides — override the build-info version at build time, and write the artifact outside the project's build/ directory (leaving the project tree clean).
  • Dynamic version tokens — resolve ${TIMESTAMP} / ${DATE} / ${DATETIME} in the build-info version before ${version} name substitution, matching munki-pkg (YYYY.MM.DD.HHMM).

The two compose cleanly: a --pkg-version override feeds the same dynamic-resolution → name-substitution pipeline.

Tests: VersionOverrideTests, DynamicVersionTests; verify-loop.sh covers both end to end; full suite green (24 tests).


Part of a 9-PR series splitting a batch of features into small, themed, independently reviewable PRs. Each applies cleanly to main on its own; the ordering below only minimizes rebases as they land:

  1. Process and exit-code correctness: pipe drain, notarization failure, distinct exit codes #19 — process & exit-code correctness
  2. Version resolution: --pkg-version/--output-dir overrides and dynamic version tokens #20 — version resolution · munki-pkg drop-in compatibility: name handling, keychain paths, --skip-import, receipt-only, notarization deferral #21 — munki-pkg compatibility
  3. Add --output-format json build manifest #22 — json manifest · Add --lint to validate a project without building #23 — lint · Add --verify to check the built package against build-info #24 — verify · Add --provenance attestation sidecar #25 — provenance · Add .env build-time variable substitution for scripts #26 — .env substitution
  4. Add GitHub Action and Azure DevOps templates for building packages #27 — CI templates

Happy to squash, split, or reorder any of these to suit your review preferences.

Summary by CodeRabbit

  • New Features

    • Added --pkg-version to override the package version during builds.
    • Added --output-dir to choose where built packages are saved, creating missing directories automatically.
    • Added dynamic version tokens for timestamps, dates, and date-times.
    • Package names now reflect version overrides and resolved dynamic versions.
  • Documentation

    • Updated command-line help to describe the new options.
  • Tests

    • Added coverage for version overrides, dynamic versions, output naming, and directory handling.

--pkg-version lets the version come from a git tag or CI variable instead
of the committed build-info; it is resolved before ${version} substitution
so it flows into the package name too. --output-dir writes the package to a
chosen directory (created if absent) instead of the project's build/ dir.

Both are threaded through PackageBuildOptions so the GUI can adopt them
without new plumbing. PackageConfiguration.withVersion applies the override
ahead of substitutingVersion; PackageProjectLayout takes an optional
output directory.

Tests: VersionOverrideTests (withVersion isolation; load applies the
override to version and ${version} in name; no override preserves
build-info). verify-loop.sh builds with --pkg-version + --output-dir and
asserts the artifact lands in the target dir with the overridden version
and not in build/.
Support ${TIMESTAMP} (yyyy.MM.dd.HHmm), ${DATE} (yyyy.MM.dd), and
${DATETIME} (yyyy.MM.dd.HHmmss) in the build-info version field, resolved
before ${version} substitution so the stamp flows into the package name.
Mirrors munki-pkg. Static versions are unaffected.

DynamicVersion.resolve takes an injectable clock so tests are deterministic;
resolvingDynamicVersion applies it at load time.

Tests: DynamicVersionTests (each token's format at a fixed date, embedded
token, static passthrough, and resolved version feeding ${version} in name).
verify-loop.sh builds a project versioned ${DATE} and asserts the package
filename matches the dated pattern.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Versioned package builds

Layer / File(s) Summary
Version resolution contracts
swiftpkg/DynamicVersion.swift, swiftpkg/BuildInfo.swift, swiftpkgTests/*VersionTests.swift
Dynamic version tokens, explicit version replacement, and ${version} substitution ordering are implemented and tested.
Build output wiring
swiftpkg/PackageBuildOptions.swift, swiftpkg/PackageBuilder.swift, swiftpkgCLI/CLI.swift
CLI options pass version overrides and output directories through package building, with intermediate output directories created as needed.
Package build verification
scripts/verify-loop.sh
Verification builds check explicit package versions and date-based dynamic package filenames.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLIOptions
  participant PackageBuildOptions
  participant PackageBuildCoordinator
  participant BuildInfoStore
  participant PackageProjectLayout
  CLIOptions->>PackageBuildOptions: set pkgVersion and outputDir
  PackageBuildOptions->>PackageBuildCoordinator: provide versionOverride and outputDirectory
  PackageBuildCoordinator->>BuildInfoStore: load with versionOverride
  PackageBuildCoordinator->>PackageProjectLayout: initialize with outputDirectory
  PackageProjectLayout->>PackageProjectLayout: create intermediate build directories
Loading

Suggested reviewers: jordancalhoun

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: version overrides, output directory support, and dynamic version token resolution.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants