@@ -13,21 +13,63 @@ jobs:
1313 permissions :
1414 id-token : write # Enable OIDC
1515 runs-on : ubuntu-latest
16+ outputs :
17+ upload_artifact : ${{ steps.package-crates.outputs.upload_artifact }}
1618 steps :
1719 - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
1820 with :
1921 fetch-depth : 0
22+ # Checkout PR head (not the synthetic merge commit) so version comparison matches the proposal branch.
23+ ref : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
2024 - uses : dtolnay/rust-toolchain@stable
2125 with :
2226 toolchain : 1.92.0
2327
24- - name : Package the workspace
28+ # origin/main is needed for merge-base on push; PR base SHA must be fetched for git show.
29+ - name : Fetch refs for version comparison
2530 run : |
26- cargo package --workspace --exclude "libdd-*-ffi" --exclude libdd-crashtracker --exclude libdd-libunwind-sys --exclude "datadog-*" \
27- --exclude bin_tests --exclude "tools" --exclude "sidecar_mockgen" --exclude "cc_utils" --exclude spawn_worker --exclude symbolizer-ffi \
28- --exclude test_spawn_from_lib --exclude build-common --exclude builder --all-features
31+ git fetch origin main
32+ if [ "${{ github.event_name }}" = "pull_request" ]; then
33+ git fetch --no-tags origin "${{ github.event.pull_request.base.sha }}"
34+ fi
35+
36+ # Compare [package] versions between PR base and head (or merge-base(main,HEAD) vs push on direct push).
37+ # Dependency-only manifest edits are ignored; excludes match the old cargo package --exclude list.
38+ - name : Package crates with version bumps vs comparison base
39+ id : package-crates
40+ run : |
41+ set -euo pipefail
42+ if [ "${{ github.event_name }}" = "pull_request" ]; then
43+ GIT_VERSION_BASE="${{ github.event.pull_request.base.sha }}"
44+ export GIT_VERSION_BASE
45+ GIT_VERSION_HEAD="${{ github.event.pull_request.head.sha }}"
46+ export GIT_VERSION_HEAD
47+ else
48+ # Direct push: compare from fork point with main, not origin/main's current tip (main may have advanced).
49+ GIT_VERSION_BASE="$(git merge-base origin/main HEAD)"
50+ export GIT_VERSION_BASE
51+ GIT_VERSION_HEAD="${GITHUB_SHA}"
52+ export GIT_VERSION_HEAD
53+ fi
54+
55+ echo "Comparing Cargo.toml package versions: GIT_VERSION_BASE=${GIT_VERSION_BASE} GIT_VERSION_HEAD=${GIT_VERSION_HEAD}"
56+ mapfile -t PACKAGES < <(./scripts/crates-to-package.sh)
57+ echo "Packages to run cargo package on (version bump only):"
58+ printf '%s\n' "${PACKAGES[@]}"
59+ PKG_ARGS=()
60+ for p in "${PACKAGES[@]}"; do
61+ PKG_ARGS+=(-p "$p")
62+ done
63+ if [ "${#PKG_ARGS[@]}" -eq 0 ]; then
64+ echo "upload_artifact=false" >> "$GITHUB_OUTPUT"
65+ echo "Skipping cargo package: no crates had a version bump vs the base ref (PKG_ARGS is empty)."
66+ exit 0
67+ fi
68+ cargo package "${PKG_ARGS[@]}" --all-features
69+ echo "upload_artifact=true" >> "$GITHUB_OUTPUT"
2970
3071 - name : Upload crates
72+ if : steps.package-crates.outputs.upload_artifact == 'true'
3173 uses : actions/upload-artifact@v4
3274 with :
3375 name : release-proposal-test-crates
4082 id-token : write # Enable OIDC
4183 runs-on : ubuntu-latest
4284 needs : package-and-upload-crates
85+ if : needs.package-and-upload-crates.outputs.upload_artifact == 'true'
4386 strategy :
4487 matrix :
4588 version : ["datadog-opentelemetry-v0.3.2", "datadog-opentelemetry-v0.3.1"]
0 commit comments