mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
init
This commit is contained in:
@@ -28,22 +28,59 @@ jobs:
|
|||||||
permission: 'write'
|
permission: 'write'
|
||||||
issue-type: 'pull-request'
|
issue-type: 'pull-request'
|
||||||
|
|
||||||
- name: 'Get PR Status'
|
- name: 'Get Commits'
|
||||||
id: 'pr_status'
|
id: 'get_commits'
|
||||||
if: "startsWith(github.event.comment.body, '/patch')"
|
if: "startsWith(github.event.comment.body, '/patch')"
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
|
COMMENT_BODY: '${{ github.event.comment.body }}'
|
||||||
|
CURRENT_PR: '${{ github.event.issue.number }}'
|
||||||
run: |
|
run: |
|
||||||
gh pr view "${{ github.event.issue.number }}" --json mergeCommit,state > pr_status.json
|
# Find all PR numbers in the comment body (e.g., #123, owner/repo#456)
|
||||||
echo "MERGE_COMMIT_SHA=$(jq -r .mergeCommit.oid pr_status.json)" >> "$GITHUB_OUTPUT"
|
# The regex handles both formats and extracts just the number
|
||||||
echo "STATE=$(jq -r .state pr_status.json)" >> "$GITHUB_OUTPUT"
|
comment_prs=$(echo "$COMMENT_BODY" | grep -oP '(?:\S+/)?\S+#\K\d+')
|
||||||
|
|
||||||
|
# Combine with the current PR number, ensuring no duplicates
|
||||||
|
all_prs=$(echo -e "${CURRENT_PR}\n${comment_prs}" | sort -u)
|
||||||
|
|
||||||
|
echo "Found PRs to patch: ${all_prs}"
|
||||||
|
|
||||||
|
commit_shas=()
|
||||||
|
unmerged_prs=()
|
||||||
|
merged_prs=()
|
||||||
|
|
||||||
|
for pr in $all_prs; do
|
||||||
|
echo "Checking status of PR #${pr}..."
|
||||||
|
# Get PR status (state and merge commit)
|
||||||
|
pr_status=$(gh pr view "$pr" --json mergeCommit,state)
|
||||||
|
state=$(echo "$pr_status" | jq -r .state)
|
||||||
|
|
||||||
|
if [[ "$state" != "MERGED" ]]; then
|
||||||
|
unmerged_prs+=("$pr")
|
||||||
|
else
|
||||||
|
commit_sha=$(echo "$pr_status" | jq -r .mergeCommit.oid)
|
||||||
|
commit_shas+=("$commit_sha")
|
||||||
|
merged_prs+=("$pr")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ ${#unmerged_prs[@]} -gt 0 ]]; then
|
||||||
|
echo "ALL_MERGED=false" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "UNMERGED_PRS=$(IFS=,; echo "${unmerged_prs[*]}")" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "ALL_MERGED=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "COMMITS=$(IFS=,; echo "${commit_shas[*]}")" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "PR_NUMBERS=$(IFS=,; echo "${merged_prs[*]}")" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: 'Dispatch if Merged'
|
- name: 'Dispatch if Merged'
|
||||||
if: "steps.pr_status.outputs.STATE == 'MERGED'"
|
if: "steps.get_commits.outputs.ALL_MERGED == 'true'"
|
||||||
id: 'dispatch_patch'
|
id: 'dispatch_patch'
|
||||||
uses: 'actions/github-script@00f12e3e20659f42342b1c0226afda7f7c042325'
|
uses: 'actions/github-script@00f12e3e20659f42342b1c0226afda7f7c042325'
|
||||||
env:
|
env:
|
||||||
COMMENT_BODY: '${{ github.event.comment.body }}'
|
COMMENT_BODY: '${{ github.event.comment.body }}'
|
||||||
|
COMMITS: '${{ steps.get_commits.outputs.COMMITS }}'
|
||||||
|
PR_NUMBERS: '${{ steps.get_commits.outputs.PR_NUMBERS }}'
|
||||||
with:
|
with:
|
||||||
github-token: '${{ secrets.GITHUB_TOKEN }}'
|
github-token: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
script: |
|
script: |
|
||||||
@@ -60,17 +97,10 @@ jobs:
|
|||||||
// /patch preview
|
// /patch preview
|
||||||
if (commentBody.trim() === '/patch' || commentBody.trim() === '/patch both') {
|
if (commentBody.trim() === '/patch' || commentBody.trim() === '/patch both') {
|
||||||
channels = ['stable', 'preview'];
|
channels = ['stable', 'preview'];
|
||||||
} else if (commentBody.trim() === '/patch stable') {
|
} else if (commentBody.includes('stable')) {
|
||||||
channels = ['stable'];
|
channels = ['stable'];
|
||||||
} else if (commentBody.trim() === '/patch preview') {
|
} else if (commentBody.includes('preview')) {
|
||||||
channels = ['preview'];
|
channels = ['preview'];
|
||||||
} else {
|
|
||||||
// Fallback parsing for legacy formats
|
|
||||||
if (commentBody.includes('channel=preview')) {
|
|
||||||
channels = ['preview'];
|
|
||||||
} else if (commentBody.includes('--channel preview')) {
|
|
||||||
channels = ['preview'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Detected channels:', channels);
|
console.log('Detected channels:', channels);
|
||||||
@@ -87,9 +117,9 @@ jobs:
|
|||||||
workflow_id: 'release-patch-1-create-pr.yml',
|
workflow_id: 'release-patch-1-create-pr.yml',
|
||||||
ref: 'main',
|
ref: 'main',
|
||||||
inputs: {
|
inputs: {
|
||||||
commit: '${{ steps.pr_status.outputs.MERGE_COMMIT_SHA }}',
|
commits: process.env.COMMITS,
|
||||||
channel: channel,
|
channel: channel,
|
||||||
original_pr: '${{ github.event.issue.number }}',
|
original_prs: process.env.PR_NUMBERS,
|
||||||
environment: 'prod'
|
environment: 'prod'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -123,13 +153,13 @@ jobs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
- name: 'Comment on Failure'
|
- name: 'Comment on Failure'
|
||||||
if: "startsWith(github.event.comment.body, '/patch') && steps.pr_status.outputs.STATE != 'MERGED'"
|
if: "startsWith(github.event.comment.body, '/patch') && steps.get_commits.outputs.ALL_MERGED == 'false'"
|
||||||
uses: 'peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d'
|
uses: 'peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d'
|
||||||
with:
|
with:
|
||||||
token: '${{ secrets.GITHUB_TOKEN }}'
|
token: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
issue-number: '${{ github.event.issue.number }}'
|
issue-number: '${{ github.event.issue.number }}'
|
||||||
body: |
|
body: |
|
||||||
:x: The `/patch` command failed. This pull request must be merged before a patch can be created.
|
:x: The `/patch` command failed. The following pull request(s) must be merged before a patch can be created: #${{ steps.get_commits.outputs.UNMERGED_PRS }}
|
||||||
|
|
||||||
- name: 'Final Status Comment - Success'
|
- name: 'Final Status Comment - Success'
|
||||||
if: "always() && startsWith(github.event.comment.body, '/patch') && steps.dispatch_patch.outcome == 'success' && steps.dispatch_patch.outputs.dispatched_run_urls"
|
if: "always() && startsWith(github.event.comment.body, '/patch') && steps.dispatch_patch.outcome == 'success' && steps.dispatch_patch.outputs.dispatched_run_urls"
|
||||||
@@ -142,7 +172,8 @@ jobs:
|
|||||||
|
|
||||||
**📋 Details:**
|
**📋 Details:**
|
||||||
- **Channels**: `${{ steps.dispatch_patch.outputs.dispatched_channels }}`
|
- **Channels**: `${{ steps.dispatch_patch.outputs.dispatched_channels }}`
|
||||||
- **Commit**: `${{ steps.pr_status.outputs.MERGE_COMMIT_SHA }}`
|
- **PRs**: `${{ steps.get_commits.outputs.PR_NUMBERS }}`
|
||||||
|
- **Commits**: `${{ steps.get_commits.outputs.COMMITS }}`
|
||||||
- **Workflows Created**: ${{ steps.dispatch_patch.outputs.dispatched_run_count }}
|
- **Workflows Created**: ${{ steps.dispatch_patch.outputs.dispatched_run_count }}
|
||||||
|
|
||||||
**🔗 Track Progress:**
|
**🔗 Track Progress:**
|
||||||
@@ -160,7 +191,8 @@ jobs:
|
|||||||
|
|
||||||
**📋 Details:**
|
**📋 Details:**
|
||||||
- **Channels**: `${{ steps.dispatch_patch.outputs.dispatched_channels }}`
|
- **Channels**: `${{ steps.dispatch_patch.outputs.dispatched_channels }}`
|
||||||
- **Commit**: `${{ steps.pr_status.outputs.MERGE_COMMIT_SHA }}`
|
- **PRs**: `${{ steps.get_commits.outputs.PR_NUMBERS }}`
|
||||||
|
- **Commits**: `${{ steps.get_commits.outputs.COMMITS }}`
|
||||||
- **Workflows Created**: ${{ steps.dispatch_patch.outputs.dispatched_run_count }}
|
- **Workflows Created**: ${{ steps.dispatch_patch.outputs.dispatched_run_count }}
|
||||||
|
|
||||||
**🔗 Track Progress:**
|
**🔗 Track Progress:**
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
name: 'Release: Patch (1) Create PR'
|
name: 'Release: Patch (1) Create PR'
|
||||||
|
|
||||||
run-name: >-
|
run-name: >-
|
||||||
Release Patch (1) Create PR | S:${{ inputs.channel }} | C:${{ inputs.commit }} ${{ inputs.original_pr && format('| PR:#{0}', inputs.original_pr) || '' }}
|
Release Patch (1) Create PR | S:${{ inputs.channel }} | C:${{ inputs.commits }} ${{ inputs.original_prs && format('| PRs:#{0}', inputs.original_prs) || '' }}
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
commit:
|
commits:
|
||||||
description: 'The commit SHA to cherry-pick for the patch.'
|
description: 'The commit SHAs to cherry-pick for the patch (comma-separated).'
|
||||||
required: true
|
required: true
|
||||||
type: 'string'
|
type: 'string'
|
||||||
channel:
|
channel:
|
||||||
@@ -27,8 +27,8 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
type: 'string'
|
type: 'string'
|
||||||
default: 'main'
|
default: 'main'
|
||||||
original_pr:
|
original_prs:
|
||||||
description: 'The original PR number to comment back on.'
|
description: 'The original PR numbers to comment back on (comma-separated).'
|
||||||
required: false
|
required: false
|
||||||
type: 'string'
|
type: 'string'
|
||||||
environment:
|
environment:
|
||||||
@@ -85,9 +85,9 @@ jobs:
|
|||||||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
GH_TOKEN: '${{ secrets.GEMINI_CLI_ROBOT_GITHUB_PAT }}'
|
GH_TOKEN: '${{ secrets.GEMINI_CLI_ROBOT_GITHUB_PAT }}'
|
||||||
CLI_PACKAGE_NAME: '${{ vars.CLI_PACKAGE_NAME }}'
|
CLI_PACKAGE_NAME: '${{ vars.CLI_PACKAGE_NAME }}'
|
||||||
PATCH_COMMIT: '${{ github.event.inputs.commit }}'
|
PATCH_COMMITS: '${{ github.event.inputs.commits }}'
|
||||||
PATCH_CHANNEL: '${{ github.event.inputs.channel }}'
|
PATCH_CHANNEL: '${{ github.event.inputs.channel }}'
|
||||||
ORIGINAL_PR: '${{ github.event.inputs.original_pr }}'
|
ORIGINAL_PRS: '${{ github.event.inputs.original_prs }}'
|
||||||
DRY_RUN: '${{ github.event.inputs.dry_run }}'
|
DRY_RUN: '${{ github.event.inputs.dry_run }}'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
@@ -95,9 +95,9 @@ jobs:
|
|||||||
{
|
{
|
||||||
node scripts/releasing/create-patch-pr.js \
|
node scripts/releasing/create-patch-pr.js \
|
||||||
--cli-package-name="${CLI_PACKAGE_NAME}" \
|
--cli-package-name="${CLI_PACKAGE_NAME}" \
|
||||||
--commit="${PATCH_COMMIT}" \
|
--commits="${PATCH_COMMITS}" \
|
||||||
--channel="${PATCH_CHANNEL}" \
|
--channel="${PATCH_CHANNEL}" \
|
||||||
--pullRequestNumber="${ORIGINAL_PR}" \
|
--pullRequestNumbers="${ORIGINAL_PRS}" \
|
||||||
--dry-run="${DRY_RUN}"
|
--dry-run="${DRY_RUN}"
|
||||||
} 2>&1 | tee >(
|
} 2>&1 | tee >(
|
||||||
echo "LOG_CONTENT<<EOF" >> "$GITHUB_ENV"
|
echo "LOG_CONTENT<<EOF" >> "$GITHUB_ENV"
|
||||||
@@ -107,12 +107,12 @@ jobs:
|
|||||||
echo "EXIT_CODE=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT"
|
echo "EXIT_CODE=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: 'Comment on Original PR'
|
- name: 'Comment on Original PR'
|
||||||
if: 'always() && inputs.original_pr'
|
if: 'always() && inputs.original_prs'
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
ORIGINAL_PR: '${{ github.event.inputs.original_pr }}'
|
ORIGINAL_PRS: '${{ github.event.inputs.original_prs }}'
|
||||||
EXIT_CODE: '${{ steps.create_patch.outputs.EXIT_CODE }}'
|
EXIT_CODE: '${{ steps.create_patch.outputs.EXIT_CODE }}'
|
||||||
COMMIT: '${{ github.event.inputs.commit }}'
|
COMMITS: '${{ github.event.inputs.commits }}'
|
||||||
CHANNEL: '${{ github.event.inputs.channel }}'
|
CHANNEL: '${{ github.event.inputs.channel }}'
|
||||||
REPOSITORY: '${{ github.repository }}'
|
REPOSITORY: '${{ github.repository }}'
|
||||||
GITHUB_RUN_ID: '${{ github.run_id }}'
|
GITHUB_RUN_ID: '${{ github.run_id }}'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: 'Release: Patch (3) Release'
|
name: 'Release: Patch (3) Release'
|
||||||
|
|
||||||
run-name: >-
|
run-name: >-
|
||||||
Release Patch (3) Release | T:${{ inputs.type }} | R:${{ inputs.release_ref }} ${{ inputs.original_pr && format('| PR:#{0}', inputs.original_pr) || '' }}
|
Release Patch (3) Release | T:${{ inputs.type }} | R:${{ inputs.release_ref }} ${{ inputs.original_prs && format('| PRs:#{0}', inputs.original_prs) || '' }}
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@@ -27,8 +27,8 @@ on:
|
|||||||
description: 'The branch, tag, or SHA to release from.'
|
description: 'The branch, tag, or SHA to release from.'
|
||||||
required: true
|
required: true
|
||||||
type: 'string'
|
type: 'string'
|
||||||
original_pr:
|
original_prs:
|
||||||
description: 'The original PR number to comment back on.'
|
description: 'The original PR numbers to comment back on.'
|
||||||
required: false
|
required: false
|
||||||
type: 'string'
|
type: 'string'
|
||||||
environment:
|
environment:
|
||||||
@@ -208,10 +208,10 @@ jobs:
|
|||||||
--label 'release-failure,priority/p0'
|
--label 'release-failure,priority/p0'
|
||||||
|
|
||||||
- name: 'Comment Success on Original PR'
|
- name: 'Comment Success on Original PR'
|
||||||
if: '${{ success() && github.event.inputs.original_pr }}'
|
if: '${{ success() && github.event.inputs.original_prs }}'
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
ORIGINAL_PR: '${{ github.event.inputs.original_pr }}'
|
ORIGINAL_PRS: '${{ github.event.inputs.original_prs }}'
|
||||||
SUCCESS: 'true'
|
SUCCESS: 'true'
|
||||||
RELEASE_VERSION: '${{ steps.patch_version.outputs.RELEASE_VERSION }}'
|
RELEASE_VERSION: '${{ steps.patch_version.outputs.RELEASE_VERSION }}'
|
||||||
RELEASE_TAG: '${{ steps.patch_version.outputs.RELEASE_TAG }}'
|
RELEASE_TAG: '${{ steps.patch_version.outputs.RELEASE_TAG }}'
|
||||||
@@ -225,10 +225,10 @@ jobs:
|
|||||||
node scripts/releasing/patch-comment.js
|
node scripts/releasing/patch-comment.js
|
||||||
|
|
||||||
- name: 'Comment Failure on Original PR'
|
- name: 'Comment Failure on Original PR'
|
||||||
if: '${{ failure() && github.event.inputs.original_pr }}'
|
if: '${{ failure() && github.event.inputs.original_prs }}'
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
ORIGINAL_PR: '${{ github.event.inputs.original_pr }}'
|
ORIGINAL_PRS: '${{ github.event.inputs.original_prs }}'
|
||||||
SUCCESS: 'false'
|
SUCCESS: 'false'
|
||||||
RELEASE_VERSION: '${{ steps.patch_version.outputs.RELEASE_VERSION }}'
|
RELEASE_VERSION: '${{ steps.patch_version.outputs.RELEASE_VERSION }}'
|
||||||
RELEASE_TAG: '${{ steps.patch_version.outputs.RELEASE_TAG }}'
|
RELEASE_TAG: '${{ steps.patch_version.outputs.RELEASE_TAG }}'
|
||||||
|
|||||||
Reference in New Issue
Block a user