-
Notifications
You must be signed in to change notification settings - Fork 7
[CNSL-1935] Add automated release PR workflow #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
linhcrl
wants to merge
1
commit into
main
Choose a base branch
from
version-bump-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+106
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
|
|
||
| # 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 | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?