Skip to content

Commit aca3745

Browse files
committed
feat: add release workflow
1 parent a829d89 commit aca3745

File tree

3 files changed

+124
-2
lines changed

3 files changed

+124
-2
lines changed

.github/workflows/release.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*' # Trigger on version tags like v1.0.0
7+
workflow_dispatch: # Allows manual triggering
8+
9+
permissions:
10+
contents: write # Needed to create releases and upload assets
11+
12+
env:
13+
CARGO_TERM_COLOR: always
14+
CRATE_NAME: rustdocs_mcp_server
15+
16+
jobs:
17+
create_release:
18+
name: Create Release
19+
runs-on: ubuntu-latest
20+
outputs:
21+
upload_url: ${{ steps.create_release.outputs.upload_url }}
22+
steps:
23+
- name: Create Release
24+
id: create_release
25+
uses: actions/create-release@v1
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
with:
29+
tag_name: ${{ github.ref_name }}
30+
release_name: Release ${{ github.ref_name }}
31+
body: |
32+
Automated release for ${{ github.ref_name }}
33+
draft: false
34+
prerelease: false
35+
36+
build_release:
37+
name: Build Release Assets
38+
needs: create_release
39+
strategy:
40+
matrix:
41+
include:
42+
- target: x86_64-unknown-linux-gnu
43+
os: ubuntu-latest
44+
asset_name_suffix: linux-x86_64
45+
- target: x86_64-apple-darwin
46+
os: macos-latest
47+
asset_name_suffix: macos-x86_64
48+
- target: aarch64-apple-darwin
49+
os: macos-latest # Can build aarch64 on x86_64 macOS runners
50+
asset_name_suffix: macos-aarch64
51+
- target: x86_64-pc-windows-msvc
52+
os: windows-latest
53+
asset_name_suffix: windows-x86_64.exe # Add .exe for Windows
54+
55+
runs-on: ${{ matrix.os }}
56+
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@v4
59+
60+
- name: Set up Rust toolchain
61+
uses: dtolnay/rust-toolchain@stable
62+
with:
63+
targets: ${{ matrix.target }} # Ensure the target is installed for the host
64+
65+
- name: Install cross-rs
66+
if: runner.os != 'Windows' # cross doesn't work on Windows runners directly for MSVC target
67+
run: cargo install cross --git https://github.com/cross-rs/cross --rev 1131999 # Use specific rev for stability
68+
69+
- name: Build binary (cross)
70+
if: runner.os != 'Windows'
71+
run: cross build --release --target ${{ matrix.target }} --verbose
72+
env:
73+
# Set linker for Linux MUSL if needed, otherwise default GNU is fine
74+
# For macOS, default linker works
75+
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER: gcc
76+
# Add other specific env vars if needed for cross-compilation
77+
78+
- name: Build binary (native Windows)
79+
if: runner.os == 'Windows'
80+
run: cargo build --release --target ${{ matrix.target }} --verbose
81+
82+
- name: Determine Artifact Path and Name
83+
id: artifact_details
84+
shell: bash
85+
run: |
86+
BINARY_NAME="${{ env.CRATE_NAME }}"
87+
ASSET_SUFFIX="${{ matrix.asset_name_suffix }}"
88+
TARGET_DIR="target/${{ matrix.target }}/release"
89+
90+
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
91+
BINARY_PATH="$TARGET_DIR/$BINARY_NAME.exe"
92+
ASSET_NAME="$BINARY_NAME-$ASSET_SUFFIX" # Suffix already includes .exe
93+
else
94+
BINARY_PATH="$TARGET_DIR/$BINARY_NAME"
95+
ASSET_NAME="$BINARY_NAME-$ASSET_SUFFIX"
96+
fi
97+
98+
echo "Calculated binary path: $BINARY_PATH"
99+
echo "Calculated asset name: $ASSET_NAME"
100+
101+
# Check if the binary exists
102+
if [[ ! -f "$BINARY_PATH" ]]; then
103+
echo "Error: Binary not found at $BINARY_PATH"
104+
# List directory contents for debugging
105+
echo "Listing contents of $TARGET_DIR:"
106+
ls -l "$TARGET_DIR"
107+
exit 1
108+
fi
109+
110+
echo "binary_path=$BINARY_PATH" >> $GITHUB_OUTPUT
111+
echo "asset_name=$ASSET_NAME" >> $GITHUB_OUTPUT
112+
113+
114+
- name: Upload Release Asset
115+
uses: actions/upload-release-asset@v1
116+
env:
117+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
118+
with:
119+
upload_url: ${{ needs.create_release.outputs.upload_url }}
120+
asset_path: ${{ steps.artifact_details.outputs.binary_path }}
121+
asset_name: ${{ steps.artifact_details.outputs.asset_name }}
122+
asset_content_type: application/octet-stream

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rustdocs_mcp_server"
3-
version = "0.1.0"
3+
version = "1.0.0"
44
edition = "2024"
55

66
[dependencies]

0 commit comments

Comments
 (0)