Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/block_if_release.yml.off
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Block if there is an ongoing release
env:
RELEASE_BRANCH_PREFIX: release-v

on:
pull_request:
push:
branches:
- main
jobs:
ongoing-release:
runs-on: ubuntu-latest
permissions:
checks: read
contents: read
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
- name: Fail if release branch exists
run: |
if git ls-remote --heads origin | grep -q "refs/heads/${RELEASE_BRANCH_PREFIX}"; then
echo "A release branch with prefix '${RELEASE_BRANCH_PREFIX}' exists. Failing workflow."
exit 1
else
echo "No release branch found with prefix '${RELEASE_BRANCH_PREFIX}'. Continuing."
fi
65 changes: 65 additions & 0 deletions .github/workflows/block_if_release_rerun.yml.off
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Rerun block_if_release when creating or deleting a release branch
env:
RELEASE_BRANCH_PREFIX: release-v

on: [create, delete]

permissions:
actions: write
contents: read

jobs:
rerun-block-if-release:
runs-on: ubuntu-latest
steps:
- name: Check if ref is release branch
id: check_release_branch
run: |
echo "Event: name: ${{ github.event_name }}, ref: ${{ github.event.ref }}"
echo "Ref: ${{ github.ref }}"
echo "Ref type: ${{ github.event.ref_type }}" # branch or tag
if [[ "${{ github.event.ref_type }}" == "branch" && "${{ github.event.ref }}" == "${RELEASE_BRANCH_PREFIX}"* ]]; then
echo "is_release_branch=true" >> $GITHUB_OUTPUT
else
echo "is_release_branch=false" >> $GITHUB_OUTPUT
fi

- name: Trigger block_if_release on open PRs
id: trigger
if: steps.check_release_branch.outputs.is_release_branch == 'true'
uses: actions/github-script@v7
with:
script: |
// TODO: filter out inactive PRs checking last update (if possible)
const prs = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
});
for (const pr of prs.data) {
console.log('Checking PR: ', pr.url)

// Get workflow runs for the PR's branch
const runs = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
branch: pr.head.ref,
event: "pull_request"
});

// Find the latest run for the desired workflow
const run = runs.data.workflow_runs.find(
r => r.name === "Block if there is an ongoing release" || r.path.endsWith('block_if_release.yml')
);
if (run) {
console.log('Rerunning: ', run.id, run.html_url)

await github.rest.actions.reRunWorkflow({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run.id
});
} else {
console.log('There is no run')
}
}
167 changes: 167 additions & 0 deletions .github/workflows/cargo_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
name: Cargo checks
on:
pull_request:
push:
branches: [main]
jobs:
cargo-deny:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
- uses: EmbarkStudios/cargo-deny-action@f2ba7abc2abebaf185c833c3961145a3c275caad # 2.0.13
with:
command: check advisories bans sources # licenses

version-and-changelog:
runs-on: ubuntu-latest
strategy:
fail-fast: false
# max-parallel: 1
matrix:
# crate: [ddcommon, ddtelemetry, ddsketch, Library-config, Datadog-crashtracker, cc_utils, data-pipeline, datadog-trace-protobuf, datadog-trace-normalization, datadog-trace-utils, dogstatsd-client, tinybytes, datadog-log]
crate: [ddcommon]
env:
CRATE: ${{ matrix.crate }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
fetch-depth: 0
fetch-tags: true
- uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0

- uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
with:
shared-key: stable-cache
save-if: false

- uses: taiki-e/cache-cargo-install-action@v2
with:
tool: tomlq

- name: Extract version from manifest
run: |
CRATE_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -e -r '.packages[] | select(.name == "'"$CRATE"'") | .version')

echo "CRATE_VERSION=$CRATE_VERSION" >> $GITHUB_ENV

# this could be enabled when defining dependencies in Cargo.toml
# - name: Enforce version in `workspace.dependencies` matches the latest version
# run: |
# SPECIFIED_VERSION=$(tq "workspace.dependencies.$CRATE.version" -r --file ./Cargo.toml)

# echo "Package version: $CRATE_VERSION";
# echo "Specified version: $SPECIFIED_VERSION";

# test "$CRATE_VERSION" = "$SPECIFIED_VERSION" || test "=$CRATE_VERSION" = "$SPECIFIED_VERSION"

- name: Enforce version in CHANGELOG.md matches the version in manifest
run: |
MANIFEST_PATH=$(cargo metadata --format-version=1 --no-deps | jq -e -r '.packages[] | select(.name == "'"$CRATE"'") | .manifest_path')
DIR_TO_CRATE=$(dirname "$MANIFEST_PATH")
VERSION_IN_CHANGELOG=$(awk -F' ' '/^## [0-9]+\.[0-9]+\.[0-9]+/{print $2; exit}' "$DIR_TO_CRATE/CHANGELOG.md")

echo "Package version: $CRATE_VERSION";
echo "Changelog version: $VERSION_IN_CHANGELOG";

test "$CRATE_VERSION" = "$VERSION_IN_CHANGELOG"

- name: Ensure manifest and CHANGELOG are properly updated
if: >
github.event_name == 'pull_request' &&
!startsWith(github.event.pull_request.title, 'chore') &&
!startsWith(github.event.pull_request.title, 'refactor') &&
!startsWith(github.event.pull_request.title, 'deps') &&
!startsWith(github.event.pull_request.title, 'docs') &&
!contains(github.event.pull_request.labels.*.name, 'internal-change')
run: |
git fetch origin main:main
git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }}
./scripts/ensure-version-bump-and-changelog.sh
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_BASE: ${{ github.event.pull_request.base.ref }}


detect-changes:
runs-on: ubuntu-latest
outputs:
changed-packages: ${{ steps.detect.outputs.packages }}
has-changes: ${{ steps.detect.outputs.has-changes }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
fetch-depth: 0 # Need full history for cargo release changes

- name: Install cargo-release
uses: taiki-e/install-action@d6d752794628f1e1fffa3c4d3c8874e06f043d50 # 2.62.15
with:
tool: cargo-release

- id: detect
name: Detect changed packages and their baseline tags
run: |
# Get changed packages from cargo release changes
# Extract package names from lines like "Changes for {package} from"
packages_list=$(cargo release changes 2>&1 | grep "Changes for" | sed 's/.*Changes for \([^ ]*\) from.*/\1/' | sort -u)

if [ -z "$packages_list" ]; then
echo "has-changes=false" >> $GITHUB_OUTPUT
echo "packages=[]" >> $GITHUB_OUTPUT
echo "No changed packages detected"
else
echo "has-changes=true" >> $GITHUB_OUTPUT

# Build JSON array with package and baseline-rev for each package
packages_json="[]"
while IFS= read -r pkg; do
[ -z "$pkg" ] && continue

# Find the latest tag for this package (format: {package}-v{version})
latest_tag=$(git tag -l "${pkg}-v*" --sort=-version:refname | head -n 1)

if [ -z "$latest_tag" ]; then
echo "Warning: No tag found for package $pkg, skipping baseline"
baseline=""
else
baseline="$latest_tag"
echo "Package $pkg -> baseline $baseline"
fi

# Add to JSON array with compact output (-c flag)
packages_json=$(echo "$packages_json" | jq -c --arg pkg "$pkg" --arg baseline "$baseline" '. += [{"package": $pkg, "baseline-rev": $baseline}]')
done <<< "$packages_list"

# Output as compact JSON (ensure no newlines)
echo "packages=$(echo "$packages_json" | jq -c .)" >> $GITHUB_OUTPUT
echo "Changed packages with baselines: $packages_json"
fi

semver:
needs: detect-changes
if: needs.detect-changes.outputs.has-changes == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.detect-changes.outputs.changed-packages) }}
env:
# Unset the global `RUSTFLAGS` env to allow warnings.
# cargo-semver-checks intentionally re-locks dependency versions
# before checking, and we shouldn't fail here if a dep has a warning.
#
# More context:
# https://github.com/libp2p/rust-libp2p/pull/4932#issuecomment-1829014527
# https://github.com/obi1kenobi/cargo-semver-checks/issues/589
RUSTFLAGS: ''
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
fetch-depth: 0
fetch-tags: true
- uses: obi1kenobi/cargo-semver-checks-action@5b298c9520f7096a4683c0bd981a7ac5a7e249ae # v2.8
with:
package: ${{ matrix.package }}
baseline-rev: ${{ matrix.baseline-rev }}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
63 changes: 63 additions & 0 deletions .github/workflows/release-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release - Open a release PR
on:
workflow_dispatch:
inputs:
crate:
description: Crate to release
required: true
type: choice
options:
- libdd-common
- libdd-telemetry
- libdd-ddsketch
- libdd-library-config
- libdd-crashtracker
- libdd-data-pipeline
- libdd-trace-protobuf
- libdd-trace-normalization
- libdd-trace-utils
- libdd-dogstatsd-client
- libdd-tinybytes
- libdd-log
version:
description: Version to release
required: true
type: string

jobs:
make-release-pr:
permissions:
id-token: write # Enable OIDC
pull-requests: write
contents: write
runs-on: ubuntu-latest
steps:
- name: Display release information
run: |
echo "### Release Information :rocket:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Crate:** \`${{ inputs.crate }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Version:** \`${{ inputs.version }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Creating release PR..." >> $GITHUB_STEP_SUMMARY

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
- uses: chainguard-dev/actions/setup-gitsign@0cda751b114eb55c388e88f7479292668165602a # v1.0.2
- name: Install cargo-release
uses: taiki-e/install-action@d6d752794628f1e1fffa3c4d3c8874e06f043d50 # 2.62.15
with:
tool: cargo-release

- name: Extract release notes
id: extract-release-notes
run: |
notes=$(./scripts/extract_changelog_vnext.sh ${{ inputs.crate }}/CHANGELOG.md)
echo "release-notes=$notes" >> $GITHUB_OUTPUT

# TODO: add release notes to the PR description ${{ steps.extract-release-notes.outputs.release-notes }}
- uses: cargo-bins/release-pr@0c019c0e5a6b9f722578d231d43ba900cacc5ffa # 2.1.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ inputs.version }}
crate-name: ${{ inputs.crate }}
# check-semver: "true"
Loading
Loading