From aa4545338dd0f0ab6307106c9e771b5a62ada81b Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Tue, 17 Nov 2026 22:40:23 +0000 Subject: [PATCH] build: track Package.resolved CI and release builds use the package versions recorded there. `make lockfile` updates it after a change to project.yml. --- .github/workflows/release-sign.yml | 2 +- .gitignore | 3 + CONTRIBUTING.md | 17 ++ Coder-Desktop/Package.resolved | 338 ++++++++++++++++++++++++ Makefile | 17 +- scripts/build.sh | 1 + scripts/update-appcast/Package.resolved | 33 +++ 7 files changed, 409 insertions(+), 2 deletions(-) create mode 100644 Coder-Desktop/Package.resolved create mode 100644 scripts/update-appcast/Package.resolved diff --git a/.github/workflows/release-sign.yml b/.github/workflows/release-sign.yml index f7bc4c17..432292d0 100644 --- a/.github/workflows/release-sign.yml +++ b/.github/workflows/release-sign.yml @@ -734,7 +734,7 @@ jobs: run: | gsutil cp "gs://releases.coder.com/coder-desktop/mac/appcast.xml" ./oldappcast.xml pushd scripts/update-appcast - swift run update-appcast \ + swift run --disable-automatic-resolution update-appcast \ -i ../../oldappcast.xml \ -s ../../build/out/Coder-Desktop.pkg.sig \ -v "$(../version.sh)" \ diff --git a/.gitignore b/.gitignore index fdf22e2f..8844859b 100644 --- a/.gitignore +++ b/.gitignore @@ -235,6 +235,9 @@ playground.xcworkspace Packages/ Package.pins Package.resolved +# The lockfiles are tracked. The Makefile copies the app's into the generated Xcode project. +!/Coder-Desktop/Package.resolved +!/scripts/update-appcast/Package.resolved *.xcodeproj # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata # hence it is not needed unless you have added a package configuration file to your project diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a64d63cd..0a955a06 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -85,6 +85,22 @@ make This will use **XcodeGen** to create the required Xcode project files. The configuration for the project is defined in `Coder-Desktop/project.yml`. +### Changing Swift Packages + +The package versions the app is built with are recorded in +`Coder-Desktop/Package.resolved`. CI and release builds use exactly those +versions, and fail if the file does not match `project.yml`. After adding, +removing or updating a package in `project.yml`, run: + +```bash +make lockfile +``` + +and commit the updated `Package.resolved` with your change. + +The release tooling in `scripts/update-appcast` has its own +`Package.resolved`. Update it with `swift package resolve` in that directory. + ## Common Make Commands Here are some useful `make` commands for working with the project: @@ -94,6 +110,7 @@ Here are some useful `make` commands for working with the project: - `make test`: Run all tests using `xcodebuild`. - `make clean`: Clean the Xcode project. - `make proto`: Generate Swift files from protobufs. +- `make lockfile`: Update `Package.resolved` after changing packages. - `make help`: Display all available `make` commands with descriptions. For continuous development, you can also use: diff --git a/Coder-Desktop/Package.resolved b/Coder-Desktop/Package.resolved new file mode 100644 index 00000000..b23a6dc7 --- /dev/null +++ b/Coder-Desktop/Package.resolved @@ -0,0 +1,338 @@ +{ + "originHash" : "48f972bcc686a7bd649fc1387554ecfff0e7f61053fc589b96325eaca30f4e9e", + "pins" : [ + { + "identity" : "fluid-menu-bar-extra", + "kind" : "remoteSourceControl", + "location" : "https://github.com/coder/fluid-menu-bar-extra", + "state" : { + "branch" : "5b131c7", + "revision" : "5b131c709200fe3b85b46e42246b45ee0e3fddb1" + } + }, + { + "identity" : "grpc-swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/grpc/grpc-swift", + "state" : { + "revision" : "8c5e99d0255c373e0330730d191a3423c57373fb", + "version" : "1.24.2" + } + }, + { + "identity" : "keychainaccess", + "kind" : "remoteSourceControl", + "location" : "https://github.com/kishikawakatsumi/KeychainAccess", + "state" : { + "revision" : "e0c7eebc5a4465a3c4680764f26b7a61f567cdaf" + } + }, + { + "identity" : "launchatlogin-modern", + "kind" : "remoteSourceControl", + "location" : "https://github.com/sindresorhus/LaunchAtLogin-modern", + "state" : { + "revision" : "a04ec1c363be3627734f6dad757d82f5d4fa8fcc", + "version" : "1.1.0" + } + }, + { + "identity" : "mocker", + "kind" : "remoteSourceControl", + "location" : "https://github.com/WeTransfer/Mocker", + "state" : { + "revision" : "95fa785c751f6bc40c49e112d433c3acf8417a97", + "version" : "3.0.2" + } + }, + { + "identity" : "sdwebimage", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SDWebImage/SDWebImage.git", + "state" : { + "revision" : "2de3a496eaf6df9a1312862adcfd54acd73c39c0", + "version" : "5.21.7" + } + }, + { + "identity" : "sdwebimagesvgcoder", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SDWebImage/SDWebImageSVGCoder", + "state" : { + "revision" : "950167445ab703740569869c8b7510efc9d09a26", + "version" : "1.7.0" + } + }, + { + "identity" : "sdwebimageswiftui", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SDWebImage/SDWebImageSwiftUI", + "state" : { + "revision" : "451c6dfd5ecec2cf626d1d9ca81c2d4a60355172", + "version" : "3.1.3" + } + }, + { + "identity" : "semaphore", + "kind" : "remoteSourceControl", + "location" : "https://github.com/groue/Semaphore/", + "state" : { + "revision" : "2543679282aa6f6c8ecf2138acd613ed20790bc2", + "version" : "0.1.0" + } + }, + { + "identity" : "sparkle", + "kind" : "remoteSourceControl", + "location" : "https://github.com/sparkle-project/Sparkle", + "state" : { + "revision" : "ab7d71291238df6e0492143b120c9b696a35f603", + "version" : "2.10.1" + } + }, + { + "identity" : "subprocess", + "kind" : "remoteSourceControl", + "location" : "https://github.com/jamf/Subprocess", + "state" : { + "branch" : "9d67b79", + "revision" : "9d67b79215836ae0dfce8b83d45e632c853b6a25" + } + }, + { + "identity" : "swift-algorithms", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-algorithms.git", + "state" : { + "revision" : "87e50f483c54e6efd60e885f7f5aa946cee68023", + "version" : "1.2.1" + } + }, + { + "identity" : "swift-asn1", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-asn1.git", + "state" : { + "revision" : "917b472dbe53ba699cbb0495f9a95a084bc6364d", + "version" : "1.7.4" + } + }, + { + "identity" : "swift-async-algorithms", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-async-algorithms.git", + "state" : { + "revision" : "13713a4ffdee8abd929f92568ee9462a46ae26e0", + "version" : "1.1.7" + } + }, + { + "identity" : "swift-atomics", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-atomics.git", + "state" : { + "revision" : "0442cb5a3f98ab802acb777929fdb446bda11a34", + "version" : "1.3.1" + } + }, + { + "identity" : "swift-case-paths", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/swift-case-paths", + "state" : { + "revision" : "cb4cba6a8a46a86db0d37dbe09935ead6b24c91a", + "version" : "1.10.0" + } + }, + { + "identity" : "swift-certificates", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-certificates.git", + "state" : { + "revision" : "84f03fafeca28c19f5fc4b528df3d22ce8896bd7", + "version" : "1.21.1" + } + }, + { + "identity" : "swift-collections", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-collections", + "state" : { + "revision" : "88754449ab766a739610b660e117762115fabc9c", + "version" : "1.7.6" + } + }, + { + "identity" : "swift-crypto", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-crypto.git", + "state" : { + "revision" : "f8fad2f95ad67b45f6340c0960e2396094d67e07", + "version" : "5.1.1" + } + }, + { + "identity" : "swift-http-structured-headers", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-http-structured-headers.git", + "state" : { + "revision" : "933538faa42c432d385f02e07df0ace7c5ecfc47", + "version" : "1.7.0" + } + }, + { + "identity" : "swift-http-types", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-http-types.git", + "state" : { + "revision" : "bff4b6903cdc99dda49649dd52f46c11cfd3ed50", + "version" : "1.8.0" + } + }, + { + "identity" : "swift-log", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-log.git", + "state" : { + "revision" : "c7413d967b97aae67c46452bf7645bdb7b200e8e", + "version" : "1.17.2" + } + }, + { + "identity" : "swift-nio", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio.git", + "state" : { + "revision" : "2f58d8ef84438d6517fc78bcea2f8527e3c72936", + "version" : "2.105.0" + } + }, + { + "identity" : "swift-nio-extras", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio-extras.git", + "state" : { + "revision" : "8e1249b29f92574e05e0d91637f239e378a9a95b", + "version" : "1.35.2" + } + }, + { + "identity" : "swift-nio-http2", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio-http2.git", + "state" : { + "revision" : "0f3e54e29c944c2e835ad52159da7d9e1c94ac69", + "version" : "1.46.0" + } + }, + { + "identity" : "swift-nio-ssl", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio-ssl.git", + "state" : { + "revision" : "15e0b9e495786807272dd4891fa4bac76aa43034", + "version" : "2.37.6" + } + }, + { + "identity" : "swift-nio-transport-services", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio-transport-services.git", + "state" : { + "revision" : "67787bb645a5e67d2edcdfbe48a216cc549222d5", + "version" : "1.28.0" + } + }, + { + "identity" : "swift-numerics", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-numerics.git", + "state" : { + "revision" : "0c0290ff6b24942dadb83a929ffaaa1481df04a2", + "version" : "1.1.1" + } + }, + { + "identity" : "swift-parsing", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/swift-parsing", + "state" : { + "revision" : "d3ca6f0f049606124d0f6a414e7fdb7b77f45452", + "version" : "0.15.2" + } + }, + { + "identity" : "swift-protobuf", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-protobuf.git", + "state" : { + "revision" : "ebc7251dd5b37f627c93698e4374084d98409633", + "version" : "1.28.2" + } + }, + { + "identity" : "swift-service-lifecycle", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swift-server/swift-service-lifecycle.git", + "state" : { + "revision" : "a18ee16b8039866fd919bdb4e8e906882d4ecc75", + "version" : "2.13.0" + } + }, + { + "identity" : "swift-syntax", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swiftlang/swift-syntax", + "state" : { + "revision" : "050f1a346fbbac0ca2cfb15a95274f7bd1cf0ccf", + "version" : "604.0.0" + } + }, + { + "identity" : "swift-system", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-system.git", + "state" : { + "revision" : "640e5755b5826f4437eaeedd366fd776737db62c", + "version" : "1.9.0" + } + }, + { + "identity" : "swift-url-routing", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/swift-url-routing", + "state" : { + "branch" : "09b155d", + "revision" : "09b155ddb2a6d09a9adbc7bac50d7d9f75d03e9d" + } + }, + { + "identity" : "swiftlintplugins", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SimplyDanny/SwiftLintPlugins", + "state" : { + "revision" : "ef7d692fc6706e8f5628e26bcafaefa445c58a97", + "version" : "0.65.1" + } + }, + { + "identity" : "viewinspector", + "kind" : "remoteSourceControl", + "location" : "https://github.com/nalexn/ViewInspector", + "state" : { + "revision" : "2dacb6e514be19379c605a5a11564d0f3fea89d9", + "version" : "0.10.5" + } + }, + { + "identity" : "xctest-dynamic-overlay", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/xctest-dynamic-overlay", + "state" : { + "revision" : "d9308ad679143c26a30dec52daefe82f54af2b82", + "version" : "1.13.1" + } + } + ], + "version" : 3 +} diff --git a/Makefile b/Makefile index 09cd2daf..9a1fc207 100644 --- a/Makefile +++ b/Makefile @@ -9,13 +9,20 @@ SHELL := bash ifdef CI LINTFLAGS := --reporter github-actions-logging FMTFLAGS := --lint --reporter github-actions-log +# Use the package versions in Package.resolved, and fail if it does not match project.yml. +PACKAGEFLAGS := -disableAutomaticPackageResolution else LINTFLAGS := FMTFLAGS := +PACKAGEFLAGS := endif PROJECT := Coder-Desktop XCPROJECT := Coder-Desktop/Coder-Desktop.xcodeproj +# The package versions the app is built with. Xcode reads them from inside the project, which +# is generated, so the tracked file is copied there whenever the project is generated. +PACKAGE_RESOLVED := $(PROJECT)/Package.resolved +XCPROJECT_PACKAGE_RESOLVED := $(XCPROJECT)/project.xcworkspace/xcshareddata/swiftpm/Package.resolved SCHEME := Coder\ Desktop TEST_PLAN := Coder-Desktop SWIFT_VERSION := 6.0 @@ -74,7 +81,7 @@ $(addprefix $(PROJECT)/Resources/,$(MUTAGEN_RESOURCES)): $(PROJECT)/Resources/.m echo "$(MUTAGEN_SHA256_$(notdir $@)) $@" | shasum -a 256 -c - || { rm -f "$@"; exit 1; } chmod +x "$@" -$(XCPROJECT): $(PROJECT)/project.yml +$(XCPROJECT): $(PROJECT)/project.yml $(PACKAGE_RESOLVED) cd $(PROJECT); \ SWIFT_VERSION=$(SWIFT_VERSION) \ PTP_SUFFIX=${PTP_SUFFIX} \ @@ -84,6 +91,8 @@ $(XCPROJECT): $(PROJECT)/project.yml MARKETING_VERSION=$(MARKETING_VERSION) \ GIT_COMMIT_HASH=$(GIT_COMMIT_HASH) \ xcodegen + mkdir -p $(dir $(XCPROJECT_PACKAGE_RESOLVED)) + cp $(PACKAGE_RESOLVED) $(XCPROJECT_PACKAGE_RESOLVED) $(PROJECT)/VPNLib/vpn.pb.swift: $(PROJECT)/VPNLib/vpn.proto protoc --swift_opt=Visibility=public --swift_out=. 'Coder-Desktop/VPNLib/vpn.proto' @@ -113,9 +122,15 @@ test: $(addprefix $(PROJECT)/Resources/,$(MUTAGEN_RESOURCES)) $(XCPROJECT) ## Ru -testPlan $(TEST_PLAN) \ -skipMacroValidation \ -skipPackagePluginValidation \ + $(PACKAGEFLAGS) \ CODE_SIGNING_REQUIRED=NO \ CODE_SIGNING_ALLOWED=NO | xcbeautify +.PHONY: lockfile +lockfile: $(XCPROJECT) ## Update Package.resolved after changing packages in project.yml + xcodebuild -resolvePackageDependencies -project $(XCPROJECT) + cp $(XCPROJECT_PACKAGE_RESOLVED) $(PACKAGE_RESOLVED) + .PHONY: lint lint: lint/swift lint/actions ## Lint all files in the repo diff --git a/scripts/build.sh b/scripts/build.sh index 3f2c7485..5fb83e4b 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -78,6 +78,7 @@ xcodebuild \ archive \ -skipMacroValidation \ -skipPackagePluginValidation \ + -disableAutomaticPackageResolution \ CODE_SIGNING_ALLOWED=NO \ CODE_SIGNING_REQUIRED=NO \ CODE_SIGN_IDENTITY="" \ diff --git a/scripts/update-appcast/Package.resolved b/scripts/update-appcast/Package.resolved new file mode 100644 index 00000000..ae57e9ea --- /dev/null +++ b/scripts/update-appcast/Package.resolved @@ -0,0 +1,33 @@ +{ + "originHash" : "2ef197f440849ae28044b67ea7b7625bbd8ab173bb291eb0b01c4b12f98a9bff", + "pins" : [ + { + "identity" : "parsley", + "kind" : "remoteSourceControl", + "location" : "https://github.com/loopwerk/Parsley", + "state" : { + "revision" : "ad35091c7a790f04fc5a912c8bde8963eba753d2", + "version" : "0.9.1" + } + }, + { + "identity" : "swift-argument-parser", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-argument-parser", + "state" : { + "revision" : "6a52f3251125d74daf04fcbd5e6f08a75d074382", + "version" : "1.8.2" + } + }, + { + "identity" : "swift-cmark-gfm", + "kind" : "remoteSourceControl", + "location" : "https://github.com/stackotter/swift-cmark-gfm", + "state" : { + "revision" : "7ec44e7384793e507cf046336aef68586719a24e", + "version" : "1.0.2" + } + } + ], + "version" : 3 +}