@@ -24,68 +24,59 @@ jobs:
2424    strategy :
2525      matrix :
2626        include :
27-           #  Nix builds (native)
2827          - target : x86_64-unknown-linux-gnu 
29-             os : ubuntu-latest 
30-             build_method : nix 
28+             os : ubuntu-latest  #  Use Linux runner for Nix
3129            asset_name_suffix : linux-x86_64 
3230            binary_name_suffix : " " 
31+             use_nix : true 
3332          - target : x86_64-apple-darwin 
34-             os : macos-latest 
35-             build_method : nix 
33+             os : macos-latest  #  Use macOS runner for Nix
3634            asset_name_suffix : macos-x86_64 
3735            binary_name_suffix : " " 
38-           #  Cross builds 
36+              use_nix :  true 
3937          - target : aarch64-apple-darwin 
40-             os : macos-latest  #  Cross-compile from x86_64 runner
41-             build_method : cross 
38+             os : macos-latest  #  Use macOS runner for Nix
4239            asset_name_suffix : macos-aarch64 
4340            binary_name_suffix : " " 
41+             use_nix : true 
4442          - target : x86_64-pc-windows-msvc 
45-             os : windows-latest 
46-             build_method : cross 
43+             os : windows-latest  #  Windows runner, build natively
4744            asset_name_suffix : windows-x86_64.exe 
4845            binary_name_suffix : " .exe" 
46+             use_nix : false 
4947
5048    runs-on : ${{ matrix.os }} 
5149    steps :
5250      - name : Checkout code 
5351        uses : actions/checkout@v4 
5452
55-       #  --- Nix Setup (only runs if build_method is nix ) ---
53+       #  --- Nix Setup (Linux/macOS ) ---
5654      - name : Install Nix 
55+         if : matrix.use_nix == true 
5756        uses : cachix/install-nix-action@v31 
58-         if : matrix.build_method == 'nix' 
5957        with :
58+           #  Use GitHub token to avoid rate limiting when fetching flakes
6059          github_access_token : ${{ secrets.GITHUB_TOKEN }} 
61-           #  Ensure flakes are enabled (default in recent versions, but explicit is safe)
62-           extra_nix_config : | 
63-             experimental-features = nix-command flakes 
64-             access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} 
65- 
66- #  --- Dependency Setup for Cross-Compile (only runs if build_method is cross) ---
67-       - name : Install macOS dependencies (for cross-compile) 
68-         #  Only needed when cross-compiling aarch64 on an x86_64 macOS runner
69-         if : matrix.build_method == 'cross' && matrix.target == 'aarch64-apple-darwin' 
70-         run : | 
71-           brew install openssl@3 pkg-config 
72-           echo "OPENSSL_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV 
73-           echo "PKG_CONFIG_PATH=$(brew --prefix openssl@3)/lib/pkgconfig" >> $GITHUB_ENV 
74- 
75- #  --- Build Steps (conditional) ---
76-       - name : Build binary using Nix 
77-         if : matrix.build_method == 'nix' 
78-         #  Assuming your flake provides the crate binary via the default package `.#rustdocs_mcp_server`
79-         #  or adjust the flake output reference as needed (e.g., .#packages.${system}.default)
80-         run : nix build .#${CRATE_NAME} --print-build-logs 
81- 
82-       - name : Build binary using actions-rust-cross 
83-         if : matrix.build_method == 'cross' 
84-         uses : houseabsolute/actions-rust-cross@v1 
60+           #  extra_nix_config: |
61+           #    experimental-features = nix-command flakes
62+ 
63+       #  --- Native Rust Setup (Windows) ---
64+       - name : Set up Rust toolchain (Windows only) 
65+         if : matrix.use_nix == false 
66+         uses : dtolnay/rust-toolchain@stable 
8567        with :
86-           target : ${{ matrix.target }} 
87-           args : " --release --verbose" 
88-           strip : false  #  Keep strip false for consistency, especially with cross-compiles
68+           targets : ${{ matrix.target }} 
69+ 
70+       #  --- Build Step ---
71+       - name : Build binary (Nix) 
72+         if : matrix.use_nix == true 
73+         #  Run the cargo build command within the Nix development shell
74+         #  This ensures all dependencies from flake.nix (like openssl) are available
75+         run : nix develop .#rust-dev --command cargo build --release --target ${{ matrix.target }} --verbose 
76+ 
77+       - name : Build binary (Windows Native) 
78+         if : matrix.use_nix == false 
79+         run : cargo build --release --target ${{ matrix.target }} --verbose 
8980
9081      #  --- Artifact Handling ---
9182      - name : Determine Artifact Path and Name 
@@ -94,47 +85,38 @@ jobs:
9485        run : | 
9586          BINARY_NAME="${{ env.CRATE_NAME }}${{ matrix.binary_name_suffix }}" 
9687          ASSET_NAME="${{ env.CRATE_NAME }}-${{ matrix.asset_name_suffix }}" 
88+           TARGET_DIR="target/${{ matrix.target }}/release" 
89+           BINARY_PATH="$TARGET_DIR/$BINARY_NAME" 
9790
98-           if [[ "${{ matrix.build_method }}" == "nix" ]]; then 
99-             # Nix build output path (adjust if flake output is different) 
100-             # Assumes the binary is directly in result/bin/ 
101-             BINARY_PATH="./result/bin/$BINARY_NAME" 
102-           else 
103-             # Cross build output path 
104-             BINARY_PATH="target/${{ matrix.target }}/release/$BINARY_NAME" 
105-           fi 
106- 
107-           echo "Build method: ${{ matrix.build_method }}" 
10891          echo "Calculated binary path: $BINARY_PATH" 
10992          echo "Calculated asset name: $ASSET_NAME" 
11093
111-           # Check if the binary exists 
11294          if [[ ! -f "$BINARY_PATH" ]]; then 
11395            echo "Error: Binary not found at $BINARY_PATH" 
114-             echo "Listing contents of potential output directories:" 
115-             echo "--- Nix build (./result/bin):" 
116-             ls -l ./result/bin || echo "Directory ./result/bin not found or empty." 
117-             echo "--- Cross build (target/${{ matrix.target }}/release):" 
118-             ls -l target/${{ matrix.target }}/release || echo "Directory target/${{ matrix.target }}/release not found or empty." 
96+             echo "Listing contents of $TARGET_DIR:" 
97+             if [[ -d "$TARGET_DIR" ]]; then 
98+               ls -l "$TARGET_DIR" 
99+             else 
100+               echo "Target directory $TARGET_DIR does not exist." 
101+               echo "Listing contents of ./target directory:" 
102+               ls -l ./target || echo "Could not list ./target" 
103+             fi 
119104            exit 1 
120105          fi 
121106
122-           # Create a temporary directory for consistent artifact upload 
123-           mkdir -p ./artifacts_temp 
124-           RENAMED_PATH="./artifacts_temp/$ASSET_NAME" 
125-           # Move the binary to the temp dir with the final asset name 
126-           mv "$BINARY_PATH" "$RENAMED_PATH" 
127-           echo "Moved/Renamed binary to $RENAMED_PATH" 
107+           # Rename binary to the desired asset name 
108+           mv "$BINARY_PATH" "$TARGET_DIR/$ASSET_NAME" 
109+           echo "Renamed binary to $TARGET_DIR/$ASSET_NAME" 
128110
129-           echo "asset_path=$RENAMED_PATH " >> $GITHUB_OUTPUT 
111+           echo "asset_path=$TARGET_DIR/$ASSET_NAME " >> $GITHUB_OUTPUT 
130112          echo "asset_name=$ASSET_NAME" >> $GITHUB_OUTPUT 
131113
132114name : Upload Artifact 
133115        uses : actions/upload-artifact@v4 
134116        with :
135-           name : ${{ steps.artifact_details.outputs.asset_name }}   #  Use asset name for artifact name 
117+           name : ${{ steps.artifact_details.outputs.asset_name }} 
136118          path : ${{ steps.artifact_details.outputs.asset_path }} 
137-           if-no-files-found : error   #  Error if the artifact isn't found 
119+           if-no-files-found : error 
138120
139121  release :
140122    name : Create GitHub Release 
@@ -155,7 +137,6 @@ jobs:
155137name : Create Release and Upload Assets 
156138        uses : softprops/action-gh-release@v2 
157139        with :
158-           #  Use the input version for manual triggers, otherwise use the tag ref
159140          tag_name : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version || github.ref_name }} 
160141          name : Release ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version || github.ref_name }} 
161142          body : | 
0 commit comments