forked from open-telemetry/opentelemetry-python-genai
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (116 loc) · 4.53 KB
/
Copy pathprepare-release.yml
File metadata and controls
130 lines (116 loc) · 4.53 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: "Prepare release"
on:
workflow_dispatch:
inputs:
package:
type: choice
options:
- ''
- opentelemetry-instrumentation-genai-agno
- opentelemetry-instrumentation-genai-anthropic
- opentelemetry-instrumentation-google-genai
- opentelemetry-instrumentation-genai-langchain
- opentelemetry-instrumentation-genai-openai-agents
- opentelemetry-instrumentation-genai-openai
- opentelemetry-instrumentation-genai-portkey
- opentelemetry-instrumentation-genai-qwen-agent
- opentelemetry-util-genai
description: >
Restrict to a single package. Leave empty to prepare every package
with pending changelog fragments.
required: false
default: ''
permissions:
contents: read
env:
UV_FROZEN: "true"
run-name: "Prepare release${{ inputs.package && format(': {0}', inputs.package) || ' (all)' }}"
jobs:
prepare:
permissions:
contents: write
runs-on: cncf-ubuntu-2-8-x86
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: true # zizmor: ignore[artipacked] a later step pushes the prepared release branch
- name: Verify branch
run: |
if [[ "$GITHUB_REF_NAME" != "main" ]]; then
echo "This workflow should only be run against main"
exit 1
fi
- name: Select packages with changelog fragments
id: packages
run: |
set -e
mapfile -t candidates < <(./scripts/eachdist.py packages-with-changelog-fragments)
if [[ ${#candidates[@]} -eq 0 ]]; then
echo "No packages with changelog fragments found"
exit 1
fi
selected=()
filter='${{ inputs.package }}'
if [[ -n "$filter" ]]; then
for package in "${candidates[@]}"; do
if [[ "$package" == "$filter" ]]; then
selected+=("$package")
fi
done
if [[ ${#selected[@]} -eq 0 ]]; then
echo "Package '$filter' has no changelog fragments to release"
exit 1
fi
else
selected=("${candidates[@]}")
fi
printf 'Preparing: %s\n' "${selected[@]}"
{
echo "packages<<EOF"
printf '%s\n' "${selected[@]}"
echo "EOF"
echo "count=${#selected[@]}"
} >> "$GITHUB_OUTPUT"
- name: Install uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
- name: Prepare selected packages for release
run: |
while IFS= read -r package; do
[[ -z "$package" ]] && continue
echo "Preparing ${package}"
./scripts/prepare_package_for_release.sh "$package"
done <<< "${STEPS_PACKAGES_OUTPUTS_PACKAGES}"
env:
STEPS_PACKAGES_OUTPUTS_PACKAGES: ${{ steps.packages.outputs.packages }}
- name: Configure CLA-approved git bot
run: .github/scripts/use-cla-approved-github-bot.sh
- uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
id: otelbot-token
with:
client-id: ${{ vars.OTELBOT_CLIENT_ID }}
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
permission-pull-requests: write
- name: Create pull request
env:
GITHUB_TOKEN: ${{ steps.otelbot-token.outputs.token }}
PACKAGES: ${{ steps.packages.outputs.packages }}
COUNT: ${{ steps.packages.outputs.count }}
run: |
if [[ "$COUNT" -eq 1 ]]; then
package=$(echo "$PACKAGES" | head -n1)
version=$(./scripts/eachdist.py version --package "$package")
title="Prepare release for ${package} v${version}"
body="Prepare \`${package}\` v\`${version}\` for release."
branch="otelbot/prepare-${package}-v${version}"
else
title="Prepare release for all packages with changelog fragments"
body="Prepare all packages that have towncrier changelog fragments for release."
branch="otelbot/prepare-release-all-$(date +%Y%m%d)"
fi
git commit -a -m "$title"
git push origin HEAD:"$branch"
pr_url=$(gh pr create --title "$title" \
--body "$body" \
--head "$branch" \
--base main)
gh pr edit "$pr_url" --add-label release