Skip to content

Commit 03ec431

Browse files
[CNSL-1935] Add automated release PR workflow
Add GitHub Actions workflow that automatically creates release PRs when pending-deploy-* branches are merged to main. The workflow updates go.mod for major version changes, updates config.yaml with the new version, and regenerates the OpenAPI client to automatically update all generated files (README.md, docs/README.md, pkg/client/configuration.go). Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
1 parent 7777b8d commit 03ec431

4 files changed

Lines changed: 106 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Create Release PR
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
create-release-pr:
16+
# Run on merged PRs with pending-deploy- prefix, or manual workflow_dispatch
17+
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'pending-deploy-'))
18+
uses: cockroachdb/actions/.github/workflows/create-release-pr.yml@v0
19+
with:
20+
fork_owner: crl-console-bot
21+
fork_repo: cockroach-cloud-sdk-go
22+
build_script: scripts/update_version.sh
23+
files_to_commit: |
24+
go.mod
25+
internal/spec/config.yaml
26+
README.md
27+
docs/README.md
28+
pkg/client/configuration.go
29+
secrets:
30+
fork_push_token: ${{ secrets.FORK_PUSH_TOKEN }}
31+
pr_create_token: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Automated release workflow that creates release PRs when `pending-deploy-*`
13+
branches are merged to main, updating the version number in all relevant files
14+
1015
## [7.1.0] - 2026-04-14
1116

1217
### Added

scripts/lib/logging.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
# Logging functions for GitHub Actions workflows
3+
4+
# Output an informational message to stderr
5+
log_info() {
6+
local message="$1"
7+
echo "$message" >&2
8+
}
9+
10+
# Output an error message using GitHub Actions workflow command format
11+
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message
12+
log_error() {
13+
local message="$1"
14+
echo "::error::$message" >&2
15+
}
16+
17+
# Output a warning message using GitHub Actions workflow command format
18+
log_warning() {
19+
local message="$1"
20+
echo "::warning::$message" >&2
21+
}
22+
23+
# Output a notice message using GitHub Actions workflow command format
24+
log_notice() {
25+
local message="$1"
26+
echo "::notice::$message" >&2
27+
}

scripts/update_version.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# This script is called by the reusable workflow after CHANGELOG.md has been updated.
6+
# The VERSION environment variable is set by the reusable workflow.
7+
# This script should only update version numbers in files other than CHANGELOG.md.
8+
9+
# Get the script directory
10+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11+
12+
# Source logging helper
13+
source "$SCRIPT_DIR/lib/logging.sh"
14+
15+
# Check if VERSION environment variable is set
16+
if [ -z "$VERSION" ]; then
17+
log_error "VERSION environment variable must be set"
18+
log_error "This script is intended to be called by the create-release-pr workflow"
19+
exit 1
20+
fi
21+
22+
log_info "Updating version to $VERSION in config and documentation files..."
23+
24+
# Extract major version from VERSION (e.g., 7.0.0 -> 7)
25+
MAJOR_VERSION=$(echo "$VERSION" | cut -d. -f1)
26+
27+
# Update go.mod module path to match major version
28+
log_info "Updating go.mod..."
29+
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
30+
31+
# Update internal/spec/config.yaml
32+
log_info "Updating internal/spec/config.yaml..."
33+
sed "s/^packageVersion:.*/packageVersion: $VERSION/" internal/spec/config.yaml > internal/spec/config.yaml.tmp && mv internal/spec/config.yaml.tmp internal/spec/config.yaml
34+
35+
# Generate OpenAPI client to update README files
36+
log_info "Generating OpenAPI client..."
37+
make generate-openapi-client
38+
39+
log_info "Version updated to $VERSION"
40+
41+
# Validate the updated code
42+
log_info "Running validation..."
43+
make validate

0 commit comments

Comments
 (0)