|
8 | 8 | branches: |
9 | 9 | - release/** |
10 | 10 | - release-testing/** |
| 11 | + |
| 12 | +env: |
| 13 | + # dd-trace-rs tags to test the proposal against are resolved at run time: the newest tag of each |
| 14 | + # of the DD_TRACE_RS_LINES most recent release lines matching DD_TRACE_RS_TAG_PREFIX. |
| 15 | + DD_TRACE_RS_REPO: https://github.com/DataDog/dd-trace-rs |
| 16 | + DD_TRACE_RS_TAG_PREFIX: datadog-opentelemetry-v |
| 17 | + DD_TRACE_RS_LINES: 3 |
| 18 | + |
11 | 19 | jobs: |
12 | 20 | package-and-upload-crates: |
13 | 21 | permissions: |
14 | 22 | id-token: write # Enable OIDC |
15 | 23 | runs-on: ubuntu-latest |
16 | 24 | outputs: |
17 | 25 | upload_artifact: ${{ steps.package-crates.outputs.upload_artifact }} |
| 26 | + dd_trace_rs_versions: ${{ steps.dd-trace-rs-versions.outputs.versions }} |
18 | 27 | steps: |
19 | 28 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 |
20 | 29 | with: |
|
78 | 87 | cargo +1.92.0 package "${PKG_ARGS[@]}" --all-features |
79 | 88 | echo "upload_artifact=true" >> "$GITHUB_OUTPUT" |
80 | 89 |
|
| 90 | + # Resolve the dd-trace-rs versions to compile against instead of hardcoding a matrix that |
| 91 | + # goes stale. A "release line" is the SemVer-breaking component: MAJOR from 1.0.0 on, and |
| 92 | + # MAJOR.MINOR while MAJOR is 0 (a 0.x minor bump is breaking). We take the newest patch of |
| 93 | + # each of the DD_TRACE_RS_LINES most recent lines, newest line first. |
| 94 | + # Runs unconditionally (even when nothing was packaged) so the matrix expression downstream |
| 95 | + # never sees an empty string. |
| 96 | + - name: Resolve dd-trace-rs versions to test against |
| 97 | + id: dd-trace-rs-versions |
| 98 | + run: | |
| 99 | + set -euo pipefail |
| 100 | + PREFIX="${DD_TRACE_RS_TAG_PREFIX}" |
| 101 | +
|
| 102 | + # --refs drops the peeled `^{}` entries annotated tags produce. Pre-release tags |
| 103 | + # (e.g. -alpha.1) are filtered out; the prefix is matched literally (index/substr, |
| 104 | + # not a regex) so a prefix with regex metacharacters would still work. |
| 105 | + VERSIONS=$(git ls-remote --tags --refs "$DD_TRACE_RS_REPO" "refs/tags/${PREFIX}*" \ |
| 106 | + | awk -v ref_prefix="refs/tags/${PREFIX}" ' |
| 107 | + index($2, ref_prefix) == 1 { |
| 108 | + v = substr($2, length(ref_prefix) + 1) |
| 109 | + if (v ~ /^[0-9]+\.[0-9]+\.[0-9]+$/) print v |
| 110 | + }' \ |
| 111 | + | sort -V) |
| 112 | +
|
| 113 | + if [ -z "$VERSIONS" ]; then |
| 114 | + echo "Error: no '${PREFIX}MAJOR.MINOR.PATCH' tags found in $DD_TRACE_RS_REPO." >&2 |
| 115 | + exit 1 |
| 116 | + fi |
| 117 | +
|
| 118 | + # Newest version of each release line. Input is ascending, so the last write per key wins. |
| 119 | + declare -A LATEST_BY_LINE=() |
| 120 | + while read -r version; do |
| 121 | + IFS='.' read -r major minor _patch <<< "$version" |
| 122 | + if [ "$major" = "0" ]; then |
| 123 | + LATEST_BY_LINE["0.$minor"]="$version" |
| 124 | + else |
| 125 | + LATEST_BY_LINE["$major"]="$version" |
| 126 | + fi |
| 127 | + done <<< "$VERSIONS" |
| 128 | +
|
| 129 | + TAGS=() |
| 130 | + while read -r line; do |
| 131 | + TAGS+=("${PREFIX}${LATEST_BY_LINE[$line]}") |
| 132 | + done < <(printf '%s\n' "${!LATEST_BY_LINE[@]}" | sort -Vr | head -n "$DD_TRACE_RS_LINES") |
| 133 | +
|
| 134 | + MATRIX=$(printf '%s\n' "${TAGS[@]}" | jq -R . | jq -c -s .) |
| 135 | + echo "dd-trace-rs versions to test against: $MATRIX" |
| 136 | + echo "versions=$MATRIX" >> "$GITHUB_OUTPUT" |
| 137 | +
|
81 | 138 | - name: Upload crates |
82 | 139 | if: steps.package-crates.outputs.upload_artifact == 'true' |
83 | 140 | uses: actions/upload-artifact@v4 |
|
95 | 152 | if: needs.package-and-upload-crates.outputs.upload_artifact == 'true' |
96 | 153 | strategy: |
97 | 154 | matrix: |
98 | | - version: ["datadog-opentelemetry-v0.4.0", "datadog-opentelemetry-v0.3.3", "datadog-opentelemetry-v0.3.2"] |
| 155 | + version: ${{ fromJSON(needs.package-and-upload-crates.outputs.dd_trace_rs_versions) }} |
99 | 156 | steps: |
100 | 157 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 |
101 | 158 | with: |
|
0 commit comments