Release #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' # Trigger on version tags like v1.0.0 | |
| workflow_dispatch: # Allows manual triggering | |
| inputs: | |
| version: | |
| description: 'The version tag to use for the release (e.g., v1.0.0)' | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write # Needed for softprops/action-gh-release | |
| env: | |
| CARGO_TERM_COLOR: always | |
| CRATE_NAME: rustdocs_mcp_server | |
| jobs: | |
| build_assets: | |
| name: Build Asset (${{ matrix.platform.target }}) | |
| strategy: | |
| matrix: | |
| platform: | |
| - release_for: Linux-x86_64 | |
| os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| bin: rustdocs_mcp_server | |
| asset_suffix: linux-x86_64 | |
| - release_for: macOS-x86_64 | |
| os: macos-latest | |
| target: x86_64-apple-darwin | |
| bin: rustdocs_mcp_server | |
| asset_suffix: macos-x86_64 | |
| - release_for: macOS-aarch64 | |
| os: macos-latest # Build arm on x86 runner | |
| target: aarch64-apple-darwin | |
| bin: rustdocs_mcp_server | |
| asset_suffix: macos-aarch64 | |
| - release_for: Windows-x86_64 | |
| os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| bin: rustdocs_mcp_server.exe | |
| asset_suffix: windows-x86_64.exe | |
| runs-on: ${{ matrix.platform.os }} | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@v4 | |
| # Removed specific repo/branch/token - assumes checkout from current repo | |
| - name: Cache cargo & target directories | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ matrix.platform.target }} # Use target in cache key | |
| # --- Install Dependencies --- | |
| - name: Install Linux dependencies | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libssl-dev pkg-config | |
| - name: Install macOS dependencies | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install openssl@3 pkg-config | |
| # Set env vars for openssl-sys build script | |
| echo "OPENSSL_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV | |
| echo "PKG_CONFIG_PATH=$(brew --prefix openssl@3)/lib/pkgconfig" >> $GITHUB_ENV | |
| # --- Build Binary --- | |
| - name: Build binary using actions-rust-cross | |
| uses: houseabsolute/actions-rust-cross@v0 # Using v0 as in your example | |
| with: | |
| # command: build # Default is build | |
| target: ${{ matrix.platform.target }} | |
| args: "--release --verbose" # Removed --locked unless you need it | |
| strip: true # Keep stripping enabled as in your example | |
| # --- Prepare Artifact --- | |
| - name: Determine Artifact Path and Name | |
| id: artifact_details | |
| shell: bash | |
| run: | | |
| BINARY_NAME="${{ matrix.platform.bin }}" | |
| ASSET_NAME="${{ env.CRATE_NAME }}-${{ matrix.platform.asset_suffix }}" | |
| TARGET_DIR="target/${{ matrix.platform.target }}/release" | |
| BINARY_PATH="$TARGET_DIR/$BINARY_NAME" | |
| echo "Calculated binary path: $BINARY_PATH" | |
| echo "Calculated asset name: $ASSET_NAME" | |
| if [[ ! -f "$BINARY_PATH" ]]; then | |
| echo "Error: Binary not found at $BINARY_PATH" | |
| echo "Listing contents of $TARGET_DIR:" | |
| ls -l "$TARGET_DIR" || echo "Could not list $TARGET_DIR" | |
| exit 1 | |
| fi | |
| # Rename binary to the desired asset name | |
| mv "$BINARY_PATH" "$TARGET_DIR/$ASSET_NAME" | |
| echo "Renamed binary to $TARGET_DIR/$ASSET_NAME" | |
| echo "asset_path=$TARGET_DIR/$ASSET_NAME" >> $GITHUB_OUTPUT | |
| echo "asset_name=$ASSET_NAME" >> $GITHUB_OUTPUT | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ steps.artifact_details.outputs.asset_name }} | |
| path: ${{ steps.artifact_details.outputs.asset_path }} | |
| if-no-files-found: error | |
| release: | |
| name: Create GitHub Release | |
| needs: build_assets | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: List downloaded artifacts for debugging | |
| run: | | |
| echo "Listing downloaded artifacts:" | |
| find artifacts -type f | |
| echo "---" | |
| - name: Create Release and Upload Assets | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version || github.ref_name }} | |
| name: Release ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version || github.ref_name }} | |
| body: | | |
| Automated release for ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version || github.ref_name }} | |
| draft: false | |
| prerelease: false | |
| files: artifacts/*/* # Upload all files from all subdirectories within artifacts |