1212 type : string
1313
1414permissions :
15- contents : write # Needed for softprops/action-gh-release to create releases and upload assets
15+ contents : write # Needed for softprops/action-gh-release
1616
1717env :
1818 CARGO_TERM_COLOR : always
1919 CRATE_NAME : rustdocs_mcp_server
2020
2121jobs :
2222 build_assets :
23- name : Build Asset (${{ matrix.target }})
23+ name : Build Asset (${{ matrix.platform. target }})
2424 strategy :
2525 matrix :
26- include :
27- - target : x86_64-unknown-linux-gnu
28- os : ubuntu-latest # Use Linux runner for Nix
29- asset_name_suffix : linux-x86_64
30- binary_name_suffix : " "
31- use_nix : true
32- - target : x86_64-apple-darwin
33- os : macos-latest # Use macOS runner for Nix
34- asset_name_suffix : macos- x86_64
35- binary_name_suffix : " "
36- use_nix : true
37- - target : aarch64-apple-darwin
38- os : macos-latest # Use macOS runner for Nix
39- asset_name_suffix : macos- aarch64
40- binary_name_suffix : " "
41- use_nix : true
42- - target : x86_64-pc-windows-msvc
43- os : windows-latest # Windows runner, build natively
44- asset_name_suffix : windows-x86_64.exe
45- binary_name_suffix : " .exe"
46- use_nix : false
47-
48- runs-on : ${{ matrix.os }}
26+ platform :
27+ - release_for : Linux-x86_64
28+ os : ubuntu-latest
29+ target : x86_64-unknown- linux-gnu
30+ bin : rustdocs_mcp_server
31+ asset_suffix : linux-x86_64
32+ - release_for : macOS-x86_64
33+ os : macos-latest
34+ target : x86_64-apple-darwin
35+ bin : rustdocs_mcp_server
36+ asset_suffix : macos-x86_64
37+ - release_for : macOS-aarch64
38+ os : macos-latest # Build arm on x86 runner
39+ target : aarch64-apple-darwin
40+ bin : rustdocs_mcp_server
41+ asset_suffix : macos-aarch64
42+ - release_for : Windows-x86_64
43+ os : windows-latest
44+ target : x86_64-pc- windows-msvc
45+ bin : rustdocs_mcp_server .exe
46+ asset_suffix : windows-x86_64.exe
47+
48+ runs-on : ${{ matrix.platform. os }}
4949 steps :
50- - name : Checkout code
50+ - name : Check out repo
5151 uses : actions/checkout@v4
52+ # Removed specific repo/branch/token - assumes checkout from current repo
5253
53- # --- Nix Setup (Linux/macOS) ---
54- - name : Install Nix
55- if : matrix.use_nix == true
56- uses : cachix/install-nix-action@v31
54+ - name : Cache cargo & target directories
55+ uses : Swatinem/rust-cache@v2
5756 with :
58- # Use GitHub token to avoid rate limiting when fetching flakes
59- github_access_token : ${{ secrets.GITHUB_TOKEN }}
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
67- with :
68- targets : ${{ matrix.target }}
57+ key : ${{ matrix.platform.target }} # Use target in cache key
58+
59+ # --- Install Dependencies ---
60+ - name : Install Linux dependencies
61+ if : runner.os == 'Linux'
62+ run : |
63+ sudo apt-get update
64+ sudo apt-get install -y libssl-dev pkg-config
6965
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
66+ - name : Install macOS dependencies
67+ if : runner.os == 'macOS'
7568 run : |
76- nix develop .#default --command bash -c ' \
77- echo "Adding target ${{ matrix.target }} with rustup..." && \
78- rustup target add ${{ matrix.target }} && \
79- echo "Building for target ${{ matrix.target }}..." && \
80- cargo build --release --target ${{ matrix.target }} --verbose \
81- '
82-
83- - name : Build binary
84- if : matrix.use_nix == false
85- run : cargo build --release --target ${{ matrix.target }} --verbose
86-
87- # --- Artifact Handling ---
69+ brew install openssl@3 pkg-config
70+ # Set env vars for openssl-sys build script
71+ echo "OPENSSL_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV
72+ echo "PKG_CONFIG_PATH=$(brew --prefix openssl@3)/lib/pkgconfig" >> $GITHUB_ENV
73+
74+ # --- Build Binary ---
75+ - name : Build binary using actions-rust-cross
76+ uses : houseabsolute/actions-rust-cross@v0 # Using v0 as in your example
77+ with :
78+ # command: build # Default is build
79+ target : ${{ matrix.platform.target }}
80+ args : " --release --verbose" # Removed --locked unless you need it
81+ strip : true # Keep stripping enabled as in your example
82+
83+ # --- Prepare Artifact ---
8884 - name : Determine Artifact Path and Name
8985 id : artifact_details
9086 shell : bash
9187 run : |
92- BINARY_NAME="${{ env.CRATE_NAME }}${{ matrix.binary_name_suffix }}"
93- ASSET_NAME="${{ env.CRATE_NAME }}-${{ matrix.asset_name_suffix }}"
94- TARGET_DIR="target/${{ matrix.target }}/release"
88+ BINARY_NAME="${{ matrix.platform.bin }}"
89+ ASSET_NAME="${{ env.CRATE_NAME }}-${{ matrix.platform.asset_suffix }}"
90+ TARGET_DIR="target/${{ matrix.platform. target }}/release"
9591 BINARY_PATH="$TARGET_DIR/$BINARY_NAME"
9692
9793 echo "Calculated binary path: $BINARY_PATH"
@@ -100,13 +96,7 @@ jobs:
10096 if [[ ! -f "$BINARY_PATH" ]]; then
10197 echo "Error: Binary not found at $BINARY_PATH"
10298 echo "Listing contents of $TARGET_DIR:"
103- if [[ -d "$TARGET_DIR" ]]; then
104- ls -l "$TARGET_DIR"
105- else
106- echo "Target directory $TARGET_DIR does not exist."
107- echo "Listing contents of ./target directory:"
108- ls -l ./target || echo "Could not list ./target"
109- fi
99+ ls -l "$TARGET_DIR" || echo "Could not list $TARGET_DIR"
110100 exit 1
111101 fi
112102
@@ -132,7 +122,7 @@ jobs:
132122 - name : Download all artifacts
133123 uses : actions/download-artifact@v4
134124 with :
135- path : artifacts # Download all artifacts to a directory named 'artifacts'
125+ path : artifacts
136126
137127 - name : List downloaded artifacts for debugging
138128 run : |
0 commit comments