-
Notifications
You must be signed in to change notification settings - Fork 1.2k
145 lines (120 loc) · 4.74 KB
/
update-copilot-dependency.yml
File metadata and controls
145 lines (120 loc) · 4.74 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: "Update @github/copilot Dependency"
on:
workflow_dispatch:
inputs:
version:
description: 'Target version of @github/copilot (e.g. 0.0.420)'
required: true
type: string
permissions:
contents: write
pull-requests: write
jobs:
update:
name: "Update @github/copilot to ${{ inputs.version }}"
runs-on: ubuntu-latest
steps:
- name: Validate version input
env:
VERSION: ${{ inputs.version }}
run: |
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9._-]+)?$ ]]; then
echo "::error::Invalid version format '$VERSION'. Expected semver (e.g. 0.0.420)."
exit 1
fi
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- uses: actions/setup-dotnet@v5
with:
dotnet-version: "10.0.x"
# Rust generator runs `cargo fmt` on its output under stable rustfmt;
# nightly rustfmt is needed for unstable format options (group_imports,
# imports_granularity, reorder_impl_items) pinned in
# `rust/.rustfmt.nightly.toml`. See codegen-check.yml for the same step.
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.94.0"
components: rustfmt
- name: Install nightly rustfmt
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2026-04-14
components: rustfmt
- name: Update @github/copilot in nodejs
env:
VERSION: ${{ inputs.version }}
working-directory: ./nodejs
run: npm install "@github/copilot@$VERSION"
- name: Update @github/copilot in test harness
env:
VERSION: ${{ inputs.version }}
working-directory: ./test/harness
run: npm install "@github/copilot@$VERSION"
- name: Refresh nodejs/samples lockfile
working-directory: ./nodejs/samples
run: npm install
- name: Install codegen dependencies
working-directory: ./scripts/codegen
run: npm ci
- name: Run codegen
working-directory: ./scripts/codegen
run: npm run generate
- name: Format generated code
run: |
cd nodejs && npx prettier --write "src/generated/**/*.ts"
cd ../dotnet && dotnet format src/GitHub.Copilot.SDK.csproj
cd ../rust && cargo +nightly-2026-04-14 fmt --all -- --config-path .rustfmt.nightly.toml
- name: Create pull request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ inputs.version }}
run: |
BRANCH="update-copilot-$VERSION"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
if git rev-parse --verify "origin/$BRANCH" >/dev/null 2>&1; then
git fetch origin "$BRANCH"
git checkout "$BRANCH"
git reset --hard "origin/$BRANCH"
else
git checkout -b "$BRANCH"
fi
git add -A
if git diff --cached --quiet; then
echo "No changes detected; skipping commit and PR creation."
exit 0
fi
git commit -m "Update @github/copilot to $VERSION
- Updated nodejs and test harness dependencies
- Re-ran code generators
- Formatted generated code"
git push origin "$BRANCH" --force-with-lease
PR_STATE="$(gh pr view "$BRANCH" --json state --jq '.state' 2>/dev/null || echo "")"
if [ "$PR_STATE" = "OPEN" ]; then
if [ "$(gh pr view "$BRANCH" --json isDraft --jq '.isDraft')" = "false" ]; then
gh pr ready "$BRANCH" --undo
echo "Pull request for branch '$BRANCH' already existed and was moved back to draft after updating the branch."
else
echo "Pull request for branch '$BRANCH' already exists and is already a draft; updated branch only."
fi
else
gh pr create \
--draft \
--title "Update @github/copilot to $VERSION" \
--body "Automated update of \`@github/copilot\` to version \`$VERSION\`.
### Changes
- Updated \`@github/copilot\` in \`nodejs/package.json\` and \`test/harness/package.json\`
- Re-ran all code generators (\`scripts/codegen\`)
- Formatted generated output
### Next steps
When ready, click **Ready for review** to trigger CI checks.
> Created by the **Update @github/copilot Dependency** workflow." \
--base main \
--head "$BRANCH"
fi