diff --git a/.github/workflows/build_publish.yml b/.github/workflows/build_publish.yml index 8b13789..f227a63 100644 --- a/.github/workflows/build_publish.yml +++ b/.github/workflows/build_publish.yml @@ -1 +1,39 @@ +name: Build and Test +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + build: + runs-on: macos-15 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@main + + - name: Show Swift version + run: | + swift --version + xcodebuild -version + + - name: Build with Nix + run: | + nix build .#default --print-build-logs + + - name: Verify binary exists + run: | + test -f result/bin/WhoseDefaultBrowser && echo "Build successful!" || exit 1 + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: WhoseDefaultBrowser + path: result/bin/WhoseDefaultBrowser diff --git a/flake.nix b/flake.nix index 4ae1a3d..387b05d 100644 --- a/flake.nix +++ b/flake.nix @@ -31,10 +31,19 @@ }; buildInputs = [ pkgs.darwin.apple_sdk.frameworks.CoreServices ]; buildPhase = '' - export PATH=$PATH:/usr/bin:/usr/local/bin - export SDKROOT=$(xcrun --show-sdk-path) - export MACOSX_DEPLOYMENT_TARGET=10.15 - xcrun swiftc -o WhoseDefaultBrowser main.swift + export PATH="/usr/bin:/usr/local/bin:$PATH" + + # Use the latest SDK and Swift from the system's Xcode + export SDKROOT=$(/usr/bin/xcrun --sdk macosx --show-sdk-path) + export DEVELOPER_DIR=$(/usr/bin/xcode-select -p) + export MACOSX_DEPLOYMENT_TARGET=15.0 + + # Use xcodebuild for compilation (compatible with macOS 26+ Xcode) + /usr/bin/xcrun --sdk macosx swiftc \ + -o WhoseDefaultBrowser \ + -sdk "$SDKROOT" \ + -target ${if system == "aarch64-darwin" then "arm64" else "x86_64"}-apple-macosx15.0 \ + main.swift ''; installPhase = '' mkdir -p $out/bin