Skip to content

Commit 6ebac51

Browse files
Copilotpetesramek
andauthored
Fix update-api-unshipped to handle dropped preview APIs
Agent-Logs-Url: https://github.com/petesramek/polyline-algorithm-csharp/sessions/b29b300b-90b6-496a-a4d6-a2f7e600bc3a Co-authored-by: petesramek <2333452+petesramek@users.noreply.github.com>
1 parent 1c11efc commit 6ebac51

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,10 @@ jobs:
171171

172172
update-api-unshipped:
173173
name: 'Update PublicAPI.Unshipped.txt'
174-
needs: [workflow-variables, build, validate-release]
175-
if: ${{ needs.workflow-variables.outputs.is-preview == 'true' }}
174+
needs: [workflow-variables, validate-release]
175+
# Run even when build fails — the build may fail solely because a dropped preview API is still
176+
# listed in Unshipped.txt (RS0017). This job fixes exactly that, so it must not be gated on build.
177+
if: ${{ needs.workflow-variables.outputs.is-preview == 'true' && needs.validate-release.result == 'success' }}
176178
runs-on: ubuntu-latest
177179
steps:
178180
- name: 'Checkout ${{ github.ref }}'
@@ -183,9 +185,25 @@ jobs:
183185
with:
184186
dotnet-version: ${{ env.dotnet-sdk-version }}
185187

186-
- name: 'Add missing API declarations to PublicAPI.Unshipped.txt'
188+
- name: 'Snapshot PublicAPI.Shipped.txt'
189+
shell: bash
190+
run: cp src/PolylineAlgorithm/PublicAPI.Shipped.txt src/PolylineAlgorithm/PublicAPI.Shipped.txt.bak
191+
192+
- name: 'Sync PublicAPI.Unshipped.txt (add new + remove dropped preview APIs)'
193+
shell: bash
194+
run: dotnet format analyzers src/PolylineAlgorithm/PolylineAlgorithm.csproj --diagnostics RS0016 RS0017
195+
196+
- name: 'Guard against accidental shipped API removal'
187197
shell: bash
188-
run: dotnet format analyzers src/PolylineAlgorithm/PolylineAlgorithm.csproj --diagnostics RS0016
198+
run: |
199+
SHIPPED="src/PolylineAlgorithm/PublicAPI.Shipped.txt"
200+
if ! diff -q "$SHIPPED" "$SHIPPED.bak" > /dev/null 2>&1; then
201+
echo "::error::Breaking change detected — a shipped API was removed from PublicAPI.Shipped.txt."
202+
echo "::error::This requires a major version bump. Reverting the unintended change."
203+
cp "$SHIPPED.bak" "$SHIPPED"
204+
exit 1
205+
fi
206+
rm -f "$SHIPPED.bak"
189207
190208
- name: 'Configure git identity'
191209
uses: './.github/actions/git/configure-identity'
@@ -195,7 +213,7 @@ jobs:
195213
run: |
196214
git add src/PolylineAlgorithm/PublicAPI.Unshipped.txt
197215
git diff --staged --quiet || (
198-
git commit -m "Update PublicAPI.Unshipped.txt with new API declarations" &&
216+
git commit -m "Sync PublicAPI.Unshipped.txt (add new, remove dropped preview APIs)" &&
199217
git pull --rebase origin ${{ github.ref_name }} &&
200218
git push
201219
)

0 commit comments

Comments
 (0)