From 29450c9ae45a079dd56e9af470fd605cba9ebb7b Mon Sep 17 00:00:00 2001 From: Juan Fernandez Date: Mon, 27 Apr 2026 16:00:58 +0200 Subject: [PATCH] Follow datadog-ci semver for action releases --- RELEASE.md | 10 ++++- scripts/release-datadog-ci-bump.sh | 64 ++++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index ac922e5..9ca73bb 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,6 +1,6 @@ # Release Process -This repository ships a composite GitHub Action. Releases are Git tags: immutable semver tags such as `v3.0.1`, plus a moving major tag such as `v3`. +This repository ships a composite GitHub Action. Releases are Git tags: immutable semver tags such as `v3.1.0`, plus a moving major tag such as `v3`. ## Bump datadog-ci @@ -28,7 +28,13 @@ After a `datadog-ci-version-bump` PR is merged, run: scripts/release-datadog-ci-bump.sh ``` -The script fetches `main` and tags, finds the latest merged PR with the `datadog-ci-version-bump` label that is on `main` but not included in the latest immutable action tag, and releases that merge commit. A release creates the next patch tag, updates the moving major tag, and creates a GitHub Release. +The script fetches `main` and tags, finds the latest merged PR with the `datadog-ci-version-bump` label that is on `main` but not included in the latest immutable action tag, and releases that merge commit. The action version follows the `datadog-ci` change: + +- floating `v5` to the first pinned `v5.x.y`: action minor bump +- `datadog-ci` minor bump: action minor bump +- `datadog-ci` patch bump: action patch bump + +The release creates the next immutable action tag, updates the moving major tag, and creates a GitHub Release. Preview the release without creating tags or a GitHub Release: diff --git a/scripts/release-datadog-ci-bump.sh b/scripts/release-datadog-ci-bump.sh index e384431..6eb434b 100755 --- a/scripts/release-datadog-ci-bump.sh +++ b/scripts/release-datadog-ci-bump.sh @@ -6,9 +6,10 @@ usage() { Usage: scripts/release-datadog-ci-bump.sh [--dry-run] [--pr NUMBER | --sha COMMIT] Finds the latest merged datadog-ci bump PR on main that is not included in the -latest immutable action release tag. When one exists, creates the next patch -action tag, updates the moving major tag, and creates a GitHub Release. If older -unreleased bump PRs exist, the script warns and releases only the latest change. +latest immutable action release tag. When one exists, creates the next action +minor or patch tag, updates the moving major tag, and creates a GitHub Release. +If older unreleased bump PRs exist, the script warns and releases only the latest +change. Options: --dry-run Print the release that would be created. @@ -193,9 +194,52 @@ else release_source="$release_sha" fi +extract_datadog_ci_version() { + local ref="$1" + + git show "$ref:action.yaml" | ruby -ryaml -e 'puts YAML.load($stdin.read).fetch("inputs").fetch("datadog-ci-version").fetch("default")' +} + +is_exact_datadog_ci_version() { + [[ "$1" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] +} + +semver_parts() { + local version="${1#v}" + IFS=. read -r semver_major semver_minor semver_patch <<< "$version" + echo "$semver_major $semver_minor $semver_patch" +} + +latest_datadog_ci_version=$(extract_datadog_ci_version "$latest_tag") +release_datadog_ci_version=$(extract_datadog_ci_version "$release_sha") + +if ! is_exact_datadog_ci_version "$release_datadog_ci_version"; then + echo "Expected datadog-ci-version default to be an exact release tag at $release_sha, got '$release_datadog_ci_version'" >&2 + exit 1 +fi + +action_bump_kind="minor" +if is_exact_datadog_ci_version "$latest_datadog_ci_version"; then + read -r latest_dd_major latest_dd_minor latest_dd_patch <<< "$(semver_parts "$latest_datadog_ci_version")" + read -r release_dd_major release_dd_minor release_dd_patch <<< "$(semver_parts "$release_datadog_ci_version")" + + if (( release_dd_major == latest_dd_major && release_dd_minor == latest_dd_minor && release_dd_patch > latest_dd_patch )); then + action_bump_kind="patch" + elif (( release_dd_major > latest_dd_major || (release_dd_major == latest_dd_major && release_dd_minor > latest_dd_minor) )); then + action_bump_kind="minor" + else + echo "Expected datadog-ci-version at $release_sha ('$release_datadog_ci_version') to be newer than the latest released default ('$latest_datadog_ci_version')." >&2 + exit 1 + fi +fi + version="${latest_tag#v}" IFS=. read -r major minor patch <<< "$version" -next_tag="v${major}.${minor}.$((patch + 1))" +if [[ "$action_bump_kind" == "minor" ]]; then + next_tag="v${major}.$((minor + 1)).0" +else + next_tag="v${major}.${minor}.$((patch + 1))" +fi major_tag="v${major}" if git rev-parse --verify --quiet "refs/tags/$next_tag" >/dev/null; then @@ -208,16 +252,10 @@ if gh release view "$next_tag" --repo "$repo" >/dev/null 2>&1; then exit 1 fi -datadog_ci_version=$(git show "$release_sha:action.yaml" | ruby -ryaml -e 'puts YAML.load($stdin.read).fetch("inputs").fetch("datadog-ci-version").fetch("default")') -if [[ ! "$datadog_ci_version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Expected datadog-ci-version default to be an exact release tag at $release_sha, got '$datadog_ci_version'" >&2 - exit 1 -fi - notes_file=$(mktemp) trap 'rm -f "$notes_file"' EXIT cat > "$notes_file" <