Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd50a31e

Browse files
authored
chore(scripts): auto create autoversion PR from release script (#13074)
Ref#12465
1 parent365231b commitd50a31e

File tree

5 files changed

+88
-7
lines changed

5 files changed

+88
-7
lines changed

‎scripts/release.sh‎

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ script_check=1
5353
mainline=1
5454
channel=mainline
5555

56+
# These values will be used for any PRs created.
57+
pr_review_assignee=${CODER_RELEASE_PR_REVIEW_ASSIGNEE:-@me}
58+
pr_review_reviewer=${CODER_RELEASE_PR_REVIEW_REVIEWER:-bpmct,stirby}
59+
5660
args="$(getopt -o h -l dry-run,help,ref:,mainline,stable,major,minor,patch,force,ignore-script-out-of-date --"$@")"
5761
evalset --"$args"
5862
whiletrue;do
@@ -294,7 +298,7 @@ log "Release tags for ${new_version} created successfully and pushed to ${remote
294298

295299
log
296300
# Write to a tmp file for ease of debugging.
297-
release_json_file=$(mktemp -t coder-release.json)
301+
release_json_file=$(mktemp -t coder-release.json.XXXXXX)
298302
log"Writing release JSON to${release_json_file}"
299303
jq -n \
300304
--argjson dry_run"${dry_run}" \
@@ -310,6 +314,49 @@ maybedryrun "${dry_run}" cat "${release_json_file}" |
310314
log
311315
log"Release workflow started successfully!"
312316

317+
log
318+
log"Would you like for me to create a pull request for you to automatically bump the version numbers in the docs?"
319+
while [[!${create_pr:-}=~ ^[YyNn]$ ]];do
320+
read -p"Create PR? (y/n)" -n 1 -r create_pr
321+
log
322+
done
323+
if [[${create_pr}=~ ^[Yy]$ ]];then
324+
pr_branch=autoversion/${new_version}
325+
title="docs: bump${channel} version to${new_version}"
326+
body="This PR was automatically created by the [release script](https://github.com/coder/coder/blob/main/scripts/release.sh).
327+
328+
Please review the changes and merge if they look good and the release is complete.
329+
330+
You can follow the release progress [here](https://github.com/coder/coder/actions/workflows/release.yaml) and view the published release [here](https://github.com/coder/coder/releases/tag/${new_version}) (once complete)."
331+
332+
log
333+
log"Creating branch\"${pr_branch}\" and updating versions..."
334+
335+
create_pr_stash=0
336+
if! git diff --quiet --exit-code -- docs;then
337+
maybedryrun"${dry_run}" git stash push --message"scripts/release.sh: autostash (autoversion)" -- docs
338+
create_pr_stash=1
339+
fi
340+
maybedryrun"${dry_run}" git checkout -b"${pr_branch}""${remote}/${branch}"
341+
execrelative go run ./release autoversion --channel"${channel}""${new_version}" --dry-run
342+
maybedryrun"${dry_run}" git add docs
343+
maybedryrun"${dry_run}" git commit -m"${title}"
344+
# Return to previous branch.
345+
maybedryrun"${dry_run}" git checkout -
346+
if((create_pr_stash));then
347+
maybedryrun"${dry_run}" git stash pop
348+
fi
349+
350+
log"Creating pull request..."
351+
maybedryrun"${dry_run}" gh pr create \
352+
--assignee"${pr_review_assignee}" \
353+
--reviewer"${pr_review_reviewer}" \
354+
--base"${branch}" \
355+
--head"${pr_branch}" \
356+
--title"${title}" \
357+
--body"${body}"
358+
fi
359+
313360
if((dry_run));then
314361
# We can't watch the release.yaml workflow if we're in dry-run mode.
315362
exit 0

‎scripts/release/main.go‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,18 @@ func (r *releaseCommand) autoversionFile(ctx context.Context, file, channel, ver
381381
}
382382
}
383383
ifmatchRe!=nil {
384-
// Apply matchRe and find the group named "version", then replace it with the new version.
385-
// Utilize the index where the match was found to replace the correct part. The only
386-
// match group is the version.
384+
// Apply matchRe and find the group named "version", then replace it
385+
// with the new version.
387386
ifmatch:=matchRe.FindStringSubmatchIndex(line);match!=nil {
388-
logger.Info(ctx,"updating version number","line_number",i+1,"match",match)
389-
lines[i]=line[:match[2]]+version+line[match[3]:]
387+
vg:=matchRe.SubexpIndex("version")
388+
ifvg==-1 {
389+
logger.Error(ctx,"version group not found in match","num_subexp",matchRe.NumSubexp(),"subexp_names",matchRe.SubexpNames(),"match",match)
390+
returnxerrors.Errorf("bug: version group not found in match")
391+
}
392+
start:=match[vg*2]
393+
end:=match[vg*2+1]
394+
logger.Info(ctx,"updating version number","line_number",i+1,"match_start",start,"match_end",end,"old_version",line[start:end])
395+
lines[i]=line[:start]+version+line[end:]
390396
matchRe=nil
391397
break
392398
}

‎scripts/release/tag_version.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ fi
191191

192192
# Ensure the ref is in the release branch.
193193
branch_contains_ref=$(git branch --contains"${ref}" --list"${release_branch}" --format='%(refname)')
194-
if [[-z$branch_contains_ref ]];then
194+
if((!dry_run))&&[[-z$branch_contains_ref ]];then
195195
error"Provided ref (${ref_name}) is not in the required release branch (${release_branch})."
196196
fi
197197

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#Some documentation
2+
3+
1. Run the following command to install the chart in your cluster.
4+
5+
For the**mainline** Coder release:
6+
7+
<!-- autoversion(mainline): "--version [version] # trailing comment!"-->
8+
9+
```shell
10+
helm install coder coder-v2/coder \
11+
--namespace coder \
12+
--values values.yaml \
13+
--version 2.10.0# trailing comment!
14+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Some documentation
2+
3+
1. Run the following command to install the chart in your cluster.
4+
5+
For the **mainline** Coder release:
6+
7+
<!-- autoversion(mainline): "--version [version] # trailing comment!" -->
8+
9+
```shell
10+
helm install coder coder-v2/coder \
11+
--namespace coder \
12+
--values values.yaml \
13+
--version 2.11.1 # trailing comment!
14+
```

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp