@@ -80,12 +80,22 @@ jobs:
8080 with :
8181 tool : cargo-semver-checks
8282
83+ - name : Determine semver release type
84+ run : |
85+ if git log --format=%B \
86+ ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} \
87+ | grep -Eq '(^[A-Za-z0-9_-]+(\([^)]*\))?!:|^BREAKING[ -]CHANGE:)'; then
88+ echo "SEMVER_RELEASE_TYPE=major" >> "$GITHUB_ENV"
89+ else
90+ echo "SEMVER_RELEASE_TYPE=minor" >> "$GITHUB_ENV"
91+ fi
92+
8393 - name : Check rmcp (default features)
8494 run : |
8595 cargo semver-checks \
8696 --package rmcp \
8797 --baseline-rev ${{ github.event.pull_request.base.sha }} \
88- --release-type minor \
98+ --release-type "$SEMVER_RELEASE_TYPE" \
8999 --only-explicit-features \
90100 --features default
91101
@@ -98,10 +108,81 @@ jobs:
98108 cargo semver-checks \
99109 --package rmcp \
100110 --baseline-rev ${{ github.event.pull_request.base.sha }} \
101- --release-type minor \
111+ --release-type "$SEMVER_RELEASE_TYPE" \
102112 --only-explicit-features \
103113 --features "$FEATURES"
104114
115+ public-api :
116+ name : Public API Check
117+ runs-on : ubuntu-latest
118+ if : github.event_name == 'pull_request'
119+ steps :
120+ - uses : actions/checkout@v7
121+ with :
122+ fetch-depth : 0
123+
124+ # cargo-public-api builds rustdoc JSON, which requires a nightly toolchain
125+ # to be installed (it does not need to be the default; the tool invokes it
126+ # via `cargo +nightly`).
127+ - name : Install Rust
128+ uses : dtolnay/rust-toolchain@nightly
129+
130+ - uses : Swatinem/rust-cache@v2
131+
132+ - name : Install cargo-public-api
133+ uses : taiki-e/install-action@v2
134+ with :
135+ tool : cargo-public-api
136+
137+ # Mirror the SemVer Check job's release-type detection: a breaking-change
138+ # commit marker (`!:` or `BREAKING CHANGE:`) means a major release (any API
139+ # change is allowed); otherwise a minor release (additions allowed, but
140+ # changed/removed public items are denied). This catches breaking changes
141+ # that cargo-semver-checks cannot yet detect, such as a change to a
142+ # function's return type or a field's type.
143+ # See https://github.com/obi1kenobi/cargo-semver-checks/issues/5
144+ - name : Determine release type and deny flags
145+ run : |
146+ if git log --format=%B \
147+ ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} \
148+ | grep -Eq '(^[A-Za-z0-9_-]+(\([^)]*\))?!:|^BREAKING[ -]CHANGE:)'; then
149+ SEMVER_RELEASE_TYPE=major
150+ else
151+ SEMVER_RELEASE_TYPE=minor
152+ fi
153+ case "$SEMVER_RELEASE_TYPE" in
154+ major) DENY="" ;;
155+ patch) DENY="--deny added --deny changed --deny removed" ;;
156+ *) DENY="--deny changed --deny removed" ;;
157+ esac
158+ echo "SEMVER_RELEASE_TYPE=$SEMVER_RELEASE_TYPE" >> "$GITHUB_ENV"
159+ echo "DENY=$DENY" >> "$GITHUB_ENV"
160+
161+ - name : Check rmcp (default features)
162+ run : |
163+ cargo public-api \
164+ --package rmcp \
165+ -ss \
166+ diff \
167+ $DENY \
168+ --force \
169+ ${{ github.event.pull_request.base.sha }}..${{ github.sha }}
170+
171+ - name : Check rmcp (all features except local)
172+ run : |
173+ FEATURES=$(cargo metadata --no-deps --format-version 1 \
174+ | jq -r '[.packages[] | select(.name == "rmcp") | .features | keys[]
175+ | select(startswith("__") | not)
176+ | select(. != "local")] | join(",")')
177+ cargo public-api \
178+ --package rmcp \
179+ --features "$FEATURES" \
180+ -ss \
181+ diff \
182+ $DENY \
183+ --force \
184+ ${{ github.event.pull_request.base.sha }}..${{ github.sha }}
185+
105186 spelling :
106187 name : spell check with typos
107188 runs-on : ubuntu-latest
0 commit comments