Skip to content
Open
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
31 changes: 31 additions & 0 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -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 }}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions scripts/lib/logging.sh
Original file line number Diff line number Diff line change
@@ -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
}
Comment on lines +4 to +8
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's surprising to me that all these need to go to stderr. Is it because some script that's using it, needs stdout for communicating between processes?


# 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
}
43 changes: 43 additions & 0 deletions scripts/update_version.sh
Original file line number Diff line number Diff line change
@@ -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
Loading