diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml new file mode 100644 index 0000000..006a417 --- /dev/null +++ b/.github/workflows/create-release-pr.yml @@ -0,0 +1,31 @@ +name: Create Release PR + +on: + pull_request: + types: [closed] + branches: + - main + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + create-release-pr: + # Run on merged PRs with pending-deploy- prefix, or manual workflow_dispatch + if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'pending-deploy-')) + uses: cockroachdb/actions/.github/workflows/create-release-pr.yml@v0 + with: + fork_owner: crl-console-bot + fork_repo: cockroach-cloud-sdk-go + build_script: scripts/update_version.sh + files_to_commit: | + go.mod + internal/spec/config.yaml + README.md + docs/README.md + pkg/client/configuration.go + secrets: + fork_push_token: ${{ secrets.FORK_PUSH_TOKEN }} + pr_create_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 83d84e8..970aa65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Automated release workflow that creates release PRs when `pending-deploy-*` + branches are merged to main, updating the version number in all relevant files + ## [7.1.0] - 2026-04-14 ### Added diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh new file mode 100755 index 0000000..8856734 --- /dev/null +++ b/scripts/lib/logging.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# Logging functions for GitHub Actions workflows + +# Output an informational message to stderr +log_info() { + local message="$1" + echo "$message" >&2 +} + +# Output an error message using GitHub Actions workflow command format +# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message +log_error() { + local message="$1" + echo "::error::$message" >&2 +} + +# Output a warning message using GitHub Actions workflow command format +log_warning() { + local message="$1" + echo "::warning::$message" >&2 +} + +# Output a notice message using GitHub Actions workflow command format +log_notice() { + local message="$1" + echo "::notice::$message" >&2 +} diff --git a/scripts/update_version.sh b/scripts/update_version.sh new file mode 100644 index 0000000..517328d --- /dev/null +++ b/scripts/update_version.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -e + +# This script is called by the reusable workflow after CHANGELOG.md has been updated. +# The VERSION environment variable is set by the reusable workflow. +# This script should only update version numbers in files other than CHANGELOG.md. + +# Get the script directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Source logging helper +source "$SCRIPT_DIR/lib/logging.sh" + +# Check if VERSION environment variable is set +if [ -z "$VERSION" ]; then + log_error "VERSION environment variable must be set" + log_error "This script is intended to be called by the create-release-pr workflow" + exit 1 +fi + +log_info "Updating version to $VERSION in config and documentation files..." + +# Extract major version from VERSION (e.g., 7.0.0 -> 7) +MAJOR_VERSION=$(echo "$VERSION" | cut -d. -f1) + +# Update go.mod module path to match major version +log_info "Updating go.mod..." +sed -E "s|(github.com/cockroachdb/cockroach-cloud-sdk-go)/v[0-9]+|\1/v${MAJOR_VERSION}|" go.mod > go.mod.tmp && mv go.mod.tmp go.mod + +# Update internal/spec/config.yaml +log_info "Updating internal/spec/config.yaml..." +sed "s/^packageVersion:.*/packageVersion: $VERSION/" internal/spec/config.yaml > internal/spec/config.yaml.tmp && mv internal/spec/config.yaml.tmp internal/spec/config.yaml + +# Generate OpenAPI client to update README files +log_info "Generating OpenAPI client..." +make generate-openapi-client + +log_info "Version updated to $VERSION" + +# Validate the updated code +log_info "Running validation..." +make validate \ No newline at end of file