forked from google/adk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (100 loc) · 3.89 KB
/
Copy pathrelease-cut.yml
File metadata and controls
109 lines (100 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Unified release manager. Supports:
# 1. Cutting a new release candidate branch from main or v1.
# 2. Regenerating/updating the changelog PR on an existing candidate branch.
name: "Release: Cut"
on:
workflow_dispatch:
inputs:
action:
description: 'Action to perform'
required: true
default: 'cut'
type: choice
options:
- cut
- regenerate
branch:
description: 'Branch to release from (main or v1)'
required: true
default: 'main'
type: choice
options:
- main
- v1
commit_sha:
description: 'Optional Commit SHA (only used for "cut" action; overrides branch latest)'
required: false
type: string
permissions:
contents: write
pull-requests: write
jobs:
cut-or-regenerate:
runs-on: ubuntu-latest
steps:
- name: Determine Branch Configurations
id: config
run: |
BRANCH="${{ inputs.branch }}"
if [ "$BRANCH" = "v1" ]; then
echo "base_ref=v1" >> $GITHUB_OUTPUT
echo "candidate_branch=release/v1-candidate" >> $GITHUB_OUTPUT
echo "config_file=.github/release-please-config-v1.json" >> $GITHUB_OUTPUT
echo "manifest_file=.github/.release-please-manifest-v1.json" >> $GITHUB_OUTPUT
else
echo "base_ref=main" >> $GITHUB_OUTPUT
echo "candidate_branch=release/candidate" >> $GITHUB_OUTPUT
echo "config_file=.github/release-please-config.json" >> $GITHUB_OUTPUT
echo "manifest_file=.github/.release-please-manifest.json" >> $GITHUB_OUTPUT
fi
# Action: CUT NEW RELEASE
- name: Checkout base ref (Cut)
if: inputs.action == 'cut'
uses: actions/checkout@v6
with:
ref: ${{ inputs.commit_sha || steps.config.outputs.base_ref }}
token: ${{ secrets.RELEASE_PAT }}
- name: Check for existing candidate branch (Cut)
if: inputs.action == 'cut'
run: |
CANDIDATE_BRANCH="${{ steps.config.outputs.candidate_branch }}"
if git ls-remote --exit-code --heads origin "$CANDIDATE_BRANCH" &>/dev/null; then
echo "Error: Branch $CANDIDATE_BRANCH already exists."
echo "Please finalize or delete the existing release candidate before starting a new one."
exit 1
fi
- name: Create and push candidate branch (Cut)
if: inputs.action == 'cut'
run: |
CANDIDATE_BRANCH="${{ steps.config.outputs.candidate_branch }}"
git checkout -b "$CANDIDATE_BRANCH"
git push origin "$CANDIDATE_BRANCH"
echo "Created and pushed branch: $CANDIDATE_BRANCH"
# Action: REGENERATE EXISTING PR
- name: Checkout existing candidate branch (Regenerate)
if: inputs.action == 'regenerate'
uses: actions/checkout@v6
with:
ref: ${{ steps.config.outputs.candidate_branch }}
token: ${{ secrets.RELEASE_PAT }}
# Run Release Please
- name: Run Release Please
uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.RELEASE_PAT }}
config-file: ${{ steps.config.outputs.config_file }}
manifest-file: ${{ steps.config.outputs.manifest_file }}
target-branch: ${{ steps.config.outputs.candidate_branch }}