-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (126 loc) · 5.01 KB
/
Copy pathrelease-please.yml
File metadata and controls
132 lines (126 loc) · 5.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: release-please
on:
push:
branches: [main]
permissions:
contents: write
pull-requests: write
jobs:
# Maintains a "chore: release X.Y.Z" PR from conventional commits. Merging
# that PR bumps the version, tags it, and creates a draft GitHub Release.
# The release is published only after binaries have been attached, which is
# required when GitHub immutable releases are enabled.
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
# cladding's build.rs embeds the Linux mcp-run/run-remote helpers, which run
# inside cladding's arm64 sandbox containers on Apple silicon. GitHub's macOS
# runners can't run a Linux container to build them, so cross-compile the
# aarch64-linux (glibc, matching the Debian base image) helpers here and hand
# them to the macOS job as an artifact.
build-helpers:
needs: release-please
if: ${{ needs.release-please.outputs.release_created == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-unknown-linux-gnu
- uses: Swatinem/rust-cache@v2
- name: Install aarch64 cross toolchain
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build helpers (aarch64 Linux)
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc
AR_aarch64_unknown_linux_gnu: aarch64-linux-gnu-ar
run: |
cargo build -p mcp-run --release --locked \
--target aarch64-unknown-linux-gnu \
--bin mcp-run --bin run-remote
- name: Stage helpers
run: |
mkdir helpers
cp target/aarch64-unknown-linux-gnu/release/mcp-run helpers/
cp target/aarch64-unknown-linux-gnu/release/run-remote helpers/
- uses: actions/upload-artifact@v4
with:
name: mcp-run-helpers-aarch64-linux
path: helpers/
# Only runs on the push that merges the release PR (release_created == true).
# Builds a release binary per target and attaches it to the draft Release.
upload-binaries:
needs: [release-please, build-helpers]
if: ${{ needs.release-please.outputs.release_created == 'true' }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: aarch64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
# macOS can't run a Linux container to build the embedded helpers, so pull
# the prebuilt aarch64-linux binaries and let build.rs copy them in via the
# CLADDING_MCP_RUN_BIN / CLADDING_RUN_REMOTE_BIN escape hatch. On Linux the
# build.rs builds them locally, so this step is skipped.
- name: Fetch prebuilt helpers
if: runner.os == 'macOS'
uses: actions/download-artifact@v4
with:
name: mcp-run-helpers-aarch64-linux
path: helpers
- name: Point build.rs at prebuilt helpers
if: runner.os == 'macOS'
run: |
echo "CLADDING_MCP_RUN_BIN=$GITHUB_WORKSPACE/helpers/mcp-run" >> "$GITHUB_ENV"
echo "CLADDING_RUN_REMOTE_BIN=$GITHUB_WORKSPACE/helpers/run-remote" >> "$GITHUB_ENV"
# --locked is safe: the cargo-workspace plugin keeps the root Cargo.lock
# in sync with the version bump on the release commit.
- name: Build
run: cargo build --release --locked --target ${{ matrix.target }} -p cladding
- name: Package
shell: bash
run: |
bin=cladding
staging="${bin}-${{ needs.release-please.outputs.tag_name }}-${{ matrix.target }}"
mkdir "$staging"
cp "target/${{ matrix.target }}/release/${bin}" "$staging/"
cp README.md "$staging/"
tar czf "$staging.tar.gz" "$staging"
echo "ASSET=$staging.tar.gz" >> "$GITHUB_ENV"
- name: Upload to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload "${{ needs.release-please.outputs.tag_name }}" "$ASSET" --clobber
publish-release:
needs: [release-please, upload-binaries]
if: ${{ needs.release-please.outputs.release_created == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Publish release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: gh release edit "${{ needs.release-please.outputs.tag_name }}" --draft=false