Skip to content

Commit c2bbd9f

Browse files
Implement CI and build releases (vibe-kanban 2ef3e91a)
Implement CI and build releases Please copy the pre-release and logic that allows us to use JS + NPX to distribute the rust binary, with code signing on mac. You can view some examples in a different repo at /Users/lkw/Documents/repos/vibe-kanban - .github/workflows/pre-release.yml - .github/workflows/publish.yml - npx-cli/bin/cli.js - npx-cli/package.json
1 parent d911829 commit c2bbd9f

File tree

6 files changed

+587
-0
lines changed

6 files changed

+587
-0
lines changed

.github/workflows/pre-release.yml

Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
name: Create GitHub Pre-Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_type:
7+
description: "Version bump type"
8+
required: true
9+
default: "patch"
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
- prerelease
16+
17+
concurrency:
18+
group: release-${{ github.ref_name }}
19+
cancel-in-progress: true
20+
21+
permissions:
22+
contents: write
23+
packages: write
24+
25+
env:
26+
NODE_VERSION: 22
27+
RUST_TOOLCHAIN: stable
28+
29+
jobs:
30+
bump-version:
31+
runs-on: ubuntu-latest
32+
outputs:
33+
new_tag: ${{ steps.version.outputs.new_tag }}
34+
new_version: ${{ steps.version.outputs.new_version }}
35+
branch_suffix: ${{ steps.branch.outputs.suffix }}
36+
steps:
37+
- uses: actions/checkout@v4
38+
with:
39+
token: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Setup Node
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version: ${{ env.NODE_VERSION }}
45+
46+
- name: Cache cargo-edit
47+
uses: actions/cache@v3
48+
id: cache-cargo-edit
49+
with:
50+
path: ~/.cargo/bin/cargo-set-version
51+
key: cargo-edit-${{ runner.os }}-${{ env.RUST_TOOLCHAIN }}
52+
53+
- name: Install cargo-edit
54+
if: steps.cache-cargo-edit.outputs.cache-hit != 'true'
55+
run: cargo install cargo-edit
56+
57+
- name: Generate branch suffix
58+
id: branch
59+
run: |
60+
branch_name="${{ github.ref_name }}"
61+
suffix=$(echo "$branch_name" | tail -c 7 | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]')
62+
echo "Branch: $branch_name"
63+
echo "Suffix: $suffix"
64+
echo "suffix=$suffix" >> $GITHUB_OUTPUT
65+
66+
- name: Determine and update versions
67+
id: version
68+
run: |
69+
latest_npm_version=$(npm view mcp-dev-manager version 2>/dev/null || echo "0.0.0")
70+
echo "Latest npm version: $latest_npm_version"
71+
72+
timestamp=$(date +%Y%m%d%H%M%S)
73+
74+
cd npx-cli
75+
if [[ "${{ github.event.inputs.version_type }}" == "prerelease" ]]; then
76+
npm version prerelease --preid="${{ steps.branch.outputs.suffix }}" --no-git-tag-version
77+
new_version=$(node -p "require('./package.json').version")
78+
new_tag="v${new_version}.${timestamp}"
79+
else
80+
npm version $latest_npm_version --no-git-tag-version --allow-same-version
81+
npm version ${{ github.event.inputs.version_type }} --no-git-tag-version
82+
new_version=$(node -p "require('./package.json').version")
83+
new_tag="v${new_version}-${timestamp}"
84+
fi
85+
cd ..
86+
87+
cargo set-version "$new_version"
88+
89+
echo "New version: $new_version"
90+
echo "new_version=$new_version" >> $GITHUB_OUTPUT
91+
echo "new_tag=$new_tag" >> $GITHUB_OUTPUT
92+
93+
- name: Commit changes and create tag
94+
run: |
95+
git config --local user.email "[email protected]"
96+
git config --local user.name "GitHub Action"
97+
git add npx-cli/package.json Cargo.toml
98+
git commit -m "chore: bump version to ${{ steps.version.outputs.new_version }}"
99+
git tag -a ${{ steps.version.outputs.new_tag }} -m "Release ${{ steps.version.outputs.new_tag }}"
100+
git push
101+
git push --tags
102+
103+
build-backend:
104+
needs: bump-version
105+
runs-on: ${{ matrix.os }}
106+
container: ${{ matrix.container }}
107+
strategy:
108+
matrix:
109+
include:
110+
- target: x86_64-unknown-linux-musl
111+
os: ubuntu-latest
112+
container: ghcr.io/rust-cross/cargo-zigbuild@sha256:af1bc2b869c5d76c1300f7a4685c2f1793d068e6e895c9f5c399b517b31a731e
113+
name: linux-x64
114+
- target: aarch64-unknown-linux-musl
115+
os: ubuntu-latest
116+
name: linux-arm64
117+
container: ghcr.io/rust-cross/cargo-zigbuild@sha256:af1bc2b869c5d76c1300f7a4685c2f1793d068e6e895c9f5c399b517b31a731e
118+
- target: x86_64-pc-windows-msvc
119+
os: windows-latest
120+
name: windows-x64
121+
- target: x86_64-apple-darwin
122+
os: macos-13
123+
name: macos-x64
124+
- target: aarch64-apple-darwin
125+
os: macos-14
126+
name: macos-arm64
127+
- target: aarch64-pc-windows-msvc
128+
os: windows-latest
129+
name: windows-arm64
130+
steps:
131+
- uses: actions/checkout@v4
132+
with:
133+
ref: ${{ needs.bump-version.outputs.new_tag }}
134+
135+
- name: Install Rust toolchain
136+
uses: dtolnay/rust-toolchain@stable
137+
with:
138+
toolchain: ${{ env.RUST_TOOLCHAIN }}
139+
targets: ${{ matrix.target }}
140+
141+
- name: Install libclang (Linux)
142+
if: runner.os == 'Linux'
143+
run: |
144+
apt-get update
145+
DEBIAN_FRONTEND=noninteractive apt-get install -y clang libclang-dev
146+
147+
- name: Cache Rust dependencies
148+
uses: Swatinem/rust-cache@v2
149+
with:
150+
workspaces: "."
151+
prefix-key: "cache-v1.0"
152+
key: ${{ matrix.target }}_${{ matrix.os }}
153+
cache-on-failure: true
154+
shared-key: "shared"
155+
cache-all-crates: true
156+
157+
- name: Build backend (Linux)
158+
if: runner.os == 'Linux'
159+
run: cargo zigbuild --release --target ${{ matrix.target }}
160+
161+
- name: Build backend (non-Linux)
162+
if: runner.os != 'Linux'
163+
run: cargo build --release --target ${{ matrix.target }}
164+
165+
- name: Prepare binaries (non-macOS)
166+
if: runner.os != 'macOS'
167+
shell: bash
168+
run: |
169+
mkdir -p dist
170+
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
171+
cp target/${{ matrix.target }}/release/mcp-dev-manager.exe dist/mcp-dev-manager-${{ matrix.name }}.exe
172+
else
173+
cp target/${{ matrix.target }}/release/mcp-dev-manager dist/mcp-dev-manager-${{ matrix.name }}
174+
fi
175+
176+
- name: Prepare Apple certificate (macOS)
177+
if: runner.os == 'macOS'
178+
run: |
179+
echo "${{ secrets.APPLE_CERTIFICATE_P12_BASE64 }}" | base64 --decode > certificate.p12
180+
181+
- name: Sign binary (macOS)
182+
if: runner.os == 'macOS'
183+
uses: indygreg/apple-code-sign-action@v1
184+
with:
185+
input_path: target/${{ matrix.target }}/release/mcp-dev-manager
186+
output_path: mcp-dev-manager
187+
p12_file: certificate.p12
188+
p12_password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
189+
sign: true
190+
sign_args: "--code-signature-flags=runtime"
191+
192+
- name: Package binary (macOS)
193+
if: runner.os == 'macOS'
194+
run: zip mcp-dev-manager.zip mcp-dev-manager
195+
196+
- name: Prepare signed binaries (macOS)
197+
if: runner.os == 'macOS'
198+
run: |
199+
mkdir -p dist
200+
cp mcp-dev-manager.zip dist/mcp-dev-manager-${{ matrix.name }}.zip
201+
202+
- name: Clean up certificates (macOS)
203+
if: runner.os == 'macOS'
204+
run: rm -f certificate.p12
205+
206+
- name: Upload binary artifact
207+
uses: actions/upload-artifact@v4
208+
with:
209+
name: backend-binary-${{ matrix.name }}
210+
path: dist/
211+
retention-days: 1
212+
213+
package-npx-cli:
214+
needs: [bump-version, build-backend]
215+
runs-on: ubuntu-latest
216+
strategy:
217+
matrix:
218+
include:
219+
- target: x86_64-unknown-linux-musl
220+
name: linux-x64
221+
binary: mcp-dev-manager
222+
- target: x86_64-pc-windows-msvc
223+
name: windows-x64
224+
binary: mcp-dev-manager.exe
225+
- target: x86_64-apple-darwin
226+
name: macos-x64
227+
binary: mcp-dev-manager
228+
- target: aarch64-apple-darwin
229+
name: macos-arm64
230+
binary: mcp-dev-manager
231+
- target: aarch64-pc-windows-msvc
232+
name: windows-arm64
233+
binary: mcp-dev-manager.exe
234+
- target: aarch64-unknown-linux-musl
235+
name: linux-arm64
236+
binary: mcp-dev-manager
237+
steps:
238+
- uses: actions/checkout@v4
239+
with:
240+
ref: ${{ needs.bump-version.outputs.new_tag }}
241+
242+
- name: Download backend binary artifact
243+
uses: actions/download-artifact@v4
244+
with:
245+
name: backend-binary-${{ matrix.name }}
246+
path: dist/
247+
248+
- name: Create platform package
249+
if: matrix.name != 'macos-arm64' && matrix.name != 'macos-x64'
250+
run: |
251+
mkdir -p npx-cli/dist/${{ matrix.name }}
252+
mkdir mcp-dev-manager-${{ matrix.name }}
253+
254+
cp dist/mcp-dev-manager-${{ matrix.name }}* mcp-dev-manager-${{ matrix.name }}/${{ matrix.binary }}
255+
256+
zip -j npx-cli/dist/${{ matrix.name }}/mcp-dev-manager.zip mcp-dev-manager-${{ matrix.name }}/${{ matrix.binary }}
257+
258+
- name: Create platform package (macOS)
259+
if: matrix.name == 'macos-arm64' || matrix.name == 'macos-x64'
260+
run: |
261+
mkdir -p npx-cli/dist/${{ matrix.name }}
262+
cp dist/mcp-dev-manager-${{ matrix.name }}* npx-cli/dist/${{ matrix.name }}/mcp-dev-manager.zip
263+
264+
- name: Upload platform package artifact
265+
uses: actions/upload-artifact@v4
266+
with:
267+
name: npx-platform-${{ matrix.name }}
268+
path: npx-cli/dist/
269+
retention-days: 1
270+
271+
create-prerelease:
272+
needs: [bump-version, build-backend, package-npx-cli]
273+
runs-on: ubuntu-latest
274+
steps:
275+
- uses: actions/checkout@v4
276+
with:
277+
ref: ${{ needs.bump-version.outputs.new_tag }}
278+
279+
- name: Download backend npx-cli zips
280+
uses: actions/download-artifact@v4
281+
with:
282+
pattern: npx-platform-*
283+
path: npx-cli/dist/
284+
merge-multiple: true
285+
286+
- name: Setup Node for npm pack
287+
uses: actions/setup-node@v4
288+
with:
289+
node-version: ${{ env.NODE_VERSION }}
290+
291+
- name: Pack
292+
run: |
293+
cd npx-cli
294+
npm pack
295+
296+
- name: Create GitHub Pre-Release
297+
uses: softprops/action-gh-release@v2
298+
with:
299+
tag_name: ${{ needs.bump-version.outputs.new_tag }}
300+
name: Pre-release ${{ needs.bump-version.outputs.new_tag }}
301+
prerelease: true
302+
generate_release_notes: true
303+
files: |
304+
npx-cli/mcp-dev-manager-*.tgz

0 commit comments

Comments
 (0)