Skip to content

Commit 5ec108f

Browse files
[CNSL-1935] Add automated release PR workflow
Added GitHub Actions workflow that automatically creates release PRs when pending-deploy-* branches are merged to main. The workflow uses the reusable workflow from cockroachdb/actions and updates the version number in CHANGELOG.md, go.mod, config files, and documentation. Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
1 parent 7777b8d commit 5ec108f

5 files changed

Lines changed: 120 additions & 1 deletion

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

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ generate-openapi-client: bin/goimports
1616
-c internal/spec/config.yaml
1717
mv internal/openapi-generator/docs ./
1818
mv internal/openapi-generator/*.md ./docs/
19-
cp ./docs/README.md ./
19+
@$(MAKE) sync-readme
2020
bin/goimports -w ./internal/openapi-generator/
2121
go fmt ./internal/openapi-generator/...
2222
mv ./internal/openapi-generator/*.go pkg/client/
2323
@$(MAKE) add-boilerplate
2424

25+
# Copy docs/README.md to root README.md
26+
.PHONY: sync-readme
27+
sync-readme:
28+
cp ./docs/README.md ./
29+
2530
bin/goimports:
2631
@TOOLPKG=github.com/cockroachdb/gostdlib/x/tools/cmd/goimports@v1.19.0 $(MAKE) build-tool
2732

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: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
# Update docs/README.md
36+
log_info "Updating docs/README.md..."
37+
sed "s/^- Package version:.*/- Package version: $VERSION/" docs/README.md > docs/README.md.tmp && mv docs/README.md.tmp docs/README.md
38+
39+
# Copy docs/README.md to root (same as generated client does)
40+
log_info "Syncing root README.md from docs/README.md..."
41+
make sync-readme
42+
43+
# Update pkg/client/configuration.go UserAgent
44+
log_info "Updating pkg/client/configuration.go..."
45+
sed "s/UserAgent: \"ccloud-sdk-go\/[^\"]*\"/UserAgent: \"ccloud-sdk-go\/$VERSION\"/" pkg/client/configuration.go > pkg/client/configuration.go.tmp && mv pkg/client/configuration.go.tmp pkg/client/configuration.go
46+
47+
log_info "Version updated to $VERSION"
48+
49+
# Validate the updated code
50+
log_info "Running validation..."
51+
make validate

0 commit comments

Comments
 (0)