-
Notifications
You must be signed in to change notification settings - Fork 21
ci(release): accept multiple crates in release-proposal-dispatch #2012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
iunanua
wants to merge
6
commits into
main
Choose a base branch
from
igor/versioning/multi-crate-proposal
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+111
−40
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ed7a32c
ci(release): accept multiple crates in release-proposal-dispatch
iunanua 2a73717
ci(release): satisfy shellcheck in validate-inputs and create-pr
iunanua 4c06362
change branch name for multi crates
iunanua 50a0f93
Merge branch 'main' into igor/versioning/multi-crate-proposal
iunanua 53dcc42
Merge branch 'main' into igor/versioning/multi-crate-proposal
iunanua 7081fea
ci(release): propagate cargo metadata failures and dedupe hotfix regex
iunanua File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,35 +2,14 @@ name: Release - Open a release proposal PR | |
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| crate: | ||
| description: Crate to release | ||
| crates: | ||
| description: > | ||
| Crate(s) to release. Names separated by commas or whitespace (e.g. "libdd-common" or "libdd-common, libdd-telemetry"). | ||
| Each selected crate is released along with its workspace dependencies (other libdd-* crates it depends on). | ||
| Hotfix releases (main_start_ref matching hotfix/<crate>/<N>.x.x) accept a single crate only. | ||
| required: true | ||
| type: choice | ||
| options: | ||
| - libdd-alloc | ||
| - libdd-capabilities | ||
| - libdd-capabilities-impl | ||
| - libdd-common | ||
| - libdd-crashtracker | ||
| - libdd-data-pipeline | ||
| - libdd-ddsketch | ||
| - libdd-dogstatsd-client | ||
| - libdd-http-client | ||
| - libdd-library-config | ||
| - libdd-log | ||
| - libdd-otel-thread-ctx | ||
| - libdd-profiling | ||
| - libdd-profiling-protobuf | ||
| - libdd-sampling | ||
| - libdd-shared-runtime | ||
| - libdd-telemetry | ||
| - libdd-tinybytes | ||
| - libdd-trace-normalization | ||
| - libdd-trace-obfuscation | ||
| - libdd-trace-protobuf | ||
| - libdd-trace-stats | ||
| - libdd-trace-utils | ||
| - libdd-tracer-flare | ||
| type: string | ||
| default: '' | ||
| main_start_ref: | ||
| description: > | ||
| Optional git ref to cut the release from: commit SHA (short or full), branch name, | ||
|
|
@@ -58,8 +37,90 @@ env: | |
| HOTFIX_REF_PATTERN: '^hotfix/[^/]+/[0-9]+\.x\.x$' | ||
|
|
||
| jobs: | ||
| validate-inputs: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| crates: ${{ steps.normalize.outputs.crates }} | ||
| crates_display: ${{ steps.normalize.outputs.crates_display }} | ||
| crates_branch: ${{ steps.normalize.outputs.crates_branch }} | ||
| count: ${{ steps.normalize.outputs.count }} | ||
| steps: | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 | ||
| - name: Normalize and validate crate list | ||
| id: normalize | ||
| env: | ||
| RAW_CRATES: ${{ inputs.crates }} | ||
| RAW_MAIN_START_REF: ${{ inputs.main_start_ref }} | ||
| HOTFIX_REF_PATTERN: ${{ env.HOTFIX_REF_PATTERN }} | ||
| run: | | ||
| set -euo pipefail | ||
| # Split on commas/whitespace, drop empties, dedupe, sort for stable downstream order. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this support trailing commas? |
||
| # Use command substitution (not process substitution) so set -e/pipefail catches failures. | ||
| NORMALIZED=$(printf '%s\n' "$RAW_CRATES" | tr ',' ' ' | tr -s '[:space:]' '\n' | sed '/^$/d' | sort -u) | ||
| mapfile -t CRATES <<< "$NORMALIZED" | ||
| # An empty NORMALIZED produces a single empty-string element via <<<; drop it. | ||
| if [ "${#CRATES[@]}" -eq 1 ] && [ -z "${CRATES[0]}" ]; then | ||
| CRATES=() | ||
| fi | ||
| if [ "${#CRATES[@]}" -eq 0 ]; then | ||
| echo "Error: 'crates' input is empty after normalization." >&2 | ||
| exit 1 | ||
| fi | ||
| METADATA=$(cargo metadata --no-deps --format-version=1) | ||
| AVAILABLE_LIST=$(jq -r ' | ||
| .packages[] | ||
| | select(.publish == null or (.publish | type == "array" and length > 0)) | ||
| | .name | ||
| ' <<< "$METADATA" | sort -u) | ||
| mapfile -t AVAILABLE <<< "$AVAILABLE_LIST" | ||
| UNKNOWN=() | ||
| for c in "${CRATES[@]}"; do | ||
| if ! printf '%s\n' "${AVAILABLE[@]}" | grep -qxF "$c"; then | ||
| UNKNOWN+=("$c") | ||
| fi | ||
| done | ||
| if [ "${#UNKNOWN[@]}" -gt 0 ]; then | ||
| echo "Error: unknown or unpublishable crate(s): ${UNKNOWN[*]}" >&2 | ||
| echo "Available crates:" >&2 | ||
| printf ' - %s\n' "${AVAILABLE[@]}" >&2 | ||
| exit 1 | ||
| fi | ||
| REF="$(echo "$RAW_MAIN_START_REF" | tr -d '[:space:]')" | ||
| if [[ -n "$REF" && "$REF" =~ $HOTFIX_REF_PATTERN ]] && [ "${#CRATES[@]}" -gt 1 ]; then | ||
| echo "Error: hotfix releases (main_start_ref=$REF) accept only a single crate; got ${#CRATES[@]}: ${CRATES[*]}" >&2 | ||
| exit 1 | ||
| fi | ||
| CRATES_SPACE="${CRATES[*]}" | ||
| CRATES_DISPLAY=$(IFS=,; echo "${CRATES[*]}") | ||
| CRATES_DISPLAY=${CRATES_DISPLAY//,/, } | ||
| # Branch segment: keep the path concise when many crates are bundled. | ||
| if [ "${#CRATES[@]}" -eq 1 ]; then | ||
| CRATES_BRANCH="${CRATES[0]}" | ||
| else | ||
| CRATES_BRANCH="${CRATES[0]}-$(( ${#CRATES[@]} - 1 ))-more" | ||
| fi | ||
| echo "Normalized crates: $CRATES_SPACE" | ||
| echo "Display: $CRATES_DISPLAY" | ||
| echo "Branch segment: $CRATES_BRANCH" | ||
| echo "Count: ${#CRATES[@]}" | ||
| { | ||
| echo "crates=$CRATES_SPACE" | ||
| echo "crates_display=$CRATES_DISPLAY" | ||
| echo "crates_branch=$CRATES_BRANCH" | ||
| echo "count=${#CRATES[@]}" | ||
| } >> "$GITHUB_OUTPUT" | ||
| check-proposal-ongoing: | ||
| runs-on: ubuntu-latest | ||
| needs: validate-inputs | ||
| steps: | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 | ||
| with: | ||
|
|
@@ -115,7 +176,7 @@ jobs: | |
| id-token: write # Enable OIDC | ||
| pull-requests: write | ||
| contents: write | ||
| needs: check-membership | ||
| needs: [check-membership, validate-inputs] | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| RUSTUP_TOOLCHAIN: 1.92.0 | ||
|
|
@@ -330,7 +391,7 @@ jobs: | |
| echo "ephemeral_branch=$EPHEMERAL_BRANCH" >> "$GITHUB_OUTPUT" | ||
| echo "is_hotfix=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| EPHEMERAL_BRANCH="${{ env.RELEASE_BRANCH_PREFIX }}/${{ inputs.crate }}/$TIMESTAMP" | ||
| EPHEMERAL_BRANCH="${{ env.RELEASE_BRANCH_PREFIX }}/${{ needs.validate-inputs.outputs.crates_branch }}/$TIMESTAMP" | ||
| git checkout -b "$EPHEMERAL_BRANCH" | ||
| git push origin "$EPHEMERAL_BRANCH" | ||
| echo "Ephemeral release branch created: $EPHEMERAL_BRANCH branch ($(git rev-parse --short HEAD))" | ||
|
|
@@ -340,11 +401,14 @@ jobs: | |
| echo "timestamp=$TIMESTAMP" >> "$GITHUB_OUTPUT" | ||
| - name: Get publication order for crate and dependencies | ||
| env: | ||
| CRATES: ${{ needs.validate-inputs.outputs.crates }} | ||
| run: | | ||
| echo "Getting publication order for ${{ inputs.crate }}..." | ||
| # Get the publication order as JSON and save to file | ||
| "${WORKFLOW_SCRIPTS_ROOT}/publication-order.sh" --format=json "${{ inputs.crate }}" > /tmp/crates.json | ||
| echo "Getting publication order for ${{ needs.validate-inputs.outputs.crates_display }}..." | ||
| # CRATES is a space-separated list validated upstream; word-splitting is intentional. | ||
| # shellcheck disable=SC2086 | ||
| "${WORKFLOW_SCRIPTS_ROOT}/publication-order.sh" --format=json $CRATES > /tmp/crates.json | ||
| echo "Publication order:" | ||
| cat /tmp/crates.json | ||
|
|
@@ -379,7 +443,7 @@ jobs: | |
| git checkout "${{ steps.ephemeral-branch.outputs.ephemeral_branch }}" | ||
| TIMESTAMP="${{ steps.ephemeral-branch.outputs.timestamp }}" | ||
| BRANCH_NAME="${{ env.PROPOSAL_BRANCH_PREFIX }}/${{ inputs.crate }}/$TIMESTAMP" | ||
| BRANCH_NAME="${{ env.PROPOSAL_BRANCH_PREFIX }}/${{ needs.validate-inputs.outputs.crates_branch }}/$TIMESTAMP" | ||
| git checkout -b "$BRANCH_NAME" | ||
| git push origin "$BRANCH_NAME" --tags | ||
| echo "Branch created: $BRANCH_NAME from ${{ steps.ephemeral-branch.outputs.ephemeral_branch }} branch" | ||
|
|
@@ -741,7 +805,7 @@ jobs: | |
| is_hotfix: ${{ steps.ephemeral-branch.outputs.is_hotfix }} | ||
|
|
||
| create-pr: | ||
| needs: cargo-release | ||
| needs: [cargo-release, validate-inputs] | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write # Enable OIDC | ||
|
|
@@ -772,6 +836,7 @@ jobs: | |
| BYPASS_STANDARD_CHECKS: ${{ inputs.bypass_standard_checks }} | ||
| PROPOSAL_BRANCH_PREFIX: ${{ env.PROPOSAL_BRANCH_PREFIX }} | ||
| RELEASE_BRANCH_PREFIX: ${{ env.RELEASE_BRANCH_PREFIX }} | ||
| CRATES_COUNT: ${{ needs.validate-inputs.outputs.count }} | ||
| run: | | ||
| BRANCH_NAME="${{ needs.cargo-release.outputs.branch_name }}" | ||
| EPHEMERAL_BRANCH="${{ needs.cargo-release.outputs.ephemeral_branch }}" | ||
|
|
@@ -820,19 +885,25 @@ jobs: | |
| COMMITS_AND_API_BODY=$(jq -nr --slurpfile api /tmp/api-changes-with-major-bumps.json "$JQ_FILTER") | ||
| PR_BODY="# Release proposal for ${{ inputs.crate }} and its dependencies | ||
| if [ "$CRATES_COUNT" -gt 1 ]; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😸 |
||
| POSSESSIVE="their" | ||
| else | ||
| POSSESSIVE="its" | ||
| fi | ||
| PR_BODY="# Release proposal for ${{ needs.validate-inputs.outputs.crates_display }} and $POSSESSIVE dependencies | ||
| This PR contains version bumps based on public API changes and commits since last release. | ||
| ${HOTFIX_NOTE}${NON_DEFAULT}${COMMITS_AND_API_BODY}" | ||
| echo "$PR_BODY" > /tmp/pr-body.md | ||
| echo "PR body written to /tmp/pr-body.md (length: $(wc -c < /tmp/pr-body.md) bytes)" | ||
| # NOTE: the PR title is used to filter gitlab CI jobs. If you change it, you need to update the gitlab CI job filter. | ||
| # NOTE: the PR title must start with 'chore(release): proposal for'. Downstream tooling matches on that prefix. | ||
| gh pr create \ | ||
| --head "$BRANCH_NAME" \ | ||
| --title "chore(release): proposal for ${{ inputs.crate }}" \ | ||
| --title "chore(release): proposal for ${{ needs.validate-inputs.outputs.crates_display }}" \ | ||
| --body-file /tmp/pr-body.md \ | ||
| --label "release-proposal" \ | ||
| --label "skip-metadata-check" \ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the interest of debuggability, I'd pick exactly one seperator